7 Replies Latest reply on Jan 25, 2008 8:02 AM by aleeuwen

    Two EARs with shared EJB/WAR

    aleeuwen

      Hello, I am trying to run two EARs on one server both of which are using SEAM. Or at least that's the idea. The problem is that I'm getting the following exception when the second EAR is loaded:

      11:27:53,724 INFO [Initialization] two components with same name, higher precedence wins: org.jboss.seam.core.init
      11:27:53,724 ERROR [[/ORM-optimizer-war]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      java.lang.RuntimeException: error while reading file:/C:/Program Files/jboss-4.2.2.GA/server/default/deploy/ORM-optimizer-ear.ear/ORM-model-ejb.jar/META-INF/components.xml
       at org.jboss.seam.init.Initialization.initComponentsFromXmlDocuments(Initialization.java:118)
       at org.jboss.seam.init.Initialization.create(Initialization.java:88)
      
      ...
      
      Caused by: java.lang.IllegalStateException: Two components with the same name and precedence: org.jboss.seam.core.init
       at org.jboss.seam.init.Initialization.addComponentDescriptor(Initialization.java:456)
       at org.jboss.seam.init.Initialization.installComponentFromXmlElement(Initialization.java:366)
       at org.jboss.seam.init.Initialization.installComponentsFromXmlElements(Initialization.java:257)
       at org.jboss.seam.init.Initialization.initComponentsFromXmlDocuments(Initialization.java:114)
       ... 138 more
      


      Apparently that component is already loaded, which makes sense to me. The question is am I doing something that I'm not supposed to be doing or should I do some configuration somewhere?

      If I would just load a 'shared' EJB in two EARs I don't seem to have a problem with the components since using the
      <core:init debug="true" jndi-pattern="@jndiPattern@" />

      in components.xml en specifying the pattern in components.properties in both EARs seem to work well. However not for the core components..? Any help is appreciated.

        • 1. Re: Two EARs with shared EJB/WAR
          nickarls

          Do you have an jboss-app.xml with a loader-repository?

          • 2. Re: Two EARs with shared EJB/WAR
            aleeuwen

             

            "nickarls" wrote:
            Do you have an jboss-app.xml with a loader-repository?


            That would be a no, however upon trying to use the following content in mij /META-INF/jboss-app.xml:

            <!DOCTYPE jboss-app
             PUBLIC "-//JBoss//DTD J2EE Application 1.4//EN"
             "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
            
            <jboss-app>
             <loader-repository>
             seam.jboss.org:loader=ORM-ear.ear
             </loader-repository>
            </jboss-app>


            It gives me the following error:

            13:41:44,032 INFO [Contexts] starting up: org.jboss.seam.bpm.jbpm
            13:41:44,069 ERROR [[/orm]] Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
            java.lang.NoClassDefFoundError: org/w3c/dom/Document
             at org.jbpm.configuration.ObjectFactoryParser.parseElementsFromResource(ObjectFactoryParser.java:104)
             at org.jbpm.JbpmConfiguration.parseObjectFactory(JbpmConfiguration.java:312)
             at org.jbpm.JbpmConfiguration.parseResource(JbpmConfiguration.java:360)
             at org.jboss.seam.bpm.Jbpm.<clinit>(Jbpm.java:305)
            


            If I don't have jboss-app.xml placed there it starts up okay. Clues?

            Thank you very much so far :-) It does seem to scope Seam (etc) correctly.

            • 3. Re: Two EARs with shared EJB/WAR
              aleeuwen

              As a follow-up: Commenting out the <bpm:jbpm ... /> in the following components.xml

              <?xml version="1.0" encoding="UTF-8"?>
              <components
               xmlns="http://jboss.com/products/seam/components"
               xmlns:core="http://jboss.com/products/seam/core"
               xmlns:persistence="http://jboss.com/products/seam/persistence"
               xmlns:drools="http://jboss.com/products/seam/drools"
               xmlns:bpm="http://jboss.com/products/seam/bpm"
               xmlns:security="http://jboss.com/products/seam/security"
               xmlns:mail="http://jboss.com/products/seam/mail"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd
               http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
               http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.0.xsd
               http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.0.xsd
               http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.0.xsd
               http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.0.xsd
               http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd"
              >
              
               <core:manager
               concurrent-request-timeout="500"
               conversation-timeout="1200000"
               conversation-id-parameter="cid"
               />
              
               <security:identity authenticate-method="#{authenticator.authenticate}" />
              
               <mail:mail-session host="localhost" port="2525" username="test" password="test" />
              
               <!-- For use with jBPM pageflow or process management -->
               <bpm:jbpm>
               <bpm:pageflow-definitions>
               <value>createdataset.jpdl.xml</value>
               <value>addhazardstojobindustry.jpdl.xml</value>
               <value>addhazardsfromscratch.jpdl.xml</value>
               </bpm:pageflow-definitions>
               </bpm:jbpm>
              
              </components>
              works like a charm, however I need the pageflows! Once again: if I lose the previously posted jboss-app.xml this problem works, however I can't have the two ears on one server.

              • 4. Re: Two EARs with shared EJB/WAR
                nickarls

                There is some info here:

                http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassLoadingConfiguration

                I don't have much experience in this since I haven't had that many classloading problems but following seam-gen example, try putting in the ear META-INF a jboss-app.xml with

                <?xml version="1.0" encoding="ISO-8859-1"?>
                <!DOCTYPE jboss-app
                 PUBLIC "-//JBoss//DTD J2EE Application 4.2//EN"
                 "http://www.jboss.org/j2ee/dtd/jboss-app_4_2.dtd">
                
                <jboss-app>
                 <loader-repository>seam.jboss.org:loader=unique</loader-repository>
                </jboss-app>
                


                and something other unique in the other ear.

                It's a long shot since one would think that normally one ear couldn't possible have effect on the other but experience shows otherwise as you have experienced...

                • 5. Re: Two EARs with shared EJB/WAR
                  aleeuwen

                   

                  "nickarls" wrote:
                  It's a long shot since one would think that normally one ear couldn't possible have effect on the other but experience shows otherwise as you have experienced...


                  Yeah I came across that page as well and have indeed put that jboss-app.xml in both of my ears with different 'unique' values. Reading my own post again and your response I realize that I didn't make myself all that clear:

                  What I meant was that the jboss-app.xml seems to work like a charm for the 'scoping' of the classes so that one EAR doesn't interfere with the other. However as soon as I use that jboss-app.xml in one of the ears I get an exception when the WAR is loaded: java.lang.NoClassDefFoundError: org/w3c/dom/Document when trying to initialize bpm (see earlier post).

                  So now I have the situation:

                  1. I don't use jboss-app.xml -> I can't have two EARs
                  2. I use jboss-app.xml -> I can have two EARs but one of them doesn't start.

                  Thanks so far for your time :-) and I still hope you or someone else has some pointers...

                  • 6. Re: Two EARs with shared EJB/WAR
                    pmuir

                    You should use scoped classloading with Seam always.

                    You should fix your NCDFE error by including the correct library n your deployed archives.

                    • 7. Re: Two EARs with shared EJB/WAR
                      aleeuwen

                       

                      "pete.muir@jboss.org" wrote:
                      You should use scoped classloading with Seam always.

                      You should fix your NCDFE error by including the correct library n your deployed archives.


                      Apparently I generated my current project with JBoss Tools v2.0.0.RC1 which didn't create that file for me, so that's why I missed that part.

                      However looking more into the problem of the NCDFE, it appears is it was not so much an including of the correct library as much as an excluding of one. One of the libraries had part of org.w3c.dom.* packed inside their own library (sigh) which was apparently causing the classloading issue.

                      Thanks for your replies.