3 Replies Latest reply on Jul 15, 2009 10:52 AM by rnicholson10

    ServiceBean and depends clause - Help Please

    rnicholson10

      Ok,

      I have a Service Bean in a jar file called: phase-input.jar

      This jar also contains a stateless timer bean (SourceBridgeCheckTimerBean). The service bean is dependent on the timer bean.

      So when deploying this jar in it's own EAR file the @ depends clause in the Service Bean looks like this:

      @Service
      @Local(InputServiceBeanLocal.class)
      @Remote(InputServiceBeanRemote.class)
      @Management(InputServiceBeanManagement.class)
      @Depends(value={"jboss.messaging.destination:service=Queue,name=phaseQueueToEngine",
       "jboss.j2ee:ear=phase-input.ear,jar=phase-input.jar,name=SourceBridgeCheckTimerBean,service=EJB3"})
      


      But this jar is supposed to be a service deployed on many different servers in different applications.

      When I create a new EAR called phase-test.ear the depends fails because the clause should now look like this:

      @Depends(value={"jboss.messaging.destination:service=Queue,name=phaseQueueToEngine",
       "jboss.j2ee:ear=phase-test.ear,jar=phase-input.jar,name=SourceBridgeCheckTimerBean,service=EJB3"})
      


      I would need to recompile phase-input.jar to change this. In fact, I would need to recompile it for every different EAR I want to add it to.

      Furthermore, the JNDI name of the local interface to SourceBridgeCheckTimerBean changes from this:

      phase-input/SourceBridgeCheckTimerBean/local
      


      to

      phase-test/SourceBridgeCheckTimerBean/local
      


      Two questions:

      1) How do I put SourceBridgeCheckTimerBean into JNDI with a common name so no matter what EAR it resides in I can call it in a common way (not another EJB, I'm calling it in a POJO so have to do a JNDI lookup)?

      2) Similarly, how do I depend on my timer bean in the Service bean no matter what EAR file it's part of?

      Note: there will only ever be one Input Service Bean on any JBoss instance.

      Or is the solution to deploy my Input service bean in it's own jar directly into the deploy directory. In this case can I access the service bean on the local interface as it's not deployed in the same ear as the application?

        • 1. Re: ServiceBean and depends clause - Help Please
          jaikiran

           

          "rnicholson10" wrote:

          1) How do I put SourceBridgeCheckTimerBean into JNDI with a common name so no matter what EAR it resides in I can call it in a common way (not another EJB, I'm calling it in a POJO so have to do a JNDI lookup)?


          You can override the default JNDI names by using the @RemoteBinding or the @LocalBinding annotations. You can even use the jboss.xml to override these. See these tutorials:
          http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/JNDI_Bindings.html

          http://www.jboss.org/file-access/default/members/jbossejb3/freezone/docs/tutorial/1.0.7/html/jboss.xml_deployment_descriptor.html


          "rnicholson10" wrote:

          I would need to recompile phase-input.jar to change this. In fact, I would need to recompile it for every different EAR I want to add it to. ...

          2) Similarly, how do I depend on my timer bean in the Service bean no matter what EAR file it's part of?

          How about adding the dependency through the jboss.xml instead of the annotations?


          • 2. Re: ServiceBean and depends clause - Help Please
            rnicholson10

            I added the following dependency using the jboss.xml file (which is in the META-INF directory in the EAR file):

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


            And with the fully qualified class name for the service bean:

            <?xml version='1.0' encoding='UTF-8' ?>
            <jboss>
             <enterprise-beans>
             <session>
             <ejb-name>com.paddypower.phase.input.bean.service.InputServiceBean</ejb-name>
             <depends>jboss.j2ee:ear=phase-test.ear,jar=phase-input.jar,name=SourceBridgeCheckTimerBean,service=EJB3</depends>
             </session>
             </enterprise-beans>
            </jboss>
            


            But neither of these seems to work. The SourceBridgeCheckTimerBean always loads after the ServiceBean which would indicate that the depends clause has no effect.

            Am I specifying the ejb-name correctly? The depends clause is specified in the same way I used in the ServiceBean previously.

            • 3. Re: ServiceBean and depends clause - Help Please
              rnicholson10

              Ok, the jboss.xml is definitely being picked up, so it must be the way I'm referencing the service bean is incorrect...

              2009-07-15 15:35:24,600 DEBUG [org.jboss.deployers.vfs.spi.deployer.JBossXBDeployerHelper] (HDScanner) Parsing file: ZipEntryHandler@12863780[path=phase-test.ear/META-INF/jboss.xml context=file:/opt/jboss-5.1.0.Beta1-jdk6/server/default/deploy/ real=file:/opt/jboss-5.1.0.Beta1-jdk6/server/default/deploy/phase-test.ear/META-INF/jboss.xml] for type: class org.jboss.metadata.ejb.jboss.JBossMetaData
              
              2009-07-15 15:35:24,635 DEBUG [org.jboss.deployers.vfs.spi.deployer.JBossXBDeployerHelper] (HDScanner) Parsed file: ZipEntryHandler@12863780[path=phase-test.ear/META-INF/jboss.xmlcontext=file:/opt/jboss-5.1.0.Beta1-jdk6/server/default/deploy/ real=file:/opt/jboss-5.1.0.Beta1-jdk6/server/default/deploy/phase-test.ear/META-INF/jboss.xml] to: org.jboss.metadata.ejb.jboss.JBoss50MetaData@1f