XMLBeans jar can't be signed when imported from custom class
Asked Answered
D

2

6

In NetBeans I created an Exporter class that exports some data to an EXCEL file using APACHE POI, which uses XMLBeans.

I added the APACHE POI 3.10.1 libraries by downloading the zip binaries and adding the jars manually.

When I use this class inside the same project, everything runs correctly.

Then I added this class to another project, via right click Libraries -> Add Project.

But when I tried running this I got the following error while compiling.

Signing JAR: C:\Users\c\p\dist\lib\xmlbeans-2.6.0.jar to C:\Users\c\p\dist\lib\xmlbeans-2.6.0.jar as nb-jfx
jarsigner: unable to sign jar: java.util.zip.ZipException: duplicate entry:    org/apache/xmlbeans/xml/stream/Location.class
Enter Passphrase for keystore: Enter key password for nb-jfx: 
C:\Users\c\p\nbproject\jfx-impl.xml:1465: The    following error occurred while executing this line:
C:\Users\c\p\nbproject\jfx-impl.xml:2968: The following error occurred while executing this line:
C:\Users\c\p\nbproject\jfx-impl.xml:1940: jarsigner   returned: 1

I don't know what this might be about, but is driving me crazy.

Dobbins answered 15/11, 2014 at 3:44 Comment(2)
I barely remember this problem now, it was a long time ago, but I think I ended up using an older version of APACHE POI. I hope this helps.Dobbins
It still occur in newest version of POIBabettebabeuf
C
15

There's a bug opened in XMLBEANS Jira that defines this issue. https://issues.apache.org/jira/browse/XMLBEANS-499 and one of the comments reports a fix. I've not tried it yet but am in the process of doing so. Check it out.

Updated: Resolved. In hindsight the resolution is obvious but painfully unnecessary if the .jar had been properly created. Unzip (I simply changed the .jar extension to .zip and proceeded) the .jar which will remove the duplicate .class files (8 in this case) then use the jar tool to recreate the .jar file. The command is: "jar cf (path)\xmlbeans-2.6.0.jar -C (unzipped folder path) ." Don't forget the period at the end of the command. Then I copied the new xmlbeans-2.6.0.jar into my lib directory and all is now well. Hope this helps someone else! :-)

Colman answered 25/12, 2014 at 17:16 Comment(0)
V
0

If you are using maven you can try to unpack the xmlbeans dependency.

<executions>
<execution>
    <id>unpack-dependencies</id>
    <phase>package</phase>
    <goals>
        <goal>unpack</goal>
    </goals>
    <configuration>
        <artifactItems>
            <artifactItem>
                <groupId>org.apache.xmlbeans</groupId>
                <artifactId>xmlbeans</artifactId>
                <version>2.6.0</version>
                <type>jar</type>
                <overWrite>true</overWrite>
                <outputDirectory>${project.build.directory}/classes</outputDirectory>
                <excludes>**/*test.class</excludes>
            </artifactItem>
        </artifactItems>
    </configuration>
</execution>
</executions>
Verse answered 27/4, 2017 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.