views:

402

answers:

2

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 w.r.t 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?

Thanks, -Keshav

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

A: 

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 !

Peter Thomas
Thanks for your reply. I am not using Spring framework. But, you might have pointed me in the right direction- log4j. I even tried removing log4j.properties and log4j jars from both the web applications to eliminate the log4j from the equation, but the result was same as before..it did not work.
Keshav
A: 

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!

Thanks, -Keshav

Keshav