Discussions

Web tier: servlets, JSP, Web frameworks: Multiple Struts applications w/ action class of same name

  1. Hi,

    I'm trying to run multiple war files, each representing a different version of the same Struts application, under the same JBoss webserver instance (i.e., application_v1.war and application_v2.war both in jboss\server\name\deploy).

    Because these are two versions of the same application, the action forms and action classes have the same names, as well as much overlapping, but not identical, code. Basically, I want to be able to have each successive application build running concurrently (under one JBoss instance) so the customer can easily compare the latest release with the previous ones to see the incremental changes.

    In Struts 1.1, if a DynaActionForm in one version contains fields not present in the other, then it is impossible to load the webpage for the version containing extra fields. This is fixed in Struts 1.2.4. So that takes care of the action forms.

    However, I haven't been able to get around the action classes. Even in Struts 1.2.4, when two separate applications have actions with the same name, only one of these action classes is being used. Thus v2.war may be calling an action class from v1.war.

    In a simple test case, I was able to get it to work by changing the names of each Struts action class to include the build version, but this would be a lot of tedious work for a regular-sized application.

    Can anyone help explain what is going on here?
    Does anyone know a way around this?
    Is it even possible to do this with one webserver instance, or do I need to run each application version in its own instance?

    Thanks for your help.
    Mena
  2. Have you assigned separate URL paths to your applications in your server config file?
  3. JBoss Class Loading[ Go to top ]

    Which config file do you mean?

    The JSPs loaded fine for each application, and everything "looked normal" until the form was posted and the Action class was executed. Then it was obvious that only one application's class was being executed by both.

    After spending some more time on this, this is really a JBoss configuration issue. I was able to resolve the problem in the test case by configuring class loading for WAR deployment. You can force JBoss to load and keep independant the classes from multiple .war files co-existing in the same JBoss instance, but this isn't the default setting.
  4. JBoss Class Loading[ Go to top ]

    How did you configure JBoss to load and keep independant the classes from multiple .war files co-existing in the same JBoss instance?

    Can you help me by giving some specific steps?Or point me right documentation where I can get the steps.

    I am also facing exactly same problem.I need to run two war files with same set of actions in one JBoss instance.

    I would appreciate your help.

    -Rohit
    Which config file do you mean?The JSPs loaded fine for each application, and everything "looked normal" until the form was posted and the Action class was executed. Then it was obvious that only one application's class was being executed by both.After spending some more time on this, this is really a JBoss configuration issue. I was able to resolve the problem in the test case by configuring class loading for WAR deployment. You can force JBoss to load and keep independant the classes from multiple .war files co-existing in the same JBoss instance, but this isn't the default setting.
  5. If you are using JBoss, the different contexts are not isolated. With JBoss class loading, you have to name the classes differently or the packages. You CANNOT run the same classes and same packages in different contexts. JBoss purposely deemed that only one class should be loaded, not two. That's inefficient right? ..well it seems OK in different web contexts. Can't do it. Plain and simple it won't work.
    But, think about it too, why would anyone use the same com.mycomp.any.Dao and not use the same class everytime. I found this problem because I was replicating similar applications and implementing methods differently. I understand your issue, however, and if you figure out your specific issue (same classes, same code) ...please share your findings with us (the public).

    Piratepete (aka. David L. Whitehurst)
  6. For better performance,JBOSS uses unified class loader and I believe that's what causing the above mentioned problems.

    Do the following to turn it off:

    Open server\default\deploy\jbossweb-tomcat50.sar\META-INF\jboss-service.xml

    and look for following line:

     <!-- A flag indicating if the JBoss Loader should be used. This loader
               uses a unified class loader as the class loader rather than the tomcat
               specific class loader.
          -->
          <attribute name="UseJBossWebLoader">true</attribute>


    Change the flag to false and it should work like a charm!

    HTH,
    Ganesh