nutzam / nutz

Nutz -- Web Framework(Mvc/Ioc/Aop/Dao/Json) for ALL Java developer
https://nutzam.com
Apache License 2.0
2.53k stars 942 forks source link

1.b.52 直接升级到 1.r.56 控制台报NullPointerException,请问需要怎么调整才能适应此次升级呢? #1066

Closed wqmain closed 8 years ago

wqmain commented 8 years ago

以下是MainModule代码,MainSetup都没进去呀,Nutz初始化时就报异常了: @Ok("json") @Fail("json") @Views({ExportMaker.class}) @Modules(scanPackage = true) @IocBy(type = ComboIocProvider.class, args = { "_org.nutz.ioc.loader.json.JsonLoader", "ioc/", "_org.nutz.ioc.loader.annotation.AnnotationIocLoader", "org.rings.framework" }) @Filters({ @By(type=WordFilter.class, args={"/(exp|imp)/"}), @By(type=LoginAdminFilter.class, args={"^/(exp|imp|code)/", Constant.SYS_USER, "/admin/login/"}) }) @SetupBy(value = MainSetup.class) public class MainModule { }

以下是Tomcat启动时报的异常:

2016-06-07 10:43:31 INFO [NutIoc] - NutIoc init begin ... 2016-06-07 10:43:31 INFO [NutIoc] - ... NutIoc init complete 2016-06-07 10:43:31 INFO [NutLoading] - Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ... 2016-06-07 10:43:48 INFO [NutActionChainMaker] - Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor 2016-06-07 10:45:10 INFO [NutActionChainMaker] - Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor 2016-06-07 10:46:31 ERROR [NutLoading] - Error happend during start serivce! java.lang.NullPointerException at org.nutz.mvc.adaptor.injector.NameInjector.(NameInjector.java:35) at org.nutz.mvc.adaptor.injector.ArrayInjector.(ArrayInjector.java:24) at org.nutz.mvc.adaptor.AbstractAdaptor.paramNameInject(AbstractAdaptor.java:312) at org.nutz.mvc.adaptor.AbstractAdaptor.init(AbstractAdaptor.java:136) at org.nutz.mvc.impl.processor.AdaptorProcessor.evalHttpAdaptor(AdaptorProcessor.java:40) at org.nutz.mvc.impl.processor.AdaptorProcessor.init(AdaptorProcessor.java:23) at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38) at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:47) at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:203) at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:107) at org.nutz.mvc.ActionHandler.(ActionHandler.java:19) at org.nutz.mvc.NutFilter._init(NutFilter.java:87) at org.nutz.mvc.NutFilter.init(NutFilter.java:65) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:298) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:119) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4102) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4760) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:803) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:780) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1080) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1003) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1069) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 2016-06-07 10:46:31 ERROR [NutLoading] - try to depose ioc 2016-06-07 10:46:31 INFO [NutIoc] - org.nutz.ioc.impl.NutIoc@1678177258 is closing. startup date [16-06-07 10:43:31.392] 2016-06-07 10:46:31 INFO [NutIoc] - org.nutz.ioc.impl.NutIoc@1678177258 is deposed. startup date [16-06-07 10:43:31.392] 2016-6-7 10:46:31 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filter nutz org.nutz.mvc.LoadingException: java.lang.NullPointerException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17) at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60) at org.nutz.lang.Mirror.born(Mirror.java:990) at org.nutz.lang.Lang.wrapThrow(Lang.java:169) at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:134) at org.nutz.mvc.ActionHandler.(ActionHandler.java:19) at org.nutz.mvc.NutFilter._init(NutFilter.java:87) at org.nutz.mvc.NutFilter.init(NutFilter.java:65) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:298) at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:119) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4102) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4760) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:803) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:780) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1080) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1003) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1069) at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.lang.NullPointerException at org.nutz.mvc.adaptor.injector.NameInjector.(NameInjector.java:35) at org.nutz.mvc.adaptor.injector.ArrayInjector.(ArrayInjector.java:24) at org.nutz.mvc.adaptor.AbstractAdaptor.paramNameInject(AbstractAdaptor.java:312) at org.nutz.mvc.adaptor.AbstractAdaptor.init(AbstractAdaptor.java:136) at org.nutz.mvc.impl.processor.AdaptorProcessor.evalHttpAdaptor(AdaptorProcessor.java:40) at org.nutz.mvc.impl.processor.AdaptorProcessor.init(AdaptorProcessor.java:23) at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38) at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:47) at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:203) at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:107) ... 29 more 2016-6-7 10:46:31 org.apache.catalina.core.StandardContext start 严重: Error filterStart 2016-6-7 10:46:31 org.apache.catalina.core.StandardContext start 严重: Context [/lightfw] startup failed due to previous errors 2016-6-7 10:46:31 org.apache.coyote.http11.Http11AprProtocol start 信息: Starting Coyote HTTP/1.1 on http-8081 2016-6-7 10:46:31 org.apache.coyote.ajp.AjpAprProtocol start 信息: Starting Coyote AJP/1.3 on ajp-829 2016-6-7 10:46:31 org.apache.catalina.startup.Catalina start 信息: Server startup in 181314 ms

wendal commented 8 years ago

把日志设置为debug, 然后找出具体的入口方法(应该是某个带数组参数的方法),贴一下

wqmain commented 8 years ago

日志调整为debug后,看到有个Eval FAIL,是HttpServletRequest 等参数解析失败么?

2016-06-07 11:01:22 DEBUG [Loadings] - >> add 'org.rings.framework.system.action.UserAction' 2016-06-07 11:01:22 DEBUG [Loadings] - >> add 'org.rings.framework.upload.action.AttachUploadAction' 2016-06-07 11:01:22 DEBUG [Loadings] - >> add 'org.rings.framework.upload.action.HeadUploadAction' 2016-06-07 11:01:26 INFO [NutActionChainMaker] - Optional processor class not found, disabled : org.nutz.integration.shiro.NutShiroProcessor 2016-06-07 11:01:26 INFO [NutActionChainMaker] - Optional processor class not found, disabled : org.nutz.plugins.validation.ValidationProcessor 2016-06-07 11:01:26 DEBUG [UrlMappingImpl] - '/admin/system/user/list' >> UserAction.list(...) : void | @Ok(jsp:/WEB-INF/admin/system/user-list.jsp) @Fail(json ) | by 3 Filters | (I:UTF-8/O:UTF-8) 2016-06-07 11:01:26 DEBUG [UrlMappingImpl] - '/admin/system/user/save' >> UserAction.save(...) : Object | @Ok(json ) @Fail(json ) | by 3 Filters | (I:UTF-8/O:UTF-8) 2016-06-07 11:01:26 DEBUG [UrlMappingImpl] - '/admin/system/user/enable/?/?' >> UserAction.enable(...) : Object | @Ok(json ) @Fail(json ) | by 3 Filters | (I:UTF-8/O:UTF-8) 2016-06-07 11:01:26 DEBUG [NutActionChainMaker] - Eval FAIL!! : public java.lang.Object org.rings.framework.system.action.UserAction.deleteAll(javax.servlet.http.HttpServletRequest,java.lang.String[],java.lang.String) java.lang.NullPointerException at org.nutz.mvc.adaptor.injector.NameInjector.(NameInjector.java:35) at org.nutz.mvc.adaptor.injector.ArrayInjector.(ArrayInjector.java:24)

wqmain commented 8 years ago

方法声明如下:

@At("/del") public Object deleteAll(HttpServletRequest req, String[] uids, String tid) { ...... }

wendal commented 8 years ago

改成

public Object deleteAll(HttpServletRequest req, @Param("uids")String[] uids, String tid) {}

我翻了代码,是bug,得查查为何以前的版本不报错

wqmain commented 8 years ago

这个改动地方太多了,那等你fix掉我再升级哈。 另外,看nutz的文档和你之前回复别人的issue,提到过exclipse的ecj编译方式,说明下我本机IDE的配置一直都没改过,需要我配合测试的话叫我一声就好。 主:我工程没用Maven

wendal commented 8 years ago

已fix, 待会可以下载快照, 或自行编译一下

wqmain commented 8 years ago

能告诉我改了哪个类,改了哪里么? 学习下!!!

wendal commented 8 years ago

10690f28f4f006e90649e4f98a1c9381337dbe05 你点进去就能看到了, AbstractAdaptor的314行