10 Replies Latest reply on Nov 30, 2009 7:15 PM by jmiguel77

    Deploy multiple Seam-EARs to a single JBoss AS

    mikeschulze

      Hi - I have a problem with deploying my Seam-Apps (2.0.2SP1) to my JBoss AS (4.2.2).

      I have two Seam-EAR-Projects and want to deploy them to a JBoss AS. If I only deploy one of them it works fine, but if I deploy both of them at the same time I get a ClassCastException if I start one of those applications.

      More details:

      EAR1 (AppA) consists of a WAR (WAR1) and an JAR
      EAR2 (AppB) consists of a WAR (WAR2) and the same JAR


      During the startup of an application an EJB (Manager) initializes a Seam-Component a runs a method from this component. In this method there is a call to a database to retrieve a certain entity (Cient):


      Object o = em.createQuery("SELECT c FROM Client c WHERE c.clientcode =:clientcode").setParameter("clientcode", clientcode).getSingleResult();
      result = (Client) o;



      The Exception occurs during the cast in the second line, although the retrieved object IS a client-object. (it works if only one EAR is deployed)

      The error only occurs in AppA - because it seems to be loaded earlier by the AS (i guess). AppB seems to work fine. If I rename AppA to AppC the exception occurs in AppB. :-( All involving classes (Bean, Seam-Component, POJO/Entity) are located within the JAR.


      I thought the is something wron with my classloader - but in the JMX-console i can see that ther two of them (org.jboss.mx.loading.HeirarchicalLoaderRepository3) one for every EAR.

      Does anybody have a clue where I could look or what my problem is?
      Is it possible to deploy multiple Seam Applications to an Application Server?


      Thx - Mike

        • 1. Re: Deploy multiple Seam-EARs to a single JBoss AS
          joaobmonteiro

          Hi Mike,


          Yes, your problem is all about classloaders. I am not a JBoss AS expert so my advice could not be the better one but one thing you can do is treat each app as isolated ear. For this, in ear-deployer.xml set the Isolated atribute:


          
          <attribute name=”Isolated”>true</attribute>
          
          



          I use this configuration and I am able to deploy multiple Seam application. Maybe someone could post a better solution.


          I hope it helps.

          • 2. Re: Deploy multiple Seam-EARs to a single JBoss AS
            mikeschulze

            Hi - thx Joao,


            yes - I have already tried this. Unfortunately it doesn't help. :-(

            • 3. Re: Deploy multiple Seam-EARs to a single JBoss AS
              obfuscator

              Have you checked that no sub-war:s or other archives defines colliding names for classloaders?

              • 4. Re: Deploy multiple Seam-EARs to a single JBoss AS
                mikeschulze

                There are no other apllications deployed then my two EARs. As I mentioned - if I undeploy one of those - the other EAR works just fine.


                In the JMX-console of my JBoss I can see, that there are two different LoaderRepositories:



                org.jboss.mx.loading.HeirarchicalLoaderRepository3@1d0bc85 
                org.jboss.mx.loading.HeirarchicalLoaderRepository3@198c0b5



                and these are my jboss-app.xmls


                EAR1:


                <jboss-app>
                   <loader-repository>
                        seam.jboss.org:loader=app1-ear
                        <loader-repository-config>
                             java2ParentDelegation=false
                        </loader-repository-config>
                   </loader-repository>
                </jboss-app>



                EAR2:



                <jboss-app>
                   <loader-repository>
                        seam.jboss.org:loader=app2-ear
                        <loader-repository-config>
                             java2ParentDelegation=false
                        </loader-repository-config>
                   </loader-repository>
                </jboss-app>



                • 5. Re: Deploy multiple Seam-EARs to a single JBoss AS
                  ppalazon.ppalazon.dsi.uclm.es

                  It's possible that you have 2 jars with same classes?. If you have the same classes with same qualify-name, classloader don't know what class get.

                  • 6. Re: Deploy multiple Seam-EARs to a single JBoss AS
                    austin

                    Hi Mike,


                    I am now facing exactly the same problem with Seam 2.1.1.GA running on Jboss 4.2.3.GA AS. Did you solve this problem?


                    Best regards,
                    Austin


                    • 7. Re: Deploy multiple Seam-EARs to a single JBoss AS
                      austin

                      I figured out where the problem is right after posting. The problem is caused by the same jndi-name of EntityManagerFactory. Just modify the persistence.xml and components.xml and makes the jndiName of EntityManagerFactory(s) different.


                      Hope this helps.
                      Austin

                      • 8. Re: Deploy multiple Seam-EARs to a single JBoss AS
                        mikeschulze

                        Yeah - that was our solution, too. Sorry for not posting it here.


                        Mike

                        • 9. Re: Deploy multiple Seam-EARs to a single JBoss AS
                          jmiguel77
                          Hi

                          i have tried the solutions exposed here but with no success

                          - i changed the ear-deployer.xml file with Isolation=true
                          - i have changed the jboss-app.xml of the ears in the way described here
                          - the EntityManagerFactory of each ear has a differente JNDI name

                          nevertheless i am getting this exception:

                          Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.seam.framework.EntityHome
                                  at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
                                  at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:521)
                                  at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
                                  at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                                  at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

                          any ideas ??

                          thanks a lot for your help
                          • 10. Re: Deploy multiple Seam-EARs to a single JBoss AS
                            jmiguel77

                            i don't know if this would be of any importance, but i have some flex development inside those ears; i am using flamingo to make the seam / flex binding