-1

请解决这个问题。我是struts2的新手。我正在使用hibernate 3.1。提前谢谢

SEVERE: Exception starting filter struts2
Class: com.opensymphony.xwork2.spring.SpringObjectFactory
File: SpringObjectFactory.java
Method: getClassInstance
Line: 209 - com/opensymphony/xwork2/spring/SpringObjectFactory.java:209:-1
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:190)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:516)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
    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:288)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NullPointerException
    at com.opensymphony.xwork2.spring.SpringObjectFactory.getClassInstance(SpringObjectFactory.java:209)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.verifyResultType(XmlConfigurationProvider.java:519)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:490)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:446)
    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:264)
    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:111)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:193)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
    ... 28 more
Apr 12, 2012 11:48:51 AM org.apache.catalina.core.StandardContext start
SEVERE: Error filterStart
Apr 12, 2012 11:48:51 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/Struts2Hibernat] startup failed due to previous errors
4

1 回答 1

1

Umesh Awasthi 是对的。您需要提供更多信息才能解决此问题。如果你使用 spring 来创建你的动作,这就是你需要做的。

  1. 确保你的类路径中有 struts2-spring-plugin。
  2. 使用 Spring 的 @Component 注释您的操作类。例如@Component("myActionName") 或使用 java.inject.Named (JSR330) @Named。例如@Named("myActionName")。
  3. 您还需要对 struts.xml 进行另一项更改。将以下内容添加到它

  4. 接下来在您的操作元素中,而不是在类属性中引用您的操作类的完整类路径,使用传递给@Named 或@Component 的值。例如 class="myActionName"

希望这可以帮助。如果您需要更多解释,请与我联系。

于 2012-04-13T11:18:52.777 回答