2010-08-30 132 views
0

我在我的應用程序中使用了Guice 2.0和它的struts插件'guice-struts2-plugin-2.0'。 struts版本是'Struts2-core-2.1.8.1,應用服務器是Jboss 4.2.2。 當部署應用程序獲得的問題是guice-struts2-plugin-2.0支持Struts 2.x嗎?

java.lang.NullPointerException : at com.google.inject.struts2.GuiceObjectFactory 
$ProvidedInterceptor.destroy(GuiceObjectFactory.java:216) 
here is my stack trace 

23:06:11,390 INFO [TomcatDeployer] deploy, ctxPath=/ 
HelloGuiceServlet, warUrl=.../tmp/deploy/tmp2295HelloGuiceServlet- 
exp.war/ 
23:06:11,390 INFO [ContainerBase] Container 
org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ 
HelloGuiceServlet].[jsp] has not been started 
23:06:11,390 INFO [ContainerBase] Container 
org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/ 
HelloGuiceServlet].[default] has not been started 
23:06:11,390 ERROR [BaseModelMBean] Exception invoking method destroy 
java.lang.NullPointerException 
     at com.google.inject.struts2.GuiceObjectFactory 
$ProvidedInterceptor.destroy(GuiceObjectFactory.java:216) 
     at org.apache.struts2.dispatcher.Dispatcher.cleanup(Dispatcher.java: 
298) 
     at 
org.apache.struts2.dispatcher.ng.PrepareOperations.cleanupDispatcher(PrepareOperations.java: 
179) 
     at 
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.destroy(StrutsPrepareAndExecuteFilter.java: 
100) 
     at 
org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java: 
332) 
     at 
org.apache.catalina.core.StandardContext.filterStop(StandardContext.java: 
3757) 
     at org.apache.catalina.core.StandardContext.stop(StandardContext.java: 
4517) 
     at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java: 
1163) 
     at 
org.apache.catalina.core.StandardContext.destroy(StandardContext.java: 
4617) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java: 
296) 
     at 
org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java: 
164) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java: 
175) 
     at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java: 
104) 
     at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java: 
375) 
     at org.jboss.web.WebModule.startModule(WebModule.java:83) 
     at org.jboss.web.WebModule.startService(WebModule.java:61) 
     at 
org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java: 
289) 
     at 
org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java: 
245) 
     at sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.system.ServiceController 
$ServiceProxy.invoke(ServiceController.java:978) 
     at $Proxy0.start(Unknown Source) 
     at org.jboss.system.ServiceController.start(ServiceController.java: 
417) 
     at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy44.start(Unknown Source) 
     at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java: 
466) 
     at sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at 
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java: 
133) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java: 
142) 
     at 
org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java: 
97) 
     at 
org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java: 
238) 
     at 
org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java: 
87) 
     at org.jboss.deployment.SubDeployerInterceptorSupport 
$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188) 
     at 
org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java: 
95) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy45.start(Unknown Source) 
     at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025) 
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819) 
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) 
     at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at 
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java: 
133) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java: 
142) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy9.deploy(Unknown Source) 
     at 
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java: 
421) 
     at 
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java: 
610) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.doScan(AbstractDeploymentScanner.java:263) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.loop(AbstractDeploymentScanner.java:274) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.run(AbstractDeploymentScanner.java:225) 
23:06:11,406 WARN [ServiceController] Problem starting service 
jboss.web.deployment:war=HelloGuiceServlet.war,id=-343052674 
org.jboss.deployment.DeploymentException: Error during deploy; - 
nested throwable: (javax.management.RuntimeOperationsException: 
Exception invoking method destroy) 
     at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java: 
384) 
     at org.jboss.web.WebModule.startModule(WebModule.java:83) 
     at org.jboss.web.WebModule.startService(WebModule.java:61) 
     at 
org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java: 
289) 
     at 
org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java: 
245) 
     at sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.system.ServiceController 
$ServiceProxy.invoke(ServiceController.java:978) 
     at $Proxy0.start(Unknown Source) 
     at org.jboss.system.ServiceController.start(ServiceController.java: 
417) 
     at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy44.start(Unknown Source) 
     at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java: 
466) 
     at sun.reflect.GeneratedMethodAccessor93.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at 
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java: 
133) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java: 
142) 
     at 
org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java: 
97) 
     at 
org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java: 
238) 
     at 
org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java: 
87) 
     at org.jboss.deployment.SubDeployerInterceptorSupport 
$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188) 
     at 
org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java: 
95) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy45.start(Unknown Source) 
     at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025) 
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819) 
     at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) 
     at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java: 
155) 
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94) 
     at 
org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java: 
133) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java: 
142) 
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) 
     at 
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java: 
264) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210) 
     at $Proxy9.deploy(Unknown Source) 
     at 
org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java: 
421) 
     at 
org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java: 
610) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.doScan(AbstractDeploymentScanner.java:263) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.loop(AbstractDeploymentScanner.java:274) 
     at org.jboss.deployment.scanner.AbstractDeploymentScanner 
$ScannerThread.run(AbstractDeploymentScanner.java:225) 
Caused by: javax.management.RuntimeOperationsException: Exception 
invoking method destroy 
     at 
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java: 
304) 
     at 
org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java: 
164) 
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java: 
659) 
     at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeployInternal(TomcatDeployer.java: 
175) 
     at 
org.jboss.web.tomcat.service.TomcatDeployer.performDeploy(TomcatDeployer.java: 
104) 
     at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java: 
375) 
     ... 65 more 
Caused by: java.lang.NullPointerException 
     at com.google.inject.struts2.GuiceObjectFactory 
$ProvidedInterceptor.destroy(GuiceObjectFactory.java:216) 
     at org.apache.struts2.dispatcher.Dispatcher.cleanup(Dispatcher.java: 
298) 
     at 
org.apache.struts2.dispatcher.ng.PrepareOperations.cleanupDispatcher(PrepareOperations.java: 
179) 
     at 
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.destroy(StrutsPrepareAndExecuteFilter.java: 
100) 
     at 
org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java: 
332) 
     at 
org.apache.catalina.core.StandardContext.filterStop(StandardContext.java: 
3757) 
     at org.apache.catalina.core.StandardContext.stop(StandardContext.java: 
4517) 
     at org.apache.catalina.core.ContainerBase.destroy(ContainerBase.java: 
1163) 
     at 
org.apache.catalina.core.StandardContext.destroy(StandardContext.java: 
4617) 
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 
     at java.lang.reflect.Method.invoke(Unknown Source) 
     at 
org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java: 
296) 
     ... 70 more 

真的是谷歌吉斯支持Struts2Integration ???是guice-struts2-plugin-2.0是struts的成熟插件?

任何幫助請。

回答

0

guice wiki頁面是struts 2.2及更高版本中使用guice的示例。看起來你正在使用struts 2.1.8.1,所以這個例子不適合你。我有同樣的問題,但能夠通過使用source code上的示例使用guice和struts < 2.2。它多一點工作,但它確實有效。

+0

謝謝科多娃回覆。我很久以前就解決了這個問題。它使用struts 2.1.8.1正常工作,我忘了添加與guice2.0一起使用的guice-servlet-2.0.jar.guice-struts2-plugin-2.0.jar。 – 2010-12-20 07:46:53