idea手动编译jfinal项目报错:java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor10 ca

使用idea第三天,导入jfinal项目教程在这里:idea导入jfinal官方项目
,现在说一个问题,当使用idea开发的时候,idea是不会自动编译的,这点就浪费了jfinal的热部署,所以手动来吧,ctrl+F9,快捷键进行编译,然后就报错了;

java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor10 cannot access its superclass sun.reflect.ConstructorAccessorImpl
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
    at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
    at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072)
    at java.lang.Class.getAnnotation(Class.java:3029)
    at com.sxjlrj.plugin.route.MyRoutesUtil.add(MyRoutesUtil.java:18)
    at com.sxjlrj.config.Config.configRoute(Config.java:80)
    at com.jfinal.core.Config.configJFinal(Config.java:48)
    at com.jfinal.core.JFinal.init(JFinal.java:62)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
    at com.jfinal.server.Scanner.compare(Scanner.java:88)
    at com.jfinal.server.Scanner.working(Scanner.java:57)
    at com.jfinal.server.Scanner.access$0(Scanner.java:55)
    at com.jfinal.server.Scanner$1.run(Scanner.java:94)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
2017-09-08 15:35:01.976:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.w.WebAppContext{/,file:/D:/work/Project/CompanyFile/XYXT/04Source/01SourceCode/XYXT/WebContent/}: java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor10 cannot access its superclass sun.reflect.ConstructorAccessorImpl
java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor10 cannot access its superclass sun.reflect.ConstructorAccessorImpl
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
    at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
    at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072)
    at java.lang.Class.getAnnotation(Class.java:3029)
    at com.sxjlrj.plugin.route.MyRoutesUtil.add(MyRoutesUtil.java:18)
    at com.sxjlrj.config.Config.configRoute(Config.java:80)
    at com.jfinal.core.Config.configJFinal(Config.java:48)
    at com.jfinal.core.JFinal.init(JFinal.java:62)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
    at com.jfinal.server.Scanner.compare(Scanner.java:88)
    at com.jfinal.server.Scanner.working(Scanner.java:57)
    at com.jfinal.server.Scanner.access$0(Scanner.java:55)
    at com.jfinal.server.Scanner$1.run(Scanner.java:94)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)
Exception in thread "JFinal-Scanner" java.lang.IllegalAccessError: class sun.reflect.GeneratedConstructorAccessor10 cannot access its superclass sun.reflect.ConstructorAccessorImpl
    at sun.misc.Unsafe.defineClass(Native Method)
    at sun.reflect.ClassDefiner.defineClass(ClassDefiner.java:45)
    at sun.reflect.MethodAccessorGenerator$1.run(MethodAccessorGenerator.java:381)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.reflect.MethodAccessorGenerator.generate(MethodAccessorGenerator.java:377)
    at sun.reflect.MethodAccessorGenerator.generateConstructor(MethodAccessorGenerator.java:76)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:30)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:588)
    at sun.reflect.annotation.AnnotationParser.annotationForMap(AnnotationParser.java:239)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation(AnnotationParser.java:229)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:69)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:52)
    at java.lang.Class.initAnnotationsIfNecessary(Class.java:3072)
    at java.lang.Class.getAnnotation(Class.java:3029)
    at com.sxjlrj.plugin.route.MyRoutesUtil.add(MyRoutesUtil.java:18)
    at com.sxjlrj.config.Config.configRoute(Config.java:80)
    at com.jfinal.core.Config.configJFinal(Config.java:48)
    at com.jfinal.core.JFinal.init(JFinal.java:62)
    at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
    at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
    at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
    at com.jfinal.server.Scanner.compare(Scanner.java:88)
    at com.jfinal.server.Scanner.working(Scanner.java:57)
    at com.jfinal.server.Scanner.access$0(Scanner.java:55)
    at com.jfinal.server.Scanner$1.run(Scanner.java:94)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)

解决方案:

JFinal.start("WebContent", 89, "/");

eclipse中是这样写的:

JFinal.start("WebContent", 8080, "/",5);

用idea启动时,需要去掉最后一个参数,这点config中有讲到。
因为 IDEA 启动时无法切换成 jfinal 自定义的 classloader
可以看看jfinal的官方说明:jfinal官网重点内容

你可能感兴趣的:(java,idea)