Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3455622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:38:13+00:00 2026-05-18T09:38:13+00:00

I have a tomcat server with two webapps (foo and bar) that have an

  • 0

I have a tomcat server with two webapps (foo and bar) that have an identical deployment war. The deployment uses the standard Spring/Hibernate setup. I assumed that these two webapps would start up and run completely independent of one another, but that is not the case – webapp foo loads normally, but webapp bar has some strange behavior – it’s as if it is using some of the same beans from webapp foo. For example, when bar starts up (the 2nd webapp to start), c3p0 complains that it is already registered – presumably in webapp foo. Again, I’m trying to make the two webapps completely independent, such that there should be no way for the two c3p0/hibernateSessionFactory beans to know about one another.

In doing some research, I’ve been led to believe that the same Spring root WebApplicationContext is being used in both webapps. If that is the case, how can I make each webapp (on the same tomcat server) completely independent of one another? Is there anything else that could be causing this problem?

Relevant excerpts from web.xml:

<web-app>
    <context-param>
        <param-name>org.hibernate.tags.sessionFactory</param-name>
        <param-value>hibernate/SessionFactory</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name> 
        <param-value>/WEB-INF/context/*Context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>fooServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
</web-app>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:38:14+00:00Added an answer on May 18, 2026 at 9:38 am

    I have a suspision. Isn’t class-loading the root of your problem?

    I guess the direct reason for your problem is that some Spring class is loaded once and shared between these two WARs. I don’t know the exact name of the class, but Spring needs to store some shared information (at least the reference to the application context) in some static field. Then when two WARs see the same copy of the class, then both applications see the same state of this static field. I guess in your setup Spring creates only one application context (when the second one should be created, Spring finds an existing application context and uses it instead).

    I see potential two reasons for such a problem:

    • either this is a class-loading issue. I am not that into tomcat and have no clue how and if you can configure that, but typically in JavaEE application servers there’s some way to configure class-loading for WARs.
    • or this is a kind of memory leak. Maybe the class (and its static field) is re-used from some previous deployment (unlikely, your description tends to suggest you encounter the problem on a fresh instance of tomcat). You can rule out this possibility by making sure the problem appears just after your (re)started tomcat.

    UPDATE:
    If this is about class-loading, I would try to figure out which class (and its static field) is causing problems. This is probably not your class but some 3rd-party library class you use in your application. After reading http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html you can see that Tomcat uses different unrelated class loaders for each application. However both of them share the parent class loaders which they delegate to if they don’t know the class.
    Again, I don’t know your exact setup and some Tomcat peculiarities, but… Isn’t it possible in Tomcat to put some library (JAR), like c3p0 or Spring, in some common ‘lib’ folder (the docs says $CATALINA_HOME/lib)? In such a case the classes from these JARs are loaded using parent class loader (the one called ‘Common’ in the tomcat docs). That implies they are loaded only once.

    To make the story short, I guess the reason is that one of the JARs in your $CATALINA_HOME/lib has some class which relies heavily on some static fields. Tomcat policy to load the JARs using Common class loader results in all applications sharing the state of these static fields.

    Have I told you this is only a suspicion and guessing?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web applications that are running on a single Tomcat server and
I have two applications under tomcat/webapps folder. tomcat/webapps/App1 tomcat/webapps/App2 Both applications share the same
I have a tomcat server running a webapp. Apart from this there are two
I have two tomcat web applications that need to share information using a singleton.
I have Tomcat 6.0.24 64 bit installed on two Windows Server 2008 boxes as
I have Flex/AIR app that connects to a tomcat server via BlazeDS. I'm not
I have two servers with Apache Tomcat that once in a while, connect to
I have a Tomcat server deployed that receives observations transmitted from sensors in JSON
I have configured Tomcat 6 to serve Perl CGI scripts. That part is well
I'm running tomcat and have some jsp pages that display a subset of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.