NutzCN Logo
问答 诡异的java.lang.NoClassDefFoundError错误,求解
发布于 3154天前 作者 邓华锋 5458 次浏览 复制 上一个帖子 下一个帖子
标签:

RunningLog类是正常的bean,相关的注解也加了,它的serverType是Integer类型,在本地运行没问题,部署到服务器上后,第一次能正常查询,第二次直接报以下错误了。说明点:我是通过传serverType来切换数据源,通过serverType来获取不同的dao,非MVC和MVC环境下 IOC容器的获取我已经做了处理。 本地和服务器的运行环境:tomcat 8 JDK 1.8 nutz 1.56。我查了tomcat下对应位置的RunningLog class 确实存在呀,居然报以下错误,诡异,求解!

2016-05-02 15:59:32,396 [DEBUG] ao.impl.sql.run.NutDaoExecutor - SELECT COUNT(*) FROM running_log
2016-05-02 15:59:32,496 [WARN ] c.impl.processor.FailProcessor - Error@/runlog :
java.lang.NoClassDefFoundError: com/denghuafeng/entity/RunningLog
at com.denghuafeng.entity.RunningLog_serverType.value(Unknown Source)
at org.beetl.core.statement.VarAttribute.evaluate(VarAttribute.java:61)
at org.beetl.core.statement.VarRef.evaluate(VarRef.java:127)
at org.beetl.core.statement.PlaceholderST.execute(PlaceholderST.java:32)
at org.beetl.core.statement.BlockStatement.execute(BlockStatement.java:68)
at org.beetl.core.statement.GeneralForStatement.execute(GeneralForStatement.java:99)
at org.beetl.core.statement.Program.execute(Program.java:70)
at org.beetl.core.Template.renderTo(Template.java:137)
at org.beetl.core.Template.renderTo(Template.java:90)
at org.beetl.ext.web.WebRender.render(WebRender.java:117)
at org.nutz.plugins.view.BeetlView.render(BeetlView.java:47)
at org.nutz.plugins.view.ResourceBundleViewResolver$1.render(ResourceBundleViewResolver.java:146)
at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:60)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:28)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:33)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:118)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:196)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1096)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:760)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1480)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

15 回复

是标准的war结构吗?有没有把jar放在tomcat lib下之类的操作?

所有的jar包 我都放在公共的lib目录下,并且配置告知tomcat 此公共lib包在哪。现在发布,我一般是手动导出项目为war包,之后解压出来把WEB-INF/lib目录删除,再上传到服务器tomcat下运行。

也许这就是问题,先放回去测试一下

打包出来的class相关的代码都正常放在tomcat下,就lib目录分离出来,既nutz.jar在公共的lib目录下,nutz加载实体的目录出错?!

我先试试把nutz.jar放回项目的WEB-INF/lib下

把nutz.jar单独返回WEB-INF/lib下 报以下错误了,项目没法运行了:
2016-05-02 17:39:17,438 [DEBUG] org.nutz.resource.Scans - Locations for Scans:
[JarResourceLocation [jarPath=/usr/local/tomcat8/bin/bootstrap.jar], JarResourceLocation [jarPath=/webapps/dhfTest/ROOT/WEB-INF/lib/nutz.jar], JarResourceLocation [jarPath=/usr/local/tomcat8/bin/tomcat-juli.jar], FileSystemResourceLocation [root=/usr/local/tomcat8/bin], FileSystemResourceLocation [root=/webapps/dhfTest/ROOT/WEB-INF/classes]]
2016-05-02 17:39:17,448 [DEBUG] z.mvc.config.AbstractNutConfig - MainModule: <com.qianlima.MainModule>
02-May-2016 17:39:17.492 SEVERE [test.denghuafeng.com-startStop-1] org.apache.catalina.core.StandardContext.filterStart Exception starting filter dhfTest
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
at java.lang.Class.createAnnotationData(Class.java:3521)
at java.lang.Class.annotationData(Class.java:3510)
at java.lang.Class.getAnnotation(Class.java:3415)
at org.nutz.mvc.config.AbstractNutConfig.createLoading(AbstractNutConfig.java:56)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:18)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:105)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4577)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5220)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1107)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1841)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

02-May-2016 17:39:17.498 SEVERE [test.denghuafeng.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log file
02-May-2016 17:39:17.499 SEVERE [monitor.spd.qianlima.com-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [] startup failed due to previous errors
02-May-2016 17:39:17.520 INFO [monitor.spd.qianlima.com-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /webapps/dhfTest/ROOT has finished in 3,603 ms

试下了下把全部关联jar包放回项目的WEB-INF/lib 运行没问题

多次查询也没出现以上空指针异常了。有没有别的办法,让nutz.jar放在公共的lib下也能正常运行,不会出现以上错误。能实现吗?!

出现以上诡异异常的原因,然道是因为nutz的获取实体的classpath出现问题?!

@denghuafeng
排除法

1.把nutz放回去,其他留着
2.把其他放回去,nutz留着

得判断是nutz的原因,还是beetl的原因,还是其他jar导致的原因

@denghuafeng beetl哪个版本的问题?

@wendal
问题解决了,问了beetl的作者@闲.大赋 ,他说groupTemplate提供了setClassLoader方法。
我就设置代码如下代码:

groupTemplate.setClassLoader(sc.getClassLoader());

其中的sc为ServletContext

beetl版本我也用错了,用的是org.beetl的,此版本groupTemplate不支持访问setClassLoader方法,换成新的com.beetl版本的就成了。
现在jar包都放在公共lib目录也没问题了。之后我会更新 nutz-plugins-multiview多视图插件,修复此问题。

添加回复
请先登陆
回到顶部