Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Bouncy Castle未签名项使用Maven运行依赖项的Jar时出错_Java_Maven_Jar - Fatal编程技术网

Java Bouncy Castle未签名项使用Maven运行依赖项的Jar时出错

Java Bouncy Castle未签名项使用Maven运行依赖项的Jar时出错,java,maven,jar,Java,Maven,Jar,我目前在尝试运行使用bouncy castle进行解密的可执行jar时遇到问题。使用maven,我创建了一个jar,其中包含运行时抛出的依赖项 java.util.jar.JarException: file: FileDecrypter-1.0-jar-with-dependencies.jar has unsigned entries - org/apache/commons/io/ByteOrderMark.class 当然,我研究了这个问题并发现,但我并没有创建uber jar,也没

我目前在尝试运行使用bouncy castle进行解密的可执行jar时遇到问题。使用maven,我创建了一个jar,其中包含运行时抛出的依赖项

java.util.jar.JarException: file: FileDecrypter-1.0-jar-with-dependencies.jar 
has unsigned entries - org/apache/commons/io/ByteOrderMark.class
当然,我研究了这个问题并发现,但我并没有创建uber jar,也没有使用清单文件来创建我的jar

My pom.xml:

<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>
<groupId>FileDecrypter</groupId>
<artifactId>FileDecrypter</artifactId>
<version>1.0</version>

<dependencies>
<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-vfs2</artifactId>
    <version>2.0</version>
</dependency>
<dependency>
    <groupId>commons-net</groupId>
    <artifactId>commons-net</artifactId>
    <version>3.3</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.2</version>
</dependency>
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcprov-jdk15on</artifactId>
    <version>1.48</version>
</dependency>
<dependency>
    <groupId>org.bouncycastle</groupId>
    <artifactId>bcpg-jdk15on</artifactId>
    <version>1.48</version>
</dependency>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
 <resources>
  <resource>
    <directory>src</directory>
    <excludes>
      <exclude>**/*.java</exclude>
    </excludes>
  </resource>
 </resources>

 <plugins>
  <!-- download source code in Eclipse, best practice -->
 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <version>2.9</version>
    <configuration>
        <downloadSources>true</downloadSources>
        <downloadJavadocs>false</downloadJavadocs>
    </configuration>
</plugin>

 <!-- Make this jar executable -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <excludes>
            <exclude>**/log4j.properties</exclude>
        </excludes>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <mainClass>com.mps.main.DecryptInput</mainClass>
                <classpathPrefix>dependency-jars/</classpathPrefix>
            </manifest>
        </archive>
    </configuration>
</plugin>

<!-- Copy project dependency -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.5.1</version>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <!-- exclude junit, we need runtime dependency only -->
                <includeScope>runtime</includeScope>
                <outputDirectory>${project.build.directory}/dependency-  
jars/</outputDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

<!-- set jdk compiler -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.3</version>
    <configuration>
      <verbose>true</verbose>
      <fork>true</fork>
      <executable>${JAVA_1_7_HOME}</executable>
      <compilerVersion>1.7</compilerVersion>
    </configuration>
</plugin>

 <!-- Maven Assembly Plugin -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
        <!-- get all project dependencies -->
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <!-- MainClass in mainfest make a executable jar -->
        <archive>
          <manifest>
            <mainClass>com.mps.main.DecryptInput</mainClass>
          </manifest>
        </archive>

    </configuration>
    <executions>
      <execution>
        <id>make-assembly</id>
                                  <!-- bind to the packaging phase -->
        <phase>package</phase> 
        <goals>
            <goal>single</goal>
        </goals>
      </execution>
    </executions>
</plugin>
</plugins>
</build>
</project>

4.0.0
文件解密程序
文件解密程序
1
公地io
公地io
2.4
org.apache.commons
commons-vfs2
2
公用网络
公用网络
3.3
org.apache.logging.log4j
log4japi
2.2
org.apache.logging.log4j
log4j型芯
2.2
org.bouncycastle
bcprov-jdk15on
1.48
org.bouncycastle
bcpg-jdk15on
1.48
src
src
**/*.爪哇
org.apache.maven.plugins
maven eclipse插件
2.9
真的
假的
org.apache.maven.plugins
maven jar插件
2.6
**/log4j.properties
真的
com.mps.main.input
依赖罐子/
org.apache.maven.plugins
maven依赖插件
2.5.1
复制依赖项
包裹
复制依赖项
运行时
${project.build.directory}/dependency-
罐子/
org.apache.maven.plugins
maven编译器插件
3.3
真的
真的
${JAVA_1_7_HOME}
1.7
org.apache.maven.plugins
maven汇编插件
2.4.1
带有依赖项的jar
com.mps.main.input
组装
包裹
单一的

我终于让它工作了,尽管我用错误的方式处理了这个问题。使用pom.xml中的以下代码,我能够创建一个jar,其中包含指向依赖项的清单文件:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5.1</version>
<executions>
    <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
            <goal>copy-dependencies</goal>
        </goals>
        <configuration>
            <!-- exclude junit, we need runtime dependency only -->
            <includeScope>runtime</includeScope>
            <outputDirectory>${project.build.directory}/dependency-  
jars/</outputDirectory>
        </configuration>
    </execution>
</executions>
</plugin>

org.apache.maven.plugins
maven依赖插件
2.5.1
复制依赖项
包裹
复制依赖项
运行时
${project.build.directory}/dependency-
罐子/

使用我的pom.xml并在命令行中运行“mvn package”,而我当前的工作目录是我当前的项目工作区,将创建一个名为“target”的文件夹,其中包含我的jar文件“FileDecrypter.jar”和一个包含我所有jar的文件夹“dependency jars”。我的execute jar中的manifest文件指向dependency jar文件夹,该文件夹允许我的bouncy castle jar保持签名状态。

那么,你基本上是说没有办法创建一个可运行的jar来保存bouncy castle jar?@pitchblack408我从来没有说过“基本上”,我只是简单地展示了这个解决方案对于我最初的问题是可行的。我不记得我是否能够让它在一个可运行的罐子中工作,但感谢您的回复。