我正在尝试将部署在weblogic 12上的应用程序迁移到tomcat 9,同时我面临以下异常
java.lang.IllegalStateException:无法初始化上下文,因为 已经存在一个根应用程序上下文-检查是否 您的web.xml中有多个ContextLoader *定义!
我的web.xml的内容如下
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
id="WebApp_ID" version="2.4">
<display-name>Temp</display-name>
<description>Temp Webservice</description>
<context-param>
<param-name>applicationName</param-name>
<param-value>Temp</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-ws-servlet.xml,/WEB-INF/spring-jpa.xml,/WEB-INF/spring-strategy.xml,/WEB-INF/spring-sdk.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<resource-ref>
<description>Oracle Datasource</description>
<res-ref-name>jdbc/TEMP_DS_RW</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<servlet>
<servlet-name>spring-ws</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-ws</servlet-name>
<url-pattern>/services/temp</url-pattern>
</servlet-mapping>
</web-app>
我的Weblogic.xml的内容如下
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.3</wls:weblogic-version>
<wls:context-root>temp-service-v2</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j</wls:package-name>
</wls:prefer-application-packages>
<!-- if not using prefer-application-resources you will get a warning like this: -->
<!-- Class path contains multiple SLF4J bindings -->
<!-- SLF4J: Found binding in [jar:file:/C:/wls1211/modules/org.slf4j.jdk14_1.6.1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] -->
<wls:prefer-application-resources>
<wls:resource-name>org/slf4j/impl/StaticLoggerBinder.class</wls:resource-name>
</wls:prefer-application-resources>
<wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>
</wls:weblogic-web-app>
注意:Tomcat无法理解weblogic.xml,因此我在应用程序的META-INF文件夹中创建了context.xml文件,context.xml的内容如下
<Context path="/temp-service-v2"/>
我的战争文件的名称是temp-service-v2.war