我正在开发一个应用程序,它接受XML文件,将其发送到服务器,并接收一些数据作为响应。我需要将它打包成.exe(遗留原因),为此我需要一个jar。我打算使用程序集插件将应用程序打包到一个包含所有依赖项的jar中。使用
从IDE运行时,该应用程序正常工作mvn clean package exec:java -Dexec.mainClass="cz.tomasdvorak.eetdemo.Main" -Dexec.args="C:\\eetTesting\\testtrzba.xml"
但是只要我使用mvn clean compile assembly:single
构建独立的.jar并尝试运行它
java -jar eet-demo-maven-1.0-SNAPSHOT-jar-with-dependencies.jar "C:\\eetTesting\\testtrzba.xml"
它抛出上述异常。怎么可能? Bouncycastle是我的依赖项之一的依赖项,我没有对它做任何事情,直到现在我甚至都不知道它存在。此外,应用程序的其他部分似乎工作正常,例如检查确保它没有运行错误数量的参数。也许是某种方式的Maven配置?包括pom供参考:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>cz.tomasdvorak.eetdemo.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<artifactSet>
<excludes>
<exclude>org.bouncycastle:*:*:*</exclude>
</excludes>
</artifactSet>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>cz.tomasdvorak.eetdemo.Main</Main-Class>
<Class-Path>. ./lib/bcprov-jdk16-1.46.jar</Class-Path>
</manifestEntries>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>fat</shadedClassifierName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<groupId>cz.tomasdvorak</groupId>
<artifactId>eet-demo-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.todvora</groupId>
<artifactId>eet-client</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
我该如何解决这个问题?
EDIT;完整的堆栈跟踪:
Exception in thread "main" cz.tomasdvorak.eet.client.exceptions.InvalidKeystoreException: java.io.IOException: error constructing MAC: java.lang.SecurityException: JCE cannot authenticate the provider BC
at cz.tomasdvorak.eet.client.security.ClientKey.getKeyStore(ClientKey.java:84)
at cz.tomasdvorak.eet.client.security.ClientKey.<init>(ClientKey.java:38)
at cz.tomasdvorak.eet.client.EETServiceFactory.getInstance(EETServiceFactory.java:20)
at cz.tomasdvorak.eetdemo.Main.main(Main.java:71)
Caused by: java.io.IOException: error constructing MAC: java.lang.SecurityException: JCE cannot authenticate the provider BC
at org.bouncycastle.jcajce.provider.keystore.pkcs12.PKCS12KeyStoreSpi.engineLoad(Unknown Source)
at java.security.KeyStore.load(Unknown Source)
at cz.tomasdvorak.eet.client.security.ClientKey.getKeyStore(ClientKey.java:75)
... 3 more