简体   繁体   中英

Two struts2 webapps fail to start together

I have problems getting two different struts2 webapps to start together in tomcat. But each of the webapps start correctly when placed independently inside webapps folder of tomcat.

I get the following in catalina.out logs-

SEVERE: Error filterStart Aug 13, 2009 3:17:45 PM org.apache.catalina.core.StandardContext start SEVERE: Context [/admin] startup failed due to previous errors

Environment- Java1.6, Tomcat6, Struts2.1.6, FC10

The webapps are "admin" and "user". Both of these webapps contain struts2 jars inside their WEB-INF/lib directory respectively.

web.xml contains the following in both the webapps-

<filter>
  <filter-name>struts2</filter-name>
  <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>

<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

A point to note that always the "admin" webapp fails to load with the above error. If I remove the "user" webapp from webapps folder, "admin" webapp comes up just fine.

I have also observed one more thing wrt struts2 filter in web.xml- If I remove the struts2 filter from web.xml in one of the webapps, BOTH the webapps start without any errors in the logs (but of course I won't be able to use struts in the webapp where the filter is removed).

I have also tried moving the struts2 jar to tomcat lib and removing them from individual webapps, but same problem exists..

Any ideas what is causing this problem?

Updates: This strangely works fine on Ubuntu OS. But the problem persists on FC10 and OpenSolaris.

I had a similar problem using Spring and using this listener class in web.xml:

org.springframework.web.util.Log4jConfigListener

See the documentation of the Spring Log4jWebConfigurer , which says you need unique "web app root" properties defined per web-app, so I had to have a section like this in each web.xml:

<!-- used by Log4jConfigListener -->
<context-param>
    <param-name>webAppRootKey</param-name>
    <param-value>myappname.root</param-value>
</context-param> 

Are you using Spring ? If not hope this gives you some clues, I don't know much about Struts2 maybe it does something similar. Do let me know how it goes !

Thanks alzoid, extraneon and Peter.

I had overlooked an exception coming up on localhost..log file. I thought I had redirected all the struts log to a different log file but had overlooked mentioning the opensymphony package in the log4j properties file.

Coming to original problem- there was a class loader issue with xerces-impl jar and some other jar file belonging to struts2. So when I removed the xerces-impl jar from the WEB-INF/lib directories in both apps, it started worked fine!

We had the same problem while launching two struts2 Maven apps on the same server. The xerces lib was the problem so we did add xalan in the pom.xml dependencies and everything worked fine:

    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.1</version>
        <type>jar</type>
        <scope>compile</scope>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM