我使用IntelliJ idea Ultimate 2018.2,我正常运行我的maven javafx桌面应用程序,但是当我编译jar(带有ant)以用于生产时,我会在仪器部分得到这个信息:
java.lang.NoClassDefFoundError: jdk/internal/reflect/ConstructorAccessorImpl
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at jdk.internal.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.Main.start(Main.java:198)
at org.apache.tools.ant.Main.main(Main.java:286)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:30)
Caused by: java.lang.NoClassDefFoundError: jdk/internal/reflect/ConstructorAccessorImpl
at java.base/jdk.internal.misc.Unsafe.defineClass0(Native Method)
at java.base/jdk.internal.misc.Unsafe.defineClass(Unsafe.java:1192)
at java.base/jdk.internal.reflect.ClassDefiner.defineClass(ClassDefiner.java:63)
at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:400)
at java.base/jdk.internal.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:394)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/jdk.internal.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:393)
at java.base/jdk.internal.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:92)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:55)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1015)
at java.base/java.lang.reflect.Proxy.newProxyInstance(Proxy.java:1001)
at javassist.bytecode.annotation.AnnotationImpl.make(AnnotationImpl.java:72)
at javassist.bytecode.annotation.Annotation.toAnnotationType(Annotation.java:295)
at javassist.CtClassType.toAnnoType(CtClassType.java:675)
at javassist.CtClassType.toAnnotationType(CtClassType.java:580)
at javassist.CtClassType.getAnnotations(CtClassType.java:546)
at javassist.CtClassType.getAnnotations(CtClassType.java:526)
at org.javalite.instrumentation.Instrumentation.getDatabaseName(Instrumentation.java:89)
at org.javalite.instrumentation.Instrumentation.generateModelsFile(Instrumentation.java:83)
at org.javalite.instrumentation.Instrumentation.instrument(Instrumentation.java:66)
at org.javalite.instrumentation.Main.main(Main.java:29)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
... 25 more
Caused by: java.lang.ClassNotFoundException: jdk.internal.reflect.ConstructorAccessorImpl
at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1374)
at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1323)
at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1082)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 54 more
这是我对ANT的检测
<java classname="org.javalite.instrumentation.Main">
<sysproperty key="outputDirectory" value="${ventas.output.dir}"/>
<classpath refid="ventas.module.classpath"/>
</java>
它停止检测,但是我直接在JAR上复制了检测的类。 当我尝试运行JAR时,我得到了:
Exception in Application start method
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at java.base/sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: org.javalite.activejdbc.InitException: java.lang.NullPointerException
at org.javalite.activejdbc.Registry.init(Registry.java:154)
at org.javalite.activejdbc.Registry.getMetaModel(Registry.java:103)
at org.javalite.activejdbc.ModelDelegate.metaModelOf(ModelDelegate.java:307)
at org.javalite.activejdbc.ModelDelegate.findFirst(ModelDelegate.java:243)
at modelos.Funcionario.findFirst(Funcionario.java:2444)
at utils.Pantallas.login(Pantallas.java:632)
at UI.Main.start(Main.java:21)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(Unknown Source)
... 1 more
Caused by: java.lang.NullPointerException
at org.javalite.activejdbc.Registry.processOverridesBelongsTo(Registry.java:379)
at org.javalite.activejdbc.Registry.processOverrides(Registry.java:264)
at org.javalite.activejdbc.Registry.init(Registry.java:145)
... 15 more
Exception running application UI.Main
我使用Java 10,尝试过Java 9,但同样,Java 8与其他项目库不兼容。使用activeJDBC 2.2
有人可以告诉我我做错了什么或者我应该怎么做才能执行JAR?
答案 0 :(得分:0)
首先,您需要发布ventas.module.classpath
的内容。其次,ActiveJDBC v 2.2 supports Java version 8。
如果由于其他原因而无法降级到Java 8,则至少需要通过删除其他依赖项来进行尝试,然后尝试在Java 8上复制此问题。ActiveJDBC确实会在Java 9上非正式运行,因此,也许您还有另一个与您如何课堂教学有关的问题。
此外,如果您在项目中使用Maven,为什么不同时使用它进行检测呢?参见:http://javalite.io/instrumentation#maven-instrumentation-plugin
此外,您说的是“ 停止检测”-尚不清楚是完成检测还是在中间停止?手动构建jar文件时,请不要忘记包含在检测过程中生成的文件activejdbc_models.properties
。