You are not allowed to sign the XMLBeans jar when importing from a custom class

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

I added APACHE POI 3.10.1 libraries by downloading zip files and adding banks manually.

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

Then I added this class to another project by right-clicking Libraries β†’ Add Project.

But when I tried to run this, during compilation I got the following error.

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 it can be, but it drives me crazy.

+5
source share
2 answers

An error has been detected in XMLBEANS Jira that identifies this issue. https://issues.apache.org/jira/browse/XMLBEANS-499 , and one of the comments reports a fix. I have not tried it yet, but I am in the process of doing this. Check this.

Updated: Solved. Looking back, the resolution is obvious, but painfully unnecessary if the .jar was correctly created. Unzip (I just changed the .jar extension to .zip and continued) .jar, which will remove duplicate .class files (in this case 8), then use the jar tool to recreate the .jar file. Command: "jar cf (path) \ xmlbeans-2.6.0.jar -C (unpacked folder path)". Do not forget about the period at the end of the team. Then I copied the new xmlbeans-2.6.0.jar to the lib directory, and now everything is fine. Hope this helps someone else !:-)

+13
source

If you are using maven, you can try unpacking 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> 
0
source

Source: https://habr.com/ru/post/1206930/


All Articles