我有一個完全部署在JBoss 6.0應用服務器上的基於J2EE的Web應用程序。 我正在使用JBoss的「默認」服務器配置。 我的「.ear」文件包含EJB和一個「.war」文件 - 我使用Spring Security 3x進行用戶認證和授權。上下文初始化失敗:org.springframework.beans.factory.BeanDefinitionStoreException
當我在JBoss 6.1上部署相同的ear文件時,我發現我的WAR部署失敗並出現以下錯誤。令人驚訝的是:如果我以分解格式部署相同的「.ear」文件,則部署成功。
22:31:14,827 INFO [StdSchedulerFactory] Quartz scheduler version: 1.8.3
22:31:14,828 INFO [QuartzScheduler] Scheduler EdmQuartzScheduler_$_NON_CLUSTERED started.
22:31:14,828 INFO [QuartzService] QuartzService(EdmQuartzMBean) started.
22:31:14,837 INFO [TomcatDeployment] deploy, ctxPath=/edm
22:31:14,896 INFO [[/edm]] Initializing Spring root WebApplicationContext
22:31:14,897 INFO [ContextLoader] Root WebApplicationContext: initialization started
22:31:14,907 INFO [XmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Wed Sep 21 22:31:14 PDT 2011]; rootof context hierarchy
22:31:14,910 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-business.xml]
22:31:14,911 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext-business.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext-business.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341) [:3.0.5.RELEASE]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) [:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [:3.0.5.RELEASE]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [:3.0.5.RELEASE]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) [:3.0.5.RELEASE]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) [:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) [:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) [:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) [:3.0.5.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [:3.0.5.RELEASE]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3369) [:6.1.0.Final]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3828) [:6.1.0.Final]
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:294) [:6.1.0.Final]
at org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:146) [:6.1.0.Final]
at org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:476) [:6.1.0.Final]
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118) [:6.1.0.Final]
at org.jboss.web.deployers.WebModule.start(WebModule.java:95) [:6.1.0.Final]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_27]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_27]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_27]
at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27]
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96) [:6.0.0.GA]
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88) [:6.0.0.GA]
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:271) [:6.0.0.GA]
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:670) [:6.0.0.GA]
at org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206) [:2.2.0.SP2]
at $Proxy41.start(Unknown Source) at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:53) [:2.2.0.SP2]
at org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:41) [:2.2.0.SP2]
at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:379) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:301) [:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:2044) [jboss-dependency.jar:2.2.0.SP2]
at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:1083) [jboss-dependency.jar:2.2.0.SP2]
.
.
.
.
在我WAR的web.xml我指定Spring配置文件的位置爲:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-business.xml
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
我已經驗證XML文件沒有任何語法問題,這些文件是根據戰爭的的確包裝WEB-INF目錄。 現在我相信JBoss使用解壓WAR文件的Tomcat。因此,當加載WAR文件和/或未解壓縮文件時,似乎無法在類路徑中找到這些文件。
我不知道它如何在JBoss 6.0中成功工作,但在6.1上失敗。 6.1中有更多的錯誤修復,但是這兩個版本之間的內部結構或庫不會更改。
任何人都可以請建議爲什麼當「耳朵」部署在歸檔/摺疊格式時,Spring無法找到這些配置文件? 我是否需要在WEB-INF/classes下打包這樣的配置文件,還是應該在標記中使用像「classpath:」這樣的任何前綴?
非常感謝提前。