0

I am trying to migrate application deployed on weblogic 12 to tomcat 9 and while doing so I am facing following exception

java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present - check whether you have multiple ContextLoader* definitions in your web.xml!

content of my web.xml is as follows

<?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>

Content of my Weblogic.xml is as follows

<?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>

Note : Tomcat would not be able to understand weblogic.xml hence I have created context.xml file in META-INF folder of my application and content of context.xml is as follows

<Context path="/temp-service-v2"/>

Name of my war file is temp-service-v2.war

4
  • You might be able to put a breakpoint for IllegalStateException then go back up the stack to try to get a better idea of what is causing the issue. Commented Aug 21, 2019 at 12:20
  • Could it be similar to that one about web app too stackoverflow.com/questions/33633098/… ? Commented Aug 21, 2019 at 12:21
  • Any better suggestion than this? Should I add full stack trace in question? Commented Aug 21, 2019 at 12:21
  • @AlexeiMartianov it is not same because same application is running on weblogic Commented Aug 21, 2019 at 12:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.