Announcement Announcement Module
Collapse
No announcement yet.
Error when deploying app to Tomcat Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when deploying app to Tomcat

    Hi,

    I got such error:

    StandardWrapper.Throwable
    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!
    at org.springframework.web.context.ContextLoader.init WebApplicationContext(ContextLoader.java:173)
    at org.springframework.web.context.ContextLoaderServl et.init(ContextLoaderServlet.java:83)
    at javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
    at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1105)
    at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:932)
    at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3917)
    at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4201)
    at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
    at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
    at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
    at org.apache.catalina.startup.HostConfig.deployDirec tory(HostConfig.java:904)
    at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:867)
    at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:474)
    at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1122)
    at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
    at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1021)
    at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:718)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1013)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:442)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:450)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:709)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:551)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:432)


    My web.xml file is:

    <?xml version="1.0" encoding="UTF-8"?>


    <web-app>

    <display-name>RentABike</display-name>
    <description>
    Renting bikes for fun and profit.
    </description>

    <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/rentaBikeApp-servlet.xml
    </param-value>
    </context-param>

    <servlet>
    <servlet-name>SpringContext</servlet-name>
    <servlet-class>
    org.springframework.web.context.ContextLoaderServl et
    </servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet>
    <servlet-name>RentABike</servlet-name>
    <servlet-class>
    org.apache.struts.action.ActionServlet
    </servlet-class>
    <init-param>
    <param-name>config</param-name>
    <param-value>/WEB-INF/struts-config.xml</param-value>
    </init-param>
    <init-param>
    <param-name>validate</param-name>
    <param-value>true</param-value>
    </init-param>
    <load-on-startup>2</load-on-startup>
    </servlet>

    <servlet-mapping>
    <servlet-name>RentABike</servlet-name>
    <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
    <welcome-file>
    start.html
    </welcome-file>
    </welcome-file-list>

    <!-- context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param-->

    <!--listener>
    <listener-class>
    org.springframework.web.util.Log4jConfigListener
    </listener-class>
    </listener-->

    <taglib>
    <taglib-uri>/spring</taglib-uri>
    <taglib-location>/WEB-INF/spring.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/c.tld</taglib-location>
    </taglib>

    <taglib>
    <taglib-uri>/struts</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListe ner
    </listener-class>
    </listener>

    </web-app>


    Can anyone tell me how to solve this problem? I found that there may be something wrong with ContextLoaderListener.

    cheers,
    tan

  • #2
    You have both ContextLoaderServlet and ContextLoaderListener in the web.xml. They do the same thing - load the app context, and only one is needed. If you are using a Servlet 2.4 container, use ContextLoaderListener, otherwise use ContextLoaderServlet.

    Comment


    • #3
      I removed ContextLoaderListener and now I got:

      Comment


      • #4
        Sorry for the previous post - I pressed <Enter> too fast.

        So I got such error now:

        Error loading WebappClassLoader
        delegate: false
        repositories:
        /WEB-INF/classes/
        ----------> Parent Classloader:
        org.apache.catalina.loader.StandardClassLoader@879 860
        org.apache.struts.action.ActionServlet
        java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
        at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1352)
        at org.apache.catalina.loader.WebappClassLoader.loadC lass(WebappClassLoader.java:1198)
        at org.apache.catalina.core.StandardWrapper.loadServl et(StandardWrapper.java:1034)
        at org.apache.catalina.core.StandardWrapper.load(Stan dardWrapper.java:932)
        at org.apache.catalina.core.StandardContext.loadOnSta rtup(StandardContext.java:3917)
        at org.apache.catalina.core.StandardContext.start(Sta ndardContext.java:4201)
        at org.apache.catalina.core.ContainerBase.addChildInt ernal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(Co ntainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(Sta ndardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployDirec tory(HostConfig.java:904)
        at org.apache.catalina.startup.HostConfig.deployDirec tories(HostConfig.java:867)
        at org.apache.catalina.startup.HostConfig.deployApps( HostConfig.java:474)
        at org.apache.catalina.startup.HostConfig.start(HostC onfig.java:1122)
        at org.apache.catalina.startup.HostConfig.lifecycleEv ent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLife cycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(Standa rdHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(Sta ndardService.java:450)
        at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalin a.java:551)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:294)
        at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:432)

        How to solve this problem?

        Comment


        • #5
          OK, I found the problem by myself - it was mainly caused by a stupid mistake - forgot to copy some jar.files to Tomcat. Sometimes happens.

          cheers,
          tan

          Comment

          Working...
          X