chunjun
chunjun copied to clipboard
[Question][ClassNotFoundException] 打包完成之后提交作业时报错ClassNotFoundException
Search before asking
-
[X] I had searched in the issues and found no similar question.
-
[X] I had googled my question but i didn't get any help.
-
[X] I had read the documentation: ChunJun doc but it didn't help me.
Description
打完包直接运行示例 json
sh bin/chunjun-local.sh -job chunjun-examples/json/stream/stream.json
报错
Exception in thread "main" java.lang.NoClassDefFoundError: com/dtstack/chunjun/throwable/ChunJunRuntimeException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:669)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:651)
Caused by: java.lang.ClassNotFoundException: com.dtstack.chunjun.throwable.ChunJunRuntimeException
at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 19 more
在 chunjun-core.jar
里面的 com.dtstack.chunjun.throwable
是可以找到 ChunJunRuntimeException.class
文件的
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
我也是,解决了吗?
@cs3163077 @itsix
chunjun_client pom
增加:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.dtstack.chunjun.client.Launcher</mainClass>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
chunjun_core pom 修改
<target>
<copy file="${basedir}/target/${project.artifactId}-${project.version}.jar"
tofile="${basedir}/target/${project.artifactId}.jar"/>
<copy todir="${basedir}/../core/"
file="${basedir}/target/${project.artifactId}.jar"/>
<delete>
<fileset dir="${basedir}/../core"
includes="${project.artifactId}-*.jar"
excludes="${project.artifactId}.jar"/>
</delete>
</target>
试试