java.lang.NoClassDefFoundError: com/sun/tools/corba/se/idl/InvalidArgument
java.lang.NoClassDefFoundError: com/sun/tools/corba/se/idl/InvalidArgument
我为 Apache Storm
拓扑创建了一个包含所有依赖项的 fat 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.run(URLClassLoader.java:366)
at java.net.URLClassLoader.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 文件包含这个 class?
编辑:添加 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>
编辑 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>
您要部署到哪个 Java 版本?浏览您的依赖项,我在 JDK1.7 的 tools.jar
中找到 com/sun/tools/corba/se/idl/InvalidArgument.class
。但是在JDK1.8中并没有这样的库。事实上,1.8 的其中一项更改是从 com.sun
包中删除旧的非 public API。
恐怕这里需要升级您的代码(到当前的 public API)。
您需要将类似的内容添加到您的 pom.xml
<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>
它将依赖的 jar 复制并提取到 target/classes
,这是文件夹 maven-jar-plugin
期望所有 类 它必须打包的文件夹。这应该适用于 mvn clean package
.
更新
在您的情况下,需要先将 tools.jar
安装到 Maven 存储库 (https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html),因为 maven-dependency-plugin
在那里寻找 jar 文件。
我为 Apache Storm
拓扑创建了一个包含所有依赖项的 fat 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.run(URLClassLoader.java:366)
at java.net.URLClassLoader.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 文件包含这个 class?
编辑:添加 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>
编辑 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>
您要部署到哪个 Java 版本?浏览您的依赖项,我在 JDK1.7 的 tools.jar
中找到 com/sun/tools/corba/se/idl/InvalidArgument.class
。但是在JDK1.8中并没有这样的库。事实上,1.8 的其中一项更改是从 com.sun
包中删除旧的非 public API。
恐怕这里需要升级您的代码(到当前的 public API)。
您需要将类似的内容添加到您的 pom.xml
<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>
它将依赖的 jar 复制并提取到 target/classes
,这是文件夹 maven-jar-plugin
期望所有 类 它必须打包的文件夹。这应该适用于 mvn clean package
.
更新
在您的情况下,需要先将 tools.jar
安装到 Maven 存储库 (https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html),因为 maven-dependency-plugin
在那里寻找 jar 文件。