3 Replies Latest reply on Sep 20, 2011 5:19 PM by Piotr Nowicki

    Obligatory <env-entry-type> and <local> in ejb-jar.xml

    Piotr Nowicki Newbie

      Howdy!

       

      I've recently jumped from Glassfish to the AS7, and I've got two questions.

       

      1. Is the <env-entry-type> required in the AS7? Consider the following field in the EJB:

       

      @Resource(name = "from")

      private String from = "defaultFromValue";

       

      and the following ejb-jar.xml env-entry:

       

      <env-entry>

          <env-entry-name>from</env-entry-name>

          <env-entry-type>java.lang.String</env-entry-type>

          <env-entry-value>myTestMail Value</env-entry-value>

      </env-entry>

       

      The bolded fragment seems to be required, as without it the AS7 cannot determine the type of the entry. In Glassfish 3.1, the type was automatically discovered. Can't the autodiscovery also occur in case of AS7?

       

      2. Is the <local> element in the AS7 required? Consider the following interface/class structure and field declaration in the EJB:

       

      MyFacade - interface
      MyFacadeBean implements MyFacade - implementation 1 (name = "MyFacadeBean")

      MyFacadeMock implements MyFacade - implementation 2 (name = "MyFacadeMock")

       

      ----------------------

       

      @Stateless(name = "UserManagement")

      @LocalBean

      public class UserManagement extends GenericCrudBean<Integer, User> {

       

          @EJB(name = "myFacade", beanName = MyFacadeBean.EJB_NAME)

          MyFacade myFacade;

       

      Now the MyFacadeBean will be used by default because of the beanName attribute. I would like to change it using ejb-jar.xml like this:

       

      <enterprise-beans>

          <session>

                  <ejb-name>UserManagement</ejb-name>

                 

                  <!-- Change the facade implementation to mock one. -->

                  <ejb-local-ref>

                      <ejb-ref-name>myFacade</ejb-ref-name>

                      <local>com.test.business.system.boundary.MyFacade</local>

                      <ejb-link>MyFacadeMock</ejb-link>

                  </ejb-local-ref>

              </session>

      </enterprise-beans>

       

      Now on glassfish it runs fine without the bolded line. If you delete it, the JBoss AS7 will give you a sign like so:

       

      17:33:59,119 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."test.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "test.war"

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

          at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

          at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Could not determine type of ejb-local-ref java:comp/env/myFacade for component org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.unit."test.war".component.UserManagement}@ec9411

          at org.jboss.as.ejb3.deployment.processors.EjbRefProcessor.processDescriptorEntries(EjbRefProcessor.java:93)

          at org.jboss.as.ee.component.AbstractDeploymentDescriptorBindingsProcessor.deploy(AbstractDeploymentDescriptorBindingsProcessor.java:71)

          at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

          ... 5 more

       

      Now my question is - why JBoss cannot autmatically resolve the EJB reference type using the annotated field class?

       

      Thanks in advance and thanks for great work with AS7!

       

      Cheers!

        • 1. Re: Obligatory <env-entry-type> and <local> in ejb-jar.xml
          jaikiran pai Master

          Pedro Kowalski wrote:

           

          Howdy!

           

          I've recently jumped from Glassfish to the AS7, and I've got two questions.

           

          1. Is the <env-entry-type> required in the AS7? Consider the following field in the EJB:

           

          @Resource(name = "from")

          private String from = "defaultFromValue";

           

          and the following ejb-jar.xml env-entry:

           

          <env-entry>

              <env-entry-name>from</env-entry-name>

              <env-entry-type>java.lang.String</env-entry-type>

              <env-entry-value>myTestMail Value</env-entry-value>

          </env-entry>

           

          The bolded fragment seems to be required, as without it the AS7 cannot determine the type of the entry. In Glassfish 3.1, the type was automatically discovered. Can't the autodiscovery also occur in case of AS7?

           

          That env-entry-type shouldn't be required since that information can be infered from the type of the injection target (in this case the @Resource field). The spec only mandates the type if there is no injection target. Can you open a JIRA with a sample application for this please?

          • 2. Re: Obligatory <env-entry-type> and <local> in ejb-jar.xml
            jaikiran pai Master

            Pedro Kowalski wrote:

             

            Now on glassfish it runs fine without the bolded line. If you delete it, the JBoss AS7 will give you a sign like so:

             

            17:33:59,119 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."test.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."test.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "test.war"

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

                at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

                at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]

                at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

            Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Could not determine type of ejb-local-ref java:comp/env/myFacade for component org.jboss.as.ejb3.component.stateless.StatelessComponentDescription{serviceName=service jboss.deployment.unit."test.war".component.UserManagement}@ec9411

                at org.jboss.as.ejb3.deployment.processors.EjbRefProcessor.processDescriptorEntries(EjbRefProcessor.java:93)

                at org.jboss.as.ee.component.AbstractDeploymentDescriptorBindingsProcessor.deploy(AbstractDeploymentDescriptorBindingsProcessor.java:71)

                at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

                ... 5 more

             

            Now my question is - why JBoss cannot autmatically resolve the EJB reference type using the annotated field class?

             

            That looks like a bug too, please add that to the JIRA.

            • 3. Re: Obligatory <env-entry-type> and <local> in ejb-jar.xml
              Piotr Nowicki Newbie

              Exemplary application for env-entry-type (don't see how a file can be attached to Jira :/)

              JIRA: https://issues.jboss.org/browse/AS7-1876