You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Thorsten Heit <th...@vkb.de> on 2011/05/13 16:45:45 UTC

Incorrect assembly created with Maven 3.0.3

Hi,

I have a strange problem when building an assembly with Maven 3.0.3, and I 
don't know where to debug...:

My project uses a combination of the appassembler mojo (1.1.1) and 
assembly plugin (2.2.1), both attached to the "package" phase, to create a 
tar.gz archive that basically has the following structure:

my-prg/
my-prg/bin/
my-prg/bin/my-prg.cmd
my-prg/bin/my-prg.sh
my-prg/bin/local-log4j.xml
my-prg/bin/log4j.dtd
my-prg/lib/
(lots of Jar files)
my-prg/log/
my-prg/log/readme.txt

An end user unzips the archive and starts the program by one of the shell 
scripts (.cmd for Windows, .sh for Unix).

Today I released a new version of my program, and just before informing my 
colleages that it's available I tested it by myself from a Windows box and 
finally got ClassNotFoundException because of a missing dependency Jar in 
the lib folder; more precisely xalan:serializer:2.7.1

Looking into the tar.gz archive I couldn't see that jar although it is 
used as a transitive compile-time dependency somewhere in the dependency 
tree of my program. The latter is verifiable by for example mvn 
dependency:tree:

thorsten$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]  
[INFO] 
------------------------------------------------------------------------
[INFO] Building my-prg 0.4.6
[INFO] 
------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ my-prg ---
[INFO] prg:my-prg:jar:0.4.6
...
[INFO] |  +- lib:v-base:jar:1.8:compile
[INFO] |  |  +- org.apache.axis:axis-saaj:jar:1.4:compile
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1.1:compile (version 
managed from 1.0.4)
[INFO] |  |  +- commons-validator:commons-validator:jar:1.0.2:compile
[INFO] |  |  |  +- commons-beanutils:commons-beanutils:jar:1.5:compile
[INFO] |  |  |  \- commons-collections:commons-collections:jar:2.1:compile
[INFO] |  |  +- commons-digester:commons-digester:jar:1.8:compile
[INFO] |  |  +- oro:oro:jar:2.0.8:compile
[INFO] |  |  +- commons-discovery:commons-discovery:jar:0.4:compile
[INFO] |  |  +- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] |  |  +- xerces:xercesImpl:jar:2.9.1:compile
[INFO] |  |  \- xalan:xalan:jar:2.7.1:compile
[INFO] |  |     \- xalan:serializer:jar:2.7.1:compile
...


For curiosity I did a "mvn package" on my project by using Maven 2.2.1 and 
exactly the same code base. Comparing the resulting archives shows an 
interesting phenomenon:

* The archive created by Maven 3.0.3 contains a dependency to 
org.apache.xmlgraphics:batik-js:1.7 (not shown by dependency:tree) and is 
missing one to xalan:serializer:jar
* The archive created by Maven 2.2.1 contains only those dependencies that 
are listed in the dependency tree with scope "compile".


>From my pom.xml:

(...)
<build>
        <resources>
                <resource>
                        <directory>src/main/resources</directory>
                </resource>

                <resource>
                        <targetPath>../my-prg</targetPath>
                </resource>
        </resources>

        <plugins>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.3.2</version>
                        <configuration>
                                <source>1.6</source>
                                <target>1.6</target>
                        </configuration>
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>2.5</version>
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.8</version>
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>2.1</version><!--$NO-MVN-MAN-VER$ -->
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>2.5</version>
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-scm-plugin</artifactId>
                        <version>1.5</version>
                        <configuration>
                                <providerImplementations>
                                        <cvs>cvs_native</cvs>
                                </providerImplementations>
                                <goals>install</goals>
                        </configuration>
                </plugin>

                <!--
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>3.0-beta-3</version>
                        <configuration>
                                <locales>de</locales>
                        </configuration>
                </plugin>
                -->

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.1.2</version>
                </plugin>

                <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>appassembler-maven-plugin</artifactId>
                        <version>1.1.1</version>
                        <executions>
                                <execution>
                                        <id>attach-appassembler</id>
                                        <phase>package</phase>
                                        <goals>
                                                <goal>assemble</goal>
                                        </goals>
                                </execution>
                        </executions>
                        <configuration>
                                <platforms>
                                        <platform>unix</platform>
                                        <platform>windows</platform>
                                </platforms>
                                <binFileExtensions>
                                        <unix>.sh</unix>
                                        <windows>.cmd</windows>
                                </binFileExtensions>
                                <assembleDirectory>
${project.build.directory}/my-prg</assembleDirectory>
                                <repositoryLayout>flat</repositoryLayout>
                                <repositoryName>lib</repositoryName>
                                <includeConfigurationDirectoryInClasspath>
false</includeConfigurationDirectoryInClasspath>
                                <programs>
                                        <program>
                                                <mainClass>my.prg.MyTool</
mainClass>
                                                <name>
${project.artifactId}</name>
                                        </program>
                                </programs>
                        </configuration>
                </plugin>

                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.2.1</version><!--$NO-MVN-MAN-VER$ -->
                        <configuration>
                                <descriptors>
                                        <descriptor>src/assembly/bin.xml</
descriptor>
                                </descriptors>
                        </configuration>
                        <executions>
                                <execution>
                                        <id>create-assembly</id>
                                        <phase>package</phase>
                                        <goals>
                                                <goal>attached</goal>
                                        </goals>
                                </execution>
                        </executions>
                </plugin>
        </plugins>
</build>

So, no big magic there.

What I have seen so far is that according to the pom of batik-script which 
is referenced somewhere in the dependency tree it has a dependency to 
batik-js:

*snip*
    <dependency>
      <groupId>org.apache.xmlgraphics</groupId>
      <artifactId>batik-js</artifactId>
      <version>1.7</version>
    </dependency>
*snip*

but dependency:tree doesn't list it. Why that?


Looking at the output of "mvn -e -X package" there seems to be a 
discrepancy in the way the assembly and appassembler plugins retrieve / 
fetch the dependency tree:

(...)
[DEBUG] 
-----------------------------------------------------------------------
[DEBUG] Goal: 
org.apache.maven.plugins:maven-assembly-plugin:2.2.1:attached 
(create-assembly)
[DEBUG] Style:         Aggregating
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
(...)
[DEBUG]          org.apache.axis:axis-saaj:jar:1.4:compile
[DEBUG]          commons-logging:commons-logging:jar:1.1.1:compile
[DEBUG]          commons-validator:commons-validator:jar:1.0.2:compile
[DEBUG]             commons-beanutils:commons-beanutils:jar:1.5:compile
[DEBUG] commons-collections:commons-collections:jar:2.1:compile
[DEBUG]          commons-digester:commons-digester:jar:1.8:compile
[DEBUG]          oro:oro:jar:2.0.8:compile
[DEBUG]          commons-discovery:commons-discovery:jar:0.4:compile
[DEBUG]          wsdl4j:wsdl4j:jar:1.6.1:compile
[DEBUG]          xerces:xercesImpl:jar:2.9.1:compile
[DEBUG]          xalan:xalan:jar:2.7.1:compile
[DEBUG]             xalan:serializer:jar:2.7.1:
(...)

(yes, exactly, no "compile" at the right side of serializer. I guess that 
explains why the dependency isn't contained in the archive.)

and basically the same list printed as debug output of the appassmbler.


Do you have any idea what is causing this? I.e. why the resulting archives 
are different using Maven 2.2.1 or 3.0.3?



Regards

Thorsten


PS: I tested it with Maven 3.0.3 using Java 1.6.0_24, first on Solaris 11 
Express and then on Mac OS X 10.6.7.

Antwort: Re: Incorrect assembly created with Maven 3.0.3

Posted by Thorsten Heit <th...@vkb.de>.
Hi,

> Thorsten Heit wrote:
> > 
> > ...snip ...
> > 
> > But what puzzles me is that the archives created by Maven 2.2.1 and 
Maven
> > 3.0.3 are different, and I don't see a reason why...
> > 
> > ...snip...
> > 
> 
> Hi there,
> 
> Did you ever get anywhere with this? I'm seeing the same problem: Maven
> 3.0.3 adds batik-js-1.7.jar and omits serializer-2.7.1.jar.
> 
> Though I am not positive, I believe this is the cause of an exception I 
see
> at runtime, the stack trace of which starts like this:
> 
> java.lang.IllegalAccessError:
> org/apache/xml/serializer/ExtendedContentHandler
>    at
> org.apache.xalan.transformer.TransformerImpl.createSerializationHandler
> (TransformerImpl.java:1233)
>         ...

I get a ClassNotFoundException at runtime. I don't know exactly which 
class, but it was one from the serializer jar...

Unfortunately the only solution I have so far is to directly add a 
dependency to the serializer jar in the pom although no class in the 
project uses it - it is used transitively by xerces or xalan I guess...


Regards

Thorsten

Re: Re: Incorrect assembly created with Maven 3.0.3

Posted by Thorsten Heit <th...@vkb.de>.
Hi,

> Just a wild guess, do you have a dependencyManagament handling these
> artifacts where the scope is defined? I've seen different behavior
> between Maven 2.x and 3.0.x due to this (MJBOSSPACK-40 [1]).

No, I haven't used dependency management. I simply referenced xerces 
and/or xalan (don't remember it exactly because I changed the project in 
the meantime...)


Regards

Thorsten

Re: Incorrect assembly created with Maven 3.0.3

Posted by Anders Hammar <an...@hammar.net>.
Just a wild guess, do you have a dependencyManagament handling these
artifacts where the scope is defined? I've seen different behavior
between Maven 2.x and 3.0.x due to this (MJBOSSPACK-40 [1]).

/Anders

[1] http://jira.codehaus.org/browse/MJBOSSPACK-40

On Fri, Sep 16, 2011 at 22:43, WhiteMarlin <we...@cytoanalytics.com> wrote:
>
> Thorsten Heit wrote:
>>
>> ...snip ...
>>
>> But what puzzles me is that the archives created by Maven 2.2.1 and Maven
>> 3.0.3 are different, and I don't see a reason why...
>>
>> ...snip...
>>
>
> Hi there,
>
> Did you ever get anywhere with this? I'm seeing the same problem: Maven
> 3.0.3 adds batik-js-1.7.jar and omits serializer-2.7.1.jar.
>
> Though I am not positive, I believe this is the cause of an exception I see
> at runtime, the stack trace of which starts like this:
>
> java.lang.IllegalAccessError:
> org/apache/xml/serializer/ExtendedContentHandler
>        at
> org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1233)
>        ...
>
> Thanks!
>
>
> --
> View this message in context: http://maven.40175.n5.nabble.com/Incorrect-assembly-created-with-Maven-3-0-3-tp4393328p4811951.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Incorrect assembly created with Maven 3.0.3

Posted by WhiteMarlin <we...@cytoanalytics.com>.
Thorsten Heit wrote:
> 
> ...snip ...
> 
> But what puzzles me is that the archives created by Maven 2.2.1 and Maven
> 3.0.3 are different, and I don't see a reason why...
> 
> ...snip...
> 

Hi there,

Did you ever get anywhere with this? I'm seeing the same problem: Maven
3.0.3 adds batik-js-1.7.jar and omits serializer-2.7.1.jar.

Though I am not positive, I believe this is the cause of an exception I see
at runtime, the stack trace of which starts like this:

java.lang.IllegalAccessError:
org/apache/xml/serializer/ExtendedContentHandler
	at
org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1233)
        ...

Thanks!


--
View this message in context: http://maven.40175.n5.nabble.com/Incorrect-assembly-created-with-Maven-3-0-3-tp4393328p4811951.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Incorrect assembly created with Maven 3.0.3

Posted by Thorsten Heit <th...@gmx.de>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

>> finally got ClassNotFoundException because of a missing dependency Jar in
>> the lib folder; more precisely xalan:serializer:2.7.1
>> 
>> PS: I tested it with Maven 3.0.3 using Java 1.6.0_24, first on Solaris 11
>> Express and then on Mac OS X 10.6.7.
> 
> Xalan and Xerces are special since they have been absorbed into the
> JVM as of 1.4. In 1.5 they were basically shaded so now they are under
> com.sun.* instead of directly under org.apache.* which was causing
> problems.

Xalan and Xerces are actually included because the versions in 1.4 / 1.5 are older than those available at apache.org. As far as I know they are needed by some legacy code for (de-)serialization of objects.

I don't know if it is feasible to replace that code in short or mid term to make (better) usage of the capabilities provided directly by Java 6.


> What class specifically is giving you the CNFE?

I'm at home so I can't tell what class was causing this error. I'll see Monday when I'm at work, but I guess it was something like org/apache/xml/serializer/Serializer


> Are you building and
> then running your code with the same version etc of the JVM?

Yes.
But what puzzles me is that the archives created by Maven 2.2.1 and Maven 3.0.3 are different, and I don't see a reason why...


> This may
> be a situation where a jdk-specific profile is kicking in and
> including (or not) a dependency during your build... or something else
> of course.

I don't use any profile, and the in-house dependencies I'm using also don't make usage of profiles.


Thorsten
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)

iQIcBAEBAgAGBQJNzlPbAAoJEFpUu7h4Il4IQ+cP/0Hg0YYDc4Uu3eVTGMqPYWd9
GeKmiUNw/mZHcR56aAUG1xgCjxfvtX1Ub3SGGNn8TKF4fNMboQv+YE41Ze8ALVC7
uX1TBu8LeWO3gq3qP7McsTxZ/+aVjYqv3RigEWEs/gOv9Z+oei3hYl8/c+9sr/sq
c1TU+A6dZqjsBeEnp0/lNoGvPV6fe/Dg+GuO9XVBZsPf7f8trL16vUPmAuyFaEoy
awN0+ZneWbMi3Ye/bTw6cCqePXIJW9UasP4uN/+QuEHokNbLixyXjd5AQ9dQhOKm
Ov3Nf2xaFa99XGi8lIqiX0ds548hC/Ub8B04/5yyv2bKcyxKcuoIa9oxYb1LlyBB
PV8VOQuVhz++mjdYVe7g70NklXI4uLo7kCxnOsfd8XgFnoxUjjj646AKpbiOwzHH
ACn1DVN2ijBDfmGmfracJo7nwkdbuEKGNIqivTg87S3EzZNATErTbSlBM4Y1Fj7+
tJb0J7SUcQBxWt4jiJBqOva0/S7l+tveQGezpIrdsv4/OglTy3vLvGNL9+J+GQlm
nlBRxsFcCVJkmhViBhNjuFAx1M6+g7pEjjxETl7OaZKtWJ0lDcoxUxQ/POfC5RKS
grhykOtrW1xU4qAJCzI4OJ72Qv9z9p/ORwGy5DAFaGAvTUK8ClzzZJRwznkilcBo
kV7bX6nN+bDhTzp//8P9
=Yfmg
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Incorrect assembly created with Maven 3.0.3

Posted by Wayne Fay <wa...@gmail.com>.
> finally got ClassNotFoundException because of a missing dependency Jar in
> the lib folder; more precisely xalan:serializer:2.7.1
>
> PS: I tested it with Maven 3.0.3 using Java 1.6.0_24, first on Solaris 11
> Express and then on Mac OS X 10.6.7.

Xalan and Xerces are special since they have been absorbed into the
JVM as of 1.4. In 1.5 they were basically shaded so now they are under
com.sun.* instead of directly under org.apache.* which was causing
problems.

What class specifically is giving you the CNFE? Are you building and
then running your code with the same version etc of the JVM? This may
be a situation where a jdk-specific profile is kicking in and
including (or not) a dependency during your build... or something else
of course.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org