1 2 Previous Next 16 Replies Latest reply on Nov 17, 2002 3:25 PM by adrian.brock

    does jboss support deployment of multiple .ear files contain

    satyannair

      i have a application.ear catering to 2 databases for which i have the database conf defined in
      a-service.xml
      b-service.xml

      and i have 2 ears abc.ear and xyz.ear both of them contain the same content i.e .jar and the .war files.
      i changed the jboss.xml, jboss-web.xml and the web.xml to specifiy different JNDI names for the ejb calls.

      i have session beans getting the data from the jsp.
      Surprisingly both the application got deployed but when i run both the application which as different contexts, it gives me the same data ... i.e data from one database coming into both the application.

      i wrote a small application that i m attaching with this query for testing the multiple instances but i guess i m failing somewhere. cause it looks like it doesn't support multiple instances?

      my email javaejb@satyan.com
      would appreciate any help i get on this issue?

      Satyan Nair

        • 1. Re: does jboss support deployment of multiple .ear files con

          j2ee packaging is madness at the best of times
          and then you put ears in a zip :-)

          My guess is that you are using static somewhere.
          You have duplicate classes across the ears.

          By default, JBoss uses a flat classloader, so the first
          version of the class loaded will be used by the
          second ear.

          To avoid sharing classes across ears create
          a loader repository for each ear. This will give
          you a new classloader space for each application.

          To do this:
          Alongside the application.xml in the ear META-INF
          create a jboss-app.xml with something like the
          following...

          <jboss-app>
          <loader-repository>com.cobite:loader=ejbcounter.ear</loader-repository>
          </jboss-app>

          The sooner we replace these Jive forums and get a search
          engine that works the better.
          If I have to explain this one more time I will scream :-)

          IMPORTANT: If you are using static, make sure you
          understand the spec, otherwise you will probably get
          unexpected behaviour, especially if you try to
          use synchronize to do your own concurrency.
          Bean instances are pooled and should do no thread
          control operations.

          Regards,
          Adrian

          • 2. Re: does jboss support deployment of multiple .ear files con
            satyannair

            thanks adrain,
            i have the jboss-app.xml and one of my servlet action classes which gets invoked via the struts-config.xml returns a set of data which is unique... for both the application

            but when i start the application over the web it gives me error saying that the action classes could not be created or instance not found.

            I have my ejb classes in a jar called say a.jar and my non-ejb classes in another jar called say b.jar
            and I load it in application.xml as

            <display-name>application name</display-name>

            a.jar


            b.jar



            <web-uri>app.war</web-uri>
            <context-root>/app</context-root>




            i also have the non-ejb classes in the war file under the WEB-INF/classes directory

            why are my classes not getting instantiated when i call it from the web context?
            is it an issue of duplicate classes? i m loading it in the webcontext of tomcat within the WEB-INF/classes dir and also in the application as b.jar!

            Before using jboss-app.xml atleast my classes got instantiated and i was able to run my application!

            Thanks for the help!
            Satyan

            • 3. Re: does jboss support deployment of multiple .ear files con

              Hi,

              I don't use struts.
              But I know it has problems if struts.jar isn't in web-inf/lib,
              I believe there's a section in the documentation explaining the restrictions/short comings.

              Regards,
              Adrian

              • 4. Re: does jboss support deployment of multiple .ear files con
                satyannair

                thanks adrain for narrowing down my problem!

                i have the struts.jar in the web-inf/lib dir which gets packaged inside the .war and also a copy in the ../lib of jboss dir

                when the application is being deployed it loads the struts-config.xml and the web.xml from where the single action servlet gets instantiated for that application.

                in my action servlet i cache some data just as it is being instantiated or loaded.

                earlier when i was deploying both the .ears with the same .jars and .wars without the jboss-app.xml i used to get the same cached data that was used for the first .ear!
                Note: both the application are trying to load data from different database configuration -service.xml files via different jndi names in the .xml configuration files(e.g the jboss.xml, jboss-web.xml etc)
                Rest both the .ears have the same classes and jsps.

                and When i invoke the application on my browser, i get the same data which was used of the first .ear deployed.

                but after i placed the jboss-app.xml i got different data while the startup of the application itself . Successful to this point.
                but when i invoke the application on the browser it gives me the error as below.

                Any clue?
                i am using struts and my action classes are in the WEB-INF/classes dir as well as i have packaged my action classes as a .jar and loading it in the application.xml as

                app-servlet.jar


                i thought i have duplicate class issue.. but well i played by mixing and matching.. by first removing the app-servlet.jar tag from the application and allowing it to load only under the tomcat context of WEB-INF/classes,
                then removing all the application files under the WEB-INF/classes dir and packaging it into a .war and only loading the non-ejb classes.. i.e these action classes as the app-servlet.jar and loading it via the application.xml

                this is after adding the jboss-app.xml!

                any clue where i m going wrong here?
                why are my non-ejb classes not accessible from the web context of tomcat when i use jboss-app.xml whereas i m able to do it when i don't use the jboss-app.xml?
                *******************************************************************************************



                16:39:43,406 INFO [Engine] action: Processing a POST for /logon
                16:39:43,408 INFO [Engine] action: Looking for ActionForm bean under attribute 'logonForm'
                16:39:43,410 INFO [Engine] action: Creating new ActionForm instance of class 'com.cobite.tbillAdmin.LogonForm'
                16:39:43,419 ERROR [Engine] action: Error creating ActionForm instance of class 'com.cobite.tbillAdmin.LogonForm'
                java.lang.ClassNotFoundException: com.cobite.tbillAdmin.LogonForm
                at org.jboss.mx.loading.UnifiedLoaderRepository2.loadClass(UnifiedLoaderRepository2.java:166)
                at org.jboss.mx.loading.UnifiedClassLoader.loadClass(UnifiedClassLoader.java:283)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
                at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
                at java.lang.Class.forName0(Native Method)
                at java.lang.Class.forName(Class.java:140)
                at org.apache.struts.action.ActionServlet.processActionForm(ActionServlet.java:1633)
                at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1495)
                at com.cobite.tbillAdmin.TbillActionServletSchmo.process(TbillActionServletSchmo.java:62)
                at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:504)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
                at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
                at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
                at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

                • 5. Re: does jboss support deployment of multiple .ear files con

                  at java.lang.Class.forName(Class.java:140)
                  at org.apache.struts.action.ActionServlet.processActionForm(ActionServlet.java:1633)

                  Like I said above, struts only works when it is
                  in the package with the application.
                  If you still have struts in server/default/lib
                  or somewhere else in the main repository it will
                  ignore your ear, the clases aren't visible from
                  the main repository.

                  The problem is the horrible Class.forName()
                  they that they use, instead of the context classloader.

                  Regards,
                  Adrian

                  • 6. Re: does jboss support deployment of multiple .ear files con
                    satyannair

                    yes adrain,
                    i do have the struts.jar in the WEB-INF/lib as well as the server/default/lib in jboss.

                    if i don't keep the struts.jar in the server/default/lib then when the jboss loads the struts-config.xml and the web.xml, i.e. the single most action servlet class, the entry point into a web application, it just crashes, so i had to put struts.jar in the jboss lib dir...

                    i will keep hunting for an answer!

                    • 7. Re: does jboss support deployment of multiple .ear files con
                      satyannair

                      hi Adrain,
                      if u get a chance please let me know how to add 2 packages in the jboss-app.xml in the loader repository

                      <jboss-app>
                      <loader-repository>com.cobite.tbillAdmin,org.apache.struts:loader=exprts-admin-schmo.ear</loader-repository>
                      </jboss-app>
                      obviously that gave me an error!

                      something like this! i have unjarred the struts.jar .. also i added as a module in the application.xml


                      struts.jar

                      but no success!

                      • 8. struts and jboss-app.xml and multiple ears
                        satyannair

                        hi Adrain,
                        if u get a chance please let me know how to add 2 packages in the jboss-app.xml in the loader repository

                        <jboss-app>
                        <loader-repository>com.cobite.tbillAdmin,org.apache.struts:loader=exprts-admin-schmo.ear</loader-repository>
                        </jboss-app>
                        obviously that gave me an error!

                        i tried by unjarring the struts.jar and packaging it with the non-ejb.jar... and .. also i added as a module in the application.xml


                        struts.jar

                        but no success!
                        without struts my app won't run at all!

                        why can't jboss-app.xml not load two package domains?

                        • 9. Re: struts and jboss-app.xml and multiple ears

                          The <loader-repository> is an MBean ObjectName used
                          to seperate classloading.
                          You could call it x:y=z it wont make any difference.

                          What was the crash?

                          You haven't said which version of JBoss you are
                          using or Tomcat?

                          Regards,
                          Adrian

                          • 10. Re: struts and jboss-app.xml and multiple ears
                            satyannair

                            the version is jboss-3.0.3_tomcat-4.1.12
                            my application.xml


                            <display-name>exprts-admin-schmo</display-name>

                            exprts-admin-schmo.jar (my ejb classes)


                            exprts-admin-schmo-servlet.jar (the non-ejb classes which is also in the WEB-INF/classes of the war)


                            struts.jar



                            <web-uri>exprts-admin-schmo.war</web-uri>
                            <context-root>/exprts-admin-schmo</context-root>





                            When i add the struts.jar into my application.xml i get the stack trace as specified below. But if i don't specify the struts.jar in the application.xml file then my ActionServlet gets instantiated without problem!
                            But then i m not able to invoke the application over the browser which says that it failed to create ActionClass instance.

                            So by writing the jboss-app.xml, i guess the only problem for me is to get the struts action class or the struts.jar also available to my non-ejb classes via the class loader.
                            it is surprising that i have the struts.jar in the WEB-INF/lib dir in the war as well in the jboss lib dir and it is not picking it up.
                            my jboss-app.xml goes
                            <jboss-app>
                            <loader-repository>com.cobite.tbillAdmin:loader=exprts-admin-schmo.ear</loader-repository>
                            </jboss-app>

                            how do i get my struts classes also to be loaded within the same repository space?

                            below goes my stack trace:
                            17:43:33,486 INFO [Engine] action: Initializing configuration from resource path /WEB-INF/struts-config.xml
                            17:43:34,433 ERROR [Digester] End event threw exception
                            java.lang.NoSuchMethodException: No such accessible method: addFormBean() on object: com.cobite.tbillAdmin.TbillActionServletSchmo
                            at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:226)
                            at org.apache.commons.digester.SetNextRule.end(SetNextRule.java:260)
                            at org.apache.commons.digester.Digester.endElement(Digester.java:1036)
                            at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1528)
                            at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
                            at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
                            at org.apache.crimson.parser.Parser2.content(Parser2.java:1779)
                            at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1507)
                            at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
                            at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
                            at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
                            at org.apache.commons.digester.Digester.parse(Digester.java:1514)
                            at org.apache.struts.action.ActionServlet.initMapping(ActionServlet.java:1273)
                            at org.apache.struts.action.ActionServlet.init(ActionServlet.java:460)
                            at com.cobite.tbillAdmin.TbillActionServletSchmo.init(TbillActionServletSchmo.java:15)
                            at javax.servlet.GenericServlet.init(GenericServlet.java:256)
                            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:924)
                            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:813)
                            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3341)



                            this is what happens when i don't put struts.jar in the application.xml

                            17:53:13,605 INFO [Engine] action: Initializing configuration from resource path /WEB-INF/struts-config.xml
                            17:53:16,032 INFO [Engine] action: Scanning web.xml for controller servlet mapping
                            17:53:16,417 INFO [Engine] action: Process servletName=action, urlPattern=*.do
                            17:53:16,421 INFO [Engine] action: Mapping for servlet 'action' = '*.do'
                            17:53:16,431 INFO [STDOUT] in schmo TbillActionServlet
                            17:53:16,432 INFO [STDOUT] appname in schmo:exprts-admin-schmo
                            17:53:16,433 INFO [STDOUT] ejbname in schmo:exprts-admin-schmo
                            17:53:16,452 INFO [STDOUT] Ejbname:exprts-admin-schmo
                            17:53:16,454 INFO [STDOUT] getting RetrieveData home referance - in TbillUserpermissions SCHMO!
                            17:53:17,711 INFO [STDOUT] retrieveBean created
                            17:53:17,737 INFO [STDOUT] just prior to getting list - satyan
                            17:53:17,778 INFO [STDOUT] getting connection from connectionfactory in schmo
                            17:53:19,049 INFO [STDOUT] got getTbillUserPermissions connection reference!



                            this is good till now. But when i try to invoke the application from the web it gives me this stack trace:



                            17:56:04,410 INFO [Engine] action: Processing a POST for /logon
                            17:56:04,411 INFO [Engine] action: Looking for ActionForm bean under attribute 'logonForm'
                            17:56:04,412 INFO [Engine] action: Creating new ActionForm instance of class 'com.cobite.tbillAdmin.LogonForm'
                            17:56:04,422 ERROR [Engine] action: Error creating ActionForm instance of class 'com.cobite.tbillAdmin.LogonForm'
                            java.lang.ClassNotFoundException: com.cobite.tbillAdmin.LogonForm
                            at org.jboss.mx.loading.UnifiedLoaderRepository2.loadClass(UnifiedLoaderRepository2.java:166)
                            at org.jboss.mx.loading.UnifiedClassLoader.loadClass(UnifiedClassLoader.java:283)
                            at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
                            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
                            at java.lang.Class.forName0(Native Method)
                            at java.lang.Class.forName(Class.java:140)
                            at org.apache.struts.action.ActionServlet.processActionForm(ActionServlet.java:1633)
                            at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1495)
                            at com.cobite.tbillAdmin.TbillActionServletSchmo.process(TbillActionServletSchmo.java:62)
                            at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:504)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
                            at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
                            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)


                            i guess if i can get the struts.jar to be loaded in the same repository space as the com.cobite.tbillAdmin then i should be through...

                            thanks adrain,
                            i appreciate ur help!

                            • 11. Re: struts and jboss-app.xml and multiple ears
                              satyannair

                              where can i find the dtd for the jboss-app.xml?

                              • 12. Re: struts and jboss-app.xml and multiple ears

                                Somebody else access about that, there isn't one.

                                It currently has the options

                                <jboss-app>
                                <loader-repository>...</loader-repository>
                                ...
                                ...
                                ...
                                </jboss-app>

                                Where identifies mbean configs.
                                *-service.xml or *.sar

                                Regards,
                                Adrian

                                • 13. Re: struts and jboss-app.xml and multiple ears
                                  satyannair

                                  any clue on how to load the struts.jar also in the same classloader scope?

                                  • 14. what if i want 2 package domains in the jboss-app.xml
                                    satyannair

                                    what if i want 2 package domains in the jboss-app.xml

                                    i know that the loader repository loads on package..
                                    <jboss-app>
                                    <loader-repository>com.test:loader=test.ear</loader-repository>
                                    </jboss-app>

                                    what if i have com.test and org.test both to be loaded in the same repository space?

                                    why does jboss-app.xml take only one package?
                                    is this an architectural issue?

                                    1 2 Previous Next