jhsuwm / onejar-maven-plugin

Automatically exported from code.google.com/p/onejar-maven-plugin
0 stars 0 forks source link

Duplicate jars from different dependencies throw java.util.zip.ZipException #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Find two dependencies that both depend on the same jar
2. Add them to the same project and one-jar them

What is the expected output? What do you see instead?

Expected: The second copy of the same jar would overwrite the first, or be
skipped if it's already in the one-jar

Instead:
[INFO] One-Jar file:
/Users/michaeld/Dropbox/Dev/idea/Filestore2Fedora/target/Filestore2Fedora-1.0-SN
APSHOT.one-jar.jar
[ERROR] 
java.util.zip.ZipException: duplicate entry: lib/xmlParserAPIs-2.0.2.jar
    at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:175)
    at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:92)
    at org.dstovall.OneJarMojo.addToZip(OneJarMojo.java:268)
    at org.dstovall.OneJarMojo.addToZip(OneJarMojo.java:264)
    at org.dstovall.OneJarMojo.execute(OneJarMojo.java:166)
    at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.ja
va:490)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycl
eExecutor.java:694)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(Defaul
tLifecycleExecutor.java:569)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycle
Executor.java:539)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures
(DefaultLifecycleExecutor.java:387)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultL
ifecycleExecutor.java:348)
    at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExec
utor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] One-jar Mojo failed.

What version of onejar-maven-plugin are you using?

1.4.1

What is the output of "mvn -version" on your machine?

Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)
Java version: 1.6.0_17
Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x" version: "10.6.3" arch: "x86_64" Family: "mac"

Original issue reported on code.google.com by mdellabi...@gmail.com on 13 Apr 2010 at 9:38

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi!

Can you please share an example project which exhibits this behaviour, so we 
can 
debug it?

Thanks,
Hugo

Original comment by hugo.josefson.old@gmail.com on 14 Apr 2010 at 6:25

GoogleCodeExporter commented 9 years ago
Here's a pom that provokes the problem. No need for actual project files, 
because the
dependency itself provokes it. Yes I know the dependency included is a mess, 
and that
project is working on becoming more modular, but it would be nice if the one-jar
plugin would be able to detect this type of issue. I patched a local version to 
just
catch and report exceptions from putting files in the jar instead of halting
execution, and that works for my immediate purposes:

private void addToZip(JarOutputStream out, ZipEntry entry, InputStream in) 
throws
IOException {
        try {
            out.putNextEntry(entry);
            IOUtils.copy(in, out);
            out.closeEntry();

        } catch (Exception e) {
            getLog().error("Caught exception adding " + entry, e);
        }
    }

Original comment by mdellabi...@gmail.com on 14 Apr 2010 at 4:18

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I can't reproduce the error based on the pom you attached.

The error I receive says the dependency org.fcrepo:fcrepo-client-admin:jar:3.3 
can't 
be found in any repo. (I also tried re-enabling the disabled repos in the pom.)

Please deploy org.fcrepo:fcrepo-client-admin:jar:3.3 to a repository, and give 
the 
URL to where it is hosted.

Thanks,
Hugo 

Original comment by hugo.josefson.old@gmail.com on 15 Apr 2010 at 2:59

GoogleCodeExporter commented 9 years ago
I too have the same problem:
[INFO] One-Jar file: /home/andy/workspace/SysMon2/target/SysMon-2.0.one-jar.jar
[ERROR] 
java.util.zip.ZipException: duplicate entry: lib/log4j-1.2.14.jar
    at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:192)

I am attaching the pom.xml and the dependency tree 

[INFO] |  +- org.tmatesoft:svnkit:jar:1.1.2:compile
[INFO] |  |  \- ch.ethz.ganymed:ganymed-ssh2:jar:build210:compile
*** [INFO] |  +- log4j:log4j:jar:1.2.14:compile
...
INFO] |  |  |  \- jboss:jboss-common-core:jar:2.0.2.GA:compile
*** [INFO] |  |  +- apache-log4j:log4j:jar:1.2.14:compile

$  mvn -version
Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500)
Java version: 1.7.0-ea
Java home: /opt/jdk1.7.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32.12-115.fc12.x86_64" arch: "amd64" Family: 
"unix"

Original comment by hazlorea...@gmail.com on 24 May 2010 at 4:21

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r76.

Original comment by hugo.josefson.old@gmail.com on 24 May 2010 at 6:43

GoogleCodeExporter commented 9 years ago

Original comment by hugo.josefson.old@gmail.com on 24 May 2010 at 6:48

GoogleCodeExporter commented 9 years ago
I think I have fixed it in version 1.4.2 now, so please try that version.

Thanks,
Hugo

Original comment by hugo.josefson.old@gmail.com on 24 May 2010 at 7:11

GoogleCodeExporter commented 9 years ago
Ok great it works with 1.4.2

Original comment by hazlorea...@gmail.com on 25 May 2010 at 4:45

GoogleCodeExporter commented 9 years ago
Thank you for verifying that.

Original comment by hugo.josefson.old@gmail.com on 25 May 2010 at 6:38