I am using Apache Axis to generate the java source from my WSDL file. The maven run was successful without any errors but no generated classes.
Question: What am I missing here?
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceDirectory>/src/main/resources</sourceDirectory>
<outputDirectory>/src/main/java</outputDirectory>
<wsdlFiles>
<wsdlFile>thesourcewsdlfile.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
I am clearly not sure what is the problem with this configuration.
Try to define source and output directory bases on your maven project, that is, using standard maven properties to point to the right absolute path at runtime, changing your configuration as following:
<sourceDirectory>${basedir}/src/main/resources</sourceDirectory>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
Based on this configuration, the thesourcewsdlfile.wsdl is supposed to be located under src/main/resources/thesourcewsdlfile.wsdl
The full plugin configuration should hence be:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceDirectory>${basedir}/src/main/resources</sourceDirectory>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<wsdlFiles>
<wsdlFile>thesourcewsdlfile.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Moreover, the following dependencies must be added to the project:
<dependencies>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc-api</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
As a general note, it would be much better to place generated sources under the target directory, since they are generated automatically and should not be added to the version control in use. A standard location would then be any desired (meaningful) directory under ${project.build.directory}/generated-sources (where ${project.build.directory} is the standard property pointing to the target directory indeed).
IMHO you are missing the wsdl folder under resources, just add it and run:
mvn clean generate-sources
Related
We are using JaCoCo for unit test code coverage in our multi-module maven project and able to get the coverage info(jacoco.exec) for most of the modules where unit tests are available. The only issue that i'm seeing is, jacoco.exec is not getting generated for some of the classes in few modules even though unit tests are available (note that surefire-reports are generated).
Able to get coverage info for the same unit tests when used Cobertura.
The following is the parent pom.xml where I've added jacoco-maven-plugin info.
Please help if there are any issues with pom.xml.
<modules>
<module>module1</module>
<module>module2</module>
<module>module3</module>
<module>module4</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>argLine</propertyName>
</configuration>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>#{argLine} -Xmx500m -XX:MaxPermSize=256m</argLine>
</configuration>
</plugin>
</plugins>
</build>
Thanks in advance!!
Error like this:- java.lang.ClassNotFoundException:
com.sun.jersey.spi.container.servlet.ServletContainer at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at
org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
It will work when I put all jar files under lib (WEB-INF/lib) folder.But I want pom file to solve this.
It's all about your configuration resp. pom.xml and incomplete tutorials. If you want your pom.xml to solve this for you, you need to add a few things.
Plugins
First things first. The little red cross and the fact, that your project is configured to run under Java 1.5 lets me guess, that you have compatibility issues with your deps. Especialy with javax.ws.rs \ javax.ws.rs-api.
To solve this, you may want maven handle it by the maven-compiler-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Then, you possibly want to run the server "in" eclipse. Here you can use the tomcat7-maven-plugin:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
The last plugin to use is the maven-war-plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Jersey Dependencies
To start with Jersey you just need to configure a single dep:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
I need to say, that there are newer versions available, but you might have reasons to use 1.19
Your complete pom.xml should now look like:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sujith</groupId>
<artifactId>jersey-sample</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.maven-compiler-plugin.version>3.5.1</project.maven-compiler-plugin.version>
<project.tomcat7-maven-plugin.version>2.2</project.tomcat7-maven-plugin.version>
<project.maven-war-plugin.version>2.6</project.maven-war-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
<outputDirectory>${project.artifactId}</outputDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${project.maven-compiler-plugin.version}</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>${project.tomcat7-maven-plugin.version}</version>
<configuration>
<port>8080</port>
<path>/</path>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${project.maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
In Eclipse you now right click your project and select -> Run As / Debug As -> Maven build...
In the Edit configuration and lauch menu, you now add the goal: clean install tomcat7:run-war and that's it.
Your server should start and the resource is available under http://127.0.0.1:8080 / {web.xml\servlet-mapping\url-pattern} / {path-to-resource}
One last thing. Please check out the original examples first. Most of the tutorial out there are crap. And finally, pls read the how to ask pages.
Have a nice day.
I am trying to generate enunciate documentation form a mix of classes, all JAX-RS annotated, some coded inn java, some in clojure.
I have built a maven project that simply depends on a war file containing the service classes:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.27</version>
<configuration>
<configFile>src/conf/enunciate.xml</configFile>
<additionalClasspathEntries>
${settings.localRepository}/com/ws/scholar/0.96-SNAPSHOT/scholar-0.96-SNAPSHOT.war
</additionalClasspathEntries>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.ws</groupId>
<artifactId>scholar</artifactId>
<version>0.96-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
I cannot get any service documentation to generate.
When running mvn enunciate:docs -X, I see my classes "Noticed":
[DEBUG] Noticed class WEB-INF.classes.com.ws.scholar.resources.ClientResource in /.m2/repository/com/ws/scholar/0.96-SNAPSHOT/scholar-0.96-SNAPSHOT.war.
Can anyone offer guidance or corrections to my configuration?
Unfortunately, you can't just add a war as a dependency and have the classes therein get picked up on the classpath. A war isn't a jar.
Instead, you'll probably need to use the attachClasses parameter of the maven-war-plugin to export your classes as a jar in addition to the war. Then you can depend on that jar like this:
<dependency>
<groupId>com.ws</groupId>
<artifactId>scholar</artifactId>
<version>0.96-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>
We are using Soap-UI for writing some web-services tests.
I put this XPath validation in one of them:
count(//mynode) > 1
This is working fine while executing from SOAP-UI software, but when the continuous integration (jenkins) execute it through the Maven Soap-UI plugin, I receive this error:
[XPath Match] junit/framework/ComparisonFailure
I guess there is a missing library somewhere but cannot figure what to do.
What is strange is that I do not refers any jUnit tests as I just call URL's of web-services.
Finally I found that there is a junit dependency to add with the help of this thread
Here is the dependency I had to add in my pom.xml file:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
For the maven-soapui-plugin.
The whole config will looks like:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<id>services-customer</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<projectFile>services/customer/smoke-tests.xml</projectFile>
<projectProperties>
<value>IdmpDataEndPointHost=${smoke.dataload.url}</value>
<value>WebServiceEndPointHost=http://${smoke.tomcat.server}:${smoke.tomcat.port}</value>
</projectProperties>
<outputFolder>${project.build.directory}/soapui-results/services/customer</outputFolder>
<junitReport>true</junitReport>
<testFailIgnore>true</testFailIgnore>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
</dependencies>
</plugin>
I am new to maven, I would like to change the order of the maven plugins execution.
In my pom.xml, I have maven-assembly-plugin and maven-ant-plugin.
maven-assembly-plugin for creating a zip file.
maven-ant-plugin for copying the zip file from target to some other directory.
When I run pom.xml, maven-ant-plugin got triggered, and looking for zip file finally I got the error saying zip file not found.
Please suggest to me the way how to run maven-assembly-plugin first before maven-ant-plugin so that it will find and copy the zip file to the corresponding directory.
Since you say you are very new to Maven....Maven builds are executions of an ordered series of phases. These phases are determined by the lifecycle that is appropriate to your project based on its packaging.
Therefore, you control when a plugin's goal is executed by binding it to a particular phase.
Hope that helps.
EDIT: Also, since Maven 3.0.3, for two plugins bound to the same phase, the order of execution is the same as the order in which you define them. For example:
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-3</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
...
</execution>
</executions>
</plugin>
In the above instance, the execution order would be:
maven-plugin-3 (generate-resources)
maven-plugin-1 (process-resources)
maven-plugin-2 (process-resources)
Plugins in the same phase are executed in the declared order.
In the case of pom hierachy, you have to re-declare the plugins from the parent pom (just its groupId and its artifactId) into the child pom to specify the execution order :
Parent pom.xml
<plugins>
<plugin>
<groupId>groupid.maven.1</groupId>
<artifactId>maven-plugin-1</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
Child pom.xml
<plugins>
<plugin>
<groupId>groupid.maven.2</groupId>
<artifactId>maven-plugin-2</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>groupid.maven.1</groupId>
<artifactId>maven-plugin-1</artifactId>
</plugin>
</plugins>
Then the execution is :
maven.plugin.2
maven.plugin.1
In Maven 3.0.3 and later, there are two rules
Plugin executions are ordered according to their phases. See
https://maven.apache.org/ref/current/maven-core/lifecycles.html for
the order of phases.
For example, here mavin-plugin-1 is executed before maven-plugin-2
because the process-resources phase is defined as taking place before
the compile phase.
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>compile</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
If multiple executions have the same phase, then the first one to be
executed will be the built-in one (e.g. maven-compiler-plugin) whose id
is default-something, then the other executions will take place in the
order they appear in your pom file.
For example, if you have this somewhere in your pom
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>my-compile</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>4.5.6</version>
<executions>
<execution>
<id>my-compile-2</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
and this anywhere in your effective pom
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>**default-compile**</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
...
</executions>
</plugin>
then maven-compiler-plugin will execute maven-compiler-plugin followed by maven-plugin-1, and maven-plugin-2.
If you want maven-compiler-plugin:compile goal to execute after maven-plugin-1 then you could do this
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.2.3</version>
<executions>
<execution>
<id>my-compile</id>
<phase>compile</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<id>something-other-than-**default-compile**</id>
<phase>compile</phase>
</execution>
<execution>
<id>**default-compile**</id>
<phase>none</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
This might be an old questions and the answers provided are correct, just adding an extra point regarding the case for inheritance because I found myself in this situation and could not figure it out.
There seem to be 2 rules for plugin order execution when no inheritance is provided:
The phases to which the plugins are bound to are executed in the order provided in the documentation: see "Default Lifecycle" on Introduction to the Build Lifecycle
Plugin executions are ordered according to their phases.
"In Maven 2.0.5 and above, multiple goals bound to a phase are executed in the same order as they are declared in the POM, however multiple instances of the same plugin are not supported. Multiple instances of the same plugin are grouped to execute together and ordered in Maven 2.0.11 and above" - source
IN THE CASE OF INHERITANCE: "Parent POM bindings execute AFTER child bindings.". So if your plugins are not executed in the order you expect them to (by following the previous two points mentioned in this answer), you should maybe look if they are defined in the parent POM. - Incorrect execution order of plugins in the same phase.
I could not find this being clarely documented anywhere, however there is an open ticket to document the algorithm calculating the order of plugin executions.