views:

195

answers:

1

I have a simple application using netbeans for developing and maven for building et all. My application uses camel , spring XML configured. I wanted to build an executable jar with dependencies so i am using the maven-assembly plugin with 'jar-with-deps' descriptor. The jar is built ok but I think that since all the dependencies get unwrapped and some of these have the same resources in the same paths as others, then they overwrite each other. I verified this by browsing the jar with winrar and i found multiple occurences of the same file in many places. I am thinking this is unsolvable by some simple maven configuration because i cannot stop a dependency wanting a resource in a specific path, used also by another dependency. BTW the app runs ok inside netbeans. Also I saw multiple occurences of my application classes. That is more strange, but i cant figure out why.

All in all, I want to know if:

  1. Is there any simple solution that finds such conflicts and at least reports them if not corrects them? (and how)

  2. Can i tell the archiver (in maven) not to unwrap the deps but just include the jars in a parent jar and then just include the jars in the manifest classpath and how? Will this solve the problem or it has the same result?

  3. Why are there also multiple occurrences of my application classes in the same path?

To give you a picture of the problem , the current resulting jar, when viewd with WinRAR, has 3 instances of 'log4j.properties' in root path and 7 instances of file 'spring.schemas' in meta-inf/ path, to name a few.

+1  A: 

I don't think that is possbile to .zip all .jars into a single .jar. Many of these .jars have resources in their .jar file (log4j.properties, spring XML files) that are located in the same folder, so there will be clash.

Its better to provide start scripts that can start your application by setting the classpath. And I remember in either JDK1.5 or is it 1.6 you can set a folder as the classpath and it will include all jars from this folder.

Claus Ibsen