Archive

Archive for the ‘Maven3’ Category

Maven best practices

February 23, 2011 4 comments

Although Maven offers a “convention over configuration” solution, there is still more then enough configuration necessary to cause some serious headache.  In this post I will share some best practices with you that will ease maintenance of your POM files.

Read more…

Categories: Maven3 Tags: ,

How to add jars to your Maven project

If you want to physically add jar files to your maven project, so they don’t have to be downloaded from a repository, you can use the system dependency scope, and point to a location in your project:

<dependency>
  <groupId>com.missionmode</groupId>
  <artifactId>missionmode-api</artifactId>
  <version>3.6.51</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/MMAPI-3.6.51.jar</systemPath>
</dependency>
Categories: Maven3 Tags: , , ,

How to create a webservice client with Maven and JAX-WS

Maven allows you to integrate the generation of a JAX-WS webservice client into your build process. To do this, do the following:

1. Create a new module for the webservice client in your maven project.
2. Add the following configuration to the pom.xml of the new module:

<build>
 <plugins>
  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>jaxws-maven-plugin</artifactId>
   <version>1.10</version>
   <executions>
    <execution>
     <goals>
      <goal>wsimport</goal>
     </goals>
    </execution>
   </executions>
   <configuration>
    <packageName>nl.interact.ipds.agentvi.connector.schema</packageName>
    <wsdlUrls>
     <wsdlUrl>http://www.ignyte.com/webservices/ignyte.whatsshowing.webservice/moviefunctions.asmx?wsdl</wsdlUrl>
    </wsdlUrls>
    <extension>true</extension>
   </configuration>
  </plugin>
 </plugins>
</build>

<dependencies>
 <dependency>
  <groupId>com.sun.xml.ws</groupId>
  <artifactId>jaxws-tools</artifactId>
  <version>2.1.4</version>
 </dependency>
 <dependency>
  <groupId>org.jvnet</groupId>
  <artifactId>mimepull</artifactId>
  <version>1.3</version>
 </dependency>
</dependencies>

3. The jar that maven generates with the above config, can be used to write a client program like the following:

MovieInformation info = new MovieInformation();
ArrayOfTheater theaters = info.getMovieInformationSoap12().getTheatersAndMovies(“10001″, 1);
for (Theater t : theaters.getTheater()) {
  System.out.println(“Theatre: “+t.getName()+”, “+t.getAddress());
  ArrayOfMovie movies = t.getMovies();
  for (Movie m : movies.getMovie()) {
    System.out.println(” -”+m.getName()+”, (Rating: “+m.getRating()+”)”);
  }
}
Categories: Java, Maven3 Tags: ,

Why the “MAVEN2_CLASSPATH_CONTAINER will not be exported or published”

March 5, 2009 11 comments

On certain occasions Eclipse will present you with the following warning:

Classpath entry org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER will not be exported or published. Runtime ClassNotFoundExceptions may result.

So solve this, do the following:

  1. Open the properties of the project that generates this warning
  2. Click on “Java Build Path”
  3. Click on the tab “Order and Export”
  4. Enable “Maven Dependencies”
  5. Click on “Ok”
  6. Open the “Problems” view
  7. Select the warning we are trying to solve, and press “Ctrl-1”
  8. Click on “Ok”

The problem is now solved. It may take some time before the warning disapears because the project needs to rebuild before it goes away.

Why my JAXB generated classes didn’t show up in the packaged jar

February 12, 2009 Leave a comment

The following problem bugged me for like 2 days:

My maven project generates classes using a maven jaxb2 plugin, but it also inherits settings from a parent project. After running “maven package” and seeing the jaxb plugin generate classes from the schema i was surprised to see zero classes showing up in the created jar file. After many hours of commenting out pieces of maven configuration in both my project and in the parent i found out that the “fork” setting on the compiler plugin was set to “true”. This didn’t seem like a setting that was causing the problem, but when i switched it to false the problem was suddenly sovled and my beloved classes settled nicely in the generated jar file.

I still don’t know why this setting causes the problem, but if you have the same problem you have now found the solution!

How to create an all-inclusive jar using Maven2

September 7, 2008 Leave a comment

When using maven2 you can create an executable jar file that contains all dependencies necessary at runtime using the following config:

Read more…

Categories: Maven3 Tags: ,