9 Replies Latest reply on Oct 14, 2009 10:37 AM by Ross Nicholson

    Setup dependencies within an EAR

    Ross Nicholson Apprentice

      I have an ear file file containing 2 ejb-jars and one war.

      Here's my application.xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <application xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="5"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/application_5.xsd">
       <display-name>PHASE Test</display-name>
      
       <module>
       <web>
       <web-uri>phase-test.war</web-uri>
       <context-root>/phase-test</context-root>
       </web>
       </module>
      
       <module>
       <ejb>phase-test.jar</ejb>
       </module>
      
       <module>
       <ejb>phase-input.jar</ejb>
       </module>
      
       <library-directory>lib</library-directory>
      
      </application>
      


      What I want to do is make both the war and phase-test.jar dependent on phase-input.jar. If phase-input.jar does not load correctly the ear should not deploy. Specifically there is a ServiceBean in phase-input.jar that I want to depend on.

      Currently the application will deploy (ear) whether or not phase-input.jar starts correctly. I'm finding it hard to find reference information on how to do this. I have a jboss-app.xml in my EAR, but most of the stuff on the web talks about jboss.xml without too much info on how exactly to set it up correctly.

      Any help would be greatly appreciated.

      Cheers,

      R.

        • 1. Re: Setup dependencies within an EAR
          jaikiran pai Master

           

          "rnicholson10" wrote:
          Specifically there is a ServiceBean in phase-input.jar that I want to depend on.


          That bean will have a MBean name corresponding to it. The jmx-console will help you in finding that name. Once you know that MBean ObjectName, just add a

          <depends>ThatMBeanObjectName</depends>


          in the META-INF/jboss.xml of phase-test.jar and add the same in the WEB-INF/jboss-web.xml of the .war file.



          • 2. Re: Setup dependencies within an EAR
            Ross Nicholson Apprentice

            Brilliant.

            One further question:

            I don't have either of those files for my jar or war. It's a seam application. I do have a jboss-app.xml in the jar though.

            Are the jboss.xml and jboss-web.xml optional files that are only read if their there? Can I just create them in the required format with only a depends clause?

            Thanks again,

            Ross

            • 3. Re: Setup dependencies within an EAR
              jaikiran pai Master

               

              "rnicholson10" wrote:
              I do have a jboss-app.xml in the jar though.

              I assume that's a typo and you actually meant jboss-app.xml the EAR?

              "rnicholson10" wrote:

              Are the jboss.xml and jboss-web.xml optional files that are only read if their there?

              Yes, that's correct.

              "rnicholson10" wrote:

              Can I just create them in the required format with only a depends clause?


              Yes, that's correct again. Only a depends clause should be enough. And remember, each of these has a different location in the .jar and .war, see my previous post for details.


              • 5. Re: Setup dependencies within an EAR
                Ross Nicholson Apprentice

                I spoke too soon!

                The jboss-web.xml is perfect so the war is sorted:

                <?xml version="1.0" encoding="UTF-8"?>
                <jboss-web>
                 <depends>jboss.j2ee:ear=phase-test.ear,jar=phase-input.jar,name=InputServiceBean,service=EJB3</depends>
                </jboss-web>
                


                But the jboss.xml is not quite right.

                <?xml version="1.0" encoding="UTF-8"?>
                <jboss>
                 <depends>jboss.j2ee:ear=phase-test.ear,jar=phase-input.jar,name=InputServiceBean,service=EJB3</depends>
                </jboss>
                


                And has the following error:

                Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: depends not found as a child of jboss in unordered_sequence: webservices? resource-managers? jmx-name? unauthenticated-principal? enforce-ejb-restrictions? container-configurations? assembly-descriptor? loader-repository? security-domain? exception-on-rollback? enterprise-beans* invoker-proxy-bindings? missing-method-permissions-excluded-mode?
                


                I can't tell from the DTD how this should be setup.


                • 6. Re: Setup dependencies within an EAR
                  Wolfgang Knauf Master

                  Hi,

                  the "depends" in jboss.xml can only be specified on bean level. Here is a sample for a session bean depending on something else:

                  <jboss ...>
                   <enterprise-beans>
                   <session>
                   <ejb-name>...</ejb-name>
                   <depends>...</depends>
                   </session>
                   </enterprise-beans>
                  </jboss>


                  Best regards

                  Wolfgang

                  • 7. Re: Setup dependencies within an EAR
                    Ross Nicholson Apprentice

                    Ok, but what if I both my ejbs are ServiceBeans?

                    I've tried adding the service element but I get another error stating that is not a choice under enterprise-beans... It should be because I checked the Schema.

                    Runnign 5.1.0.GA.

                    <?xml version="1.0" encoding="UTF-8"?>
                    <jboss>
                     <enterprise-beans>
                     <service>
                     <ejb-name>TestServiceBean</ejb-name>
                     <depends>jboss.j2ee:ear=phase-test.ear,jar=phase-input.jar,name=InputServiceBean,service=EJB3</depends>
                     </service>
                     </enterprise-beans>
                    </jboss>
                    


                    Error:

                    Caused by: org.jboss.xb.binding.JBossXBRuntimeException: service not found as a child of enterprise-beans in sequence: {choice}*
                    




                    • 8. Re: Setup dependencies within an EAR
                      jaikiran pai Master

                      Add the xsd declaration to the xml:

                      <?xml version="1.0"?>
                      <jboss
                       xmlns="http://www.jboss.com/xml/ns/javaee"
                       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                       xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
                       http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
                       version="3.0">
                      ...
                      


                      • 9. Re: Setup dependencies within an EAR
                        Ross Nicholson Apprentice

                        Brilliant, a big thanks to the both of you!