Cannot locate the chosen ObjectFactory implementation: spring

今天又遇到这个问题 ,记得 2年前 自己搭建框架 就出现这个问题,当时自己没有弄出来,就找了项目经理,项目经理桌子上放了一杯水 ,我拿着笔记本去了 ,他挪杯子给我腾地方 放笔记本,杯子的水全洒在笔记本键盘上,我立刻卸了电池,然后 电脑吹了好久,开机后 竟然好了,今天又遇到了!我是 重启好多次 ,也没辙!

还是记下来吧 ,相信 错误一定是有原因的 找到解决办法为止:

描述一下 项目架构吧:

简单的web'项目:

在tomcat运行通过,

1.添加struts2.3.4 ,通过配置,测试 struts2 已经可以正常云新

2.添加spring支持,导入spring3.1.3 相应jar包,当然不是全部,只导入和 struts整合需要的jar

在 struts.properties 中将 struts.objectFactory = spring 使用

让后再启动 项目 出现下边问题:

2012-11-1 20:49:13 org.apache.catalina.core.StandardContext filterStart

严重:Exceptionstartingfilterstruts2

Unabletoloadconfiguration.-[unknownlocation]

atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:450)

atorg.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:193)

atorg.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)

atorg.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)

atorg.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)

atorg.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)

atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4726)

atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)

atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)

atorg.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)

atorg.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)

atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)

atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)

atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)

atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)

atorg.apache.catalina.core.StandardHost.start(StandardHost.java:840)

atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)

atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

atorg.apache.catalina.core.StandardService.start(StandardService.java:525)

atorg.apache.catalina.core.StandardServer.start(StandardServer.java:754)

atorg.apache.catalina.startup.Catalina.start(Catalina.java:595)

atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

atjava.lang.reflect.Method.invoke(Method.java:597)

atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Causedby:Unabletoloadconfiguration.-[unknownlocation]

atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:69)

atorg.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:390)

atorg.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:437)

...28more

Causedby:CannotlocatethechosenObjectFactoryimplementation:spring-[unknownlocation]

atorg.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:340)

atorg.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:311)

atorg.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:245)

atcom.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:210)

atcom.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66)

...30more

2012-11-120:49:13org.apache.catalina.core.StandardContextstart

严重:ErrorfilterStart

2012-11-120:49:13org.apache.catalina.core.StandardContextstart

严重:Context[/orderMeal]startupfailedduetopreviouserrors

2012-11-120:49:14org.apache.catalina.core.ApplicationContextlog

信息:ClosingSpringrootWebApplicationContext

2012-11-120:49:15org.apache.catalina.startup.HostConfigdeployDirectory

信息:DeployingwebapplicationdirectoryROOT

2012-11-120:49:15org.apache.coyote.http11.Http11AprProtocolstart

信息:StartingCoyoteHTTP/1.1onhttp-8080

2012-11-120:49:15org.apache.coyote.ajp.AjpAprProtocolstart

信息:StartingCoyoteAJP/1.3onajp-8009

2012-11-120:49:15org.apache.catalina.startup.Catalinastart

信息: Server startup in 16108 ms

解决办法:

这次绝对是我的错:

以为 struts-spring-plugin **.jar 以为是spring的 包

无意中才想起 是struts 的包 ,

哎 ,这两年 干嘛呢 ,退步了!谨记!

相关推荐