5 Replies Latest reply on Feb 28, 2007 12:32 PM by weston.price

    Shared Jar files in RAR and WAR

    venugopalm59

      Hi,

      I have a web application which uses a connector to call an external application.

      Due to some requirement restrictions, the web application and the connector are packaged seperately - they cannot be packaged into a single EAR. Also these components needs to be self-contained, ie all the dependent JAR files need to be packaged inside these components and cannot be placed in the Server's classpath.

      The same RAR and the WAR files need to deployed without any change to JBoss and also to WebLogic.

      The RA is not implementing CCI.

      Since the RAR and the WAR code uses the ConenctionFactory I need to place the Connector JAR file inside both the RAR and the WAR. Since the classloaders for RAR and the WAR are different I get a ClassCastException when I lookup the ConnectionFactory in the Web Application.

      For the connector and the web application to be run on the Weblogic App. Server I can keep the Connector JAR file (containing the ConnectionFactory implementation) in both the RAR file and the JAR file and also set the
      <enable-global-access-to-classes>true</enable-global-access-to-classes> in weblogic-ra.xml.

      Can someone please help me by providing a similar solution with JBoss keeping in mind the following requirements:

      1. CCI not supported
      2. Connector JAR needs to be placed in both the RAR and the WAR
      3. The shared JAR files cannot be moved to Server classpath
      4. RAR and WAR needs to be deployed seperately - not in an EAR
      5. RAR and WAR needs to be deployed in JBoss and Weblogic without any structural change.

      Is there any option in JBoss specific deployment descriptors?

      Thanks and Regards,
      Venu

        • 1. Re: Shared Jar files in RAR and WAR
          weston.price

           


          Due to some requirement restrictions, the web application and the connector are packaged seperately - they cannot be packaged into a single EAR . Also these components needs to be self-contained, ie all the dependent JAR files need to be packaged inside these components and cannot be placed in the Server's classpath .


          This is fine. The classes from the RAR file will still be available to the WAR deployement without having to re-package them with the WAR.


          Since the RAR and the WAR code uses the ConenctionFactory I need to place the Connector JAR file inside both the RAR and the WAR.
          Since the classloaders for RAR and the WAR are different I get a ClassCastException when I lookup the ConnectionFactory in the Web Application.


          The reason for the CCE is that you are including the classes in *both* deployments. Remove these classes from the WAR. See above.


          For the connector and the web application to be run on the Weblogic App. Server I can keep the Connector JAR file (containing the ConnectionFactory implementation) in both the RAR file and the JAR file and also set the
          <enable-global-access-to-classes>true</enable-global-access-to-classes> in weblogic-ra.xml.


          Effectively, this is accomplished in JBoss without having to specify anything beyond the defaults.





          • 2. Re: Shared Jar files in RAR and WAR
            venugopalm59

            Thank you very much for your reply.

            I had, in fact executed the JCA without the JAR files inside my WAR - it works fine. But, as I said, Weblogic dosent allow us to deploy the WAR file without the JAR file in its WEB-INF/lib folder. Since I need to maintain the same packaging for all the servers, it is causing the problem.

            I would be really grateful if you could point me a way by which I can tell JBoss to merely ignore the JAR files included inside the WAR file - maybe using some deployment descriptor elements.

            Appreciate your help greatly.

            Thanks and Regards,
            Venu

            • 3. Re: Shared Jar files in RAR and WAR
              weston.price

              To do this you will need to change the default settings for Tomcat to use the JBossWebLoader by default and to use Parent2Child delegation. Since you didn not post what version of JBoss you are using I will assume JBoss 4.x. In your deploy directory you will see a directory

              jbossweb-tomcat55.sar

              Navigate to the META-INF directory and locate the jboss-service.xml file. In this file you will see two attributes

              <attribute name="Java2ClassLoadingCompliance">false</attribute>
              <attribute name="UseJBossWebLoader">false</attribute>
              


              set both of these to true. This will force the WAR deployment to not use an isolated classloader.

              Note, I don't really recommend doing this as it will effect every single WAR deployment in JBoss and pretty much violates the whole point of the WAR classloader to begin with. If you use Ant or some other automated build process the real solution would be to simply package your archives for your appropriate platform. Since this is simply a matter or excluding/including files, this would be the better approach.

              Good luck.



              • 4. Re: Shared Jar files in RAR and WAR
                venugopalm59

                Thanks a lot for giving this information!

                It works.


                If you use Ant or some other automated build process the real solution would be to simply package your archives for your appropriate platform. Since this is simply a matter or excluding/including files, this would be the better approach.
                We are in a situation where we are really stuck to the single package option.

                But one final question - Is it possible to override the Java2ClassLoading policy on a single Web application basis. I assume there should be an equivalent file for the WAR (equivalent of jboss-service.xml) - but I could not find such an otpion in jboss-web.xml.

                Again, thank you very much!

                Regards,
                Venu


                • 5. Re: Shared Jar files in RAR and WAR
                  weston.price

                  Unfortunately no. This is one of the 'benefits' to using an EAR as this can be done on a module by module basis without forcing all of your other deployments to use the same settings.