java.lang.NoClassDefFoundError:com/sun/tools/corba/se/idl/InvalidArgument
我已经为ApacheStorm拓扑创建了一个胖jar,它包含所有依赖项。我使用了java.lang.NoClassDefFoundError:com/sun/tools/corba/se/idl/InvalidArgument,java,maven,apache-storm,Java,Maven,Apache Storm,我已经为ApacheStorm拓扑创建了一个胖jar,它包含所有依赖项。我使用了mvn clean-dependency:copy-dependencies-package命令来创建这个jar。当我将此jar提交给Storm时,会出现以下错误: Caused by: java.lang.ClassNotFoundException: com.sun.tools.corba.se.idl.InvalidArgument at java.net.URLClassLoader$1.ru
mvn clean-dependency:copy-dependencies-package
命令来创建这个jar。当我将此jar提交给Storm时,会出现以下错误:
Caused by: java.lang.ClassNotFoundException: com.sun.tools.corba.se.idl.InvalidArgument
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
我想知道如何解决这个错误?哪个jar文件包含这个类
编辑:添加pom.xml的依赖项部分
<dependencies>
<dependency>
<groupId>com.ads.iot</groupId>
<artifactId>commons-for-iot</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-kafka</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-hbase</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.10.0-beta1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
com.ads.iot
物联网共用空间
0.0.1-快照
org.apache.storm
卡夫卡风暴
0.10.0-beta1
org.apache.storm
风暴hbase
0.10.0-beta1
org.apache.storm
风暴核心
0.10.0-beta1
假如
jdk.tools
jdk.tools
1.7.0_21
系统
${JAVA_HOME}/lib/tools.jar
编辑2:pom.xml的插件部分
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<includeProjectDependencies>true</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<classpathScope>compile</classpathScope>
<mainClass>${main.class}</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.ats.ift.KafkaStormTopologyBuilder</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
org.codehaus.mojo
execmaven插件
1.4.0
执行官
JAVA
真的
假的
编译
${main.class}
maven汇编插件
带有依赖项的jar
com.ats.ift.kafkastromTopologyBuilder
组装
包裹
单一的
您要将Java部署到哪个版本?浏览您的依赖项,我在JDK1.7的tools.jar
中找到了com/sun/tools/corba/se/idl/InvalidArgument.class
。但是在JDK1.8中没有这样的库。事实上,1.8的一个变化是从com.sun
包中删除旧的非公共API
这里恐怕需要升级您的代码(到当前的公共API)。您要部署到哪个版本的Java?浏览您的依赖项,我在JDK1.7的
tools.jar
中找到了com/sun/tools/corba/se/idl/InvalidArgument.class
。但是在JDK1.8中没有这样的库。事实上,1.8的一个变化是从com.sun
包中删除旧的非公共API
这里恐怕需要升级您的代码(到当前的公共API)。您需要将类似的内容添加到
pom.xml
<dependencies>
<dependency>
<groupId>com.ads.iot</groupId>
<artifactId>commons-for-iot</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-kafka</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-hbase</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.10.0-beta1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
),因为maven依赖插件
会在那里查找jar文件。您需要在pom.xml中添加类似的内容
<dependencies>
<dependency>
<groupId>com.ads.iot</groupId>
<artifactId>commons-for-iot</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-kafka</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-hbase</artifactId>
<version>0.10.0-beta1</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.10.0-beta1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<scope>system</scope>
<systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
</dependencies>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version><!--$NO-MVN-MAN-VER$-->
<executions>
<execution>
<id>unpack</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>jdk.tools</groupId>
<artifactId>jdk.tools</artifactId>
<version>1.7.0_21</version>
<type>jar</type>
<overWrite>false</overWrite>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
org.apache.maven.plugins
),因为maven dependency plugin
在那里查找jar文件。问题中添加了Dependencies部分。jar是在我的笔记本电脑和集群中创建的。您是否检查了jar中是否包含该文件(unzip-l jarname.jar | grep InvalidArgument
)如何构建jar?使用maven jar插件
?对于这种情况,您需要使用maven dependency plugin
将依赖的jar提取到本地target
文件夹中。当我执行(解压-l storm-For-ift-0.0.1-SNAPSHOT-jar-with-dependencies.jar | grep InvalidArgument | more
)命令时,没有显示任何输出。我已经添加了插件和命令,用于构建有问题的jar本身。如果没有显示输出,则该类不包含,也就是说,您的jar包不正确(正如我假设的那样)。请参阅我的答案如何正确打包。问题中添加了依赖项部分。Jar会在我的笔记本电脑和集群中创建。您是否检查了Jar中是否包含该文件(unzip-l jarname.Jar | grep InvalidArgument
)如何构建Jar?使用maven jar插件
?对于这种情况,您需要使用maven dependency plugin
将依赖的jar提取到本地target
文件夹中。当我执行(解压-l storm-For-ift-0.0.1-SNAPSHOT-jar-with-dependencies.jar | grep InvalidArgument | more
)命令时,没有显示任何输出。我已经添加了插件和命令,用于构建有问题的jar本身。如果没有显示输出,则该类不包含,也就是说,您的jar包不正确(正如我假设的那样)。请参阅我的答案如何正确打包。在这种情况下,请确保部署环境的类路径中包含tools.jar
。在这种情况下,请确保部署环境的类路径中包含tools.jar
。您是否检查了jar是否包含缺少的文件?您是否在target/classes/…
中检查是否找到丢失的文件?也许您需要将tools.jar
安装到maven存储库中:看起来问题已经解决了。我使用mvn install命令将tools.jar文件从$JAVA_HOME/lib目录安装到~/.m2/repository目录,之后这个错误得到了解决。非常感谢您的帮助。您是否检查过jar是否包含丢失的文件?您是否在target/classes/…
中检查是否找到丢失的文件?也许您需要将tools.jar
安装到maven存储库中:看起来问题已经解决了。我使用mvn install命令将tools.jar文件从$JAVA_HOME/lib目录安装到~/.m2/repository目录,之后这个错误得到了解决。谢谢