7 Replies Latest reply on Jun 3, 2011 9:45 AM by kirillica

    EJB3 bound problem in JBoss AS 6

    kirillica

      Hello guys,

       

      I'm about to migrate from JBoss 5.1 to JBoss 6.0 (need to move to JSF2, RichFaces 4 and etc) and here is a list of problems I have with EJB3:

      1) during startup EJB were unable to bound (if EJB is in separate jar). This was fixed adding mappedName in annotation (and bug ticket says this will be fixed in version 7).

       

      OK, with additional parameter this seems to be working:

       

      11:55:51,038 INFO  [org.jboss.ejb3.deployers.JBossASKernel] installing bean: jboss.j2ee:ear=MyApplication.ear,jar=MyBusiness.jar,name=SomeBeanDAOImpl,service=EJB3

      11:55:51,038 INFO  [org.jboss.ejb3.deployers.JBossASKernel]   with dependencies:

      11:55:51,038 INFO  [org.jboss.ejb3.deployers.JBossASKernel]   and demands:

      11:55:51,038 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jboss.ejb:service=EJBTimerService; Required: Described

      11:55:51,038 INFO  [org.jboss.ejb3.deployers.JBossASKernel]                 persistence.unit:unitName=MyApplication.ear/MyBusiness.jar#My; Required: Described

      11:55:51,039 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jboss-switchboard:appName=MyApplication,module=MyBusiness,name=SomeBeanDAOImpl; Required: Create

      11:55:51,039 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jboss-injector:topLevelUnit=MyApplication.ear,unit=MyBusiness.jar,bean=SomeBeanDAOImpl; Required: Described

      11:55:51,040 INFO  [org.jboss.ejb3.deployers.JBossASKernel]   and supplies:

      11:55:51,040 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jndi:SomeBeanDAOImpl

      11:55:51,040 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jndi:MyApplication/SomeBeanDAOImpl/local-ee.helmes.My.business.dao.SomeBeanDAO

      11:55:51,040 INFO  [org.jboss.ejb3.deployers.JBossASKernel] Class:ee.helmes.My.business.dao.SomeBeanDAO

      11:55:51,040 INFO  [org.jboss.ejb3.deployers.JBossASKernel] jndi:MyApplication/SomeBeanDAOImpl/local

      11:55:51,041 INFO  [org.jboss.ejb3.deployers.JBossASKernel] Added bean(jboss.j2ee:ear=MyApplication.ear,jar=MyBusiness.jar,name=SomeBeanDAOImpl,service=EJB3) to KernelDeployment of: MyBusiness.jar

       

       

      2) But still cannot be injected into beans:

       

      @EJB( mappedName="SomeBeanDAOImpl/local", beanInterface=SomeBeanDAO.class)

      protected SomeBeanDAO dao;

       

      (I've tried context.lookup with different variants and no help)

       

      It says:

       

      Caused by: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: SomeBeanDAOImpl not bound]

      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:87)

      at org.jboss.injection.manager.core.DefaultInjectionContext.proceed(DefaultInjectionContext.java:58)

      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:58)

      at org.jboss.injection.manager.core.DefaultInjectionManager.inject(DefaultInjectionManager.java:64)

      at org.jboss.web.tomcat.service.TomcatInjectionContainer.processInjectors(TomcatInjectionContainer.java:410)

      at org.jboss.web.jsf.integration.injection.JBossDelegatingInjectionProvider.inject(JBossDelegatingInjectionProvider.java:77)

      ... 46 more

      Caused by: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: SomeBeanDAOImpl not bound]

      at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1356)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:819)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:835)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

      at javax.naming.InitialContext.lookup(InitialContext.java:392)

      at org.jboss.injection.injector.EEInjector.lookup(EEInjector.java:153)

      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:133)

      at org.jboss.injection.injector.EEInjector.inject(EEInjector.java:82)

      ... 51 more

      Caused by: javax.naming.NameNotFoundException: SomeBeanDAOImpl not bound

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

      at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)

      at org.jnp.server.NamingServer.getObject(NamingServer.java:785)

      at org.jnp.server.NamingServer.lookup(NamingServer.java:396)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:728)

      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:688)

      at javax.naming.InitialContext.lookup(InitialContext.java:392)

      at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:1350)

      ... 58 more

       

      So what is wrong with JBoss 6.0 comparing to JBoss 5.1 where things were working this way?

       

      P.S.

       

      Interface for EJB:

       

      @Local

      public interface SomeBeanDAO extends DataTableDAO

       

      Bean:

       

      @SecurityDomain(<...>)

      @Stateless

      public class SomeBeanDAOImpl extends DAOImplBase implements SomeBeanDAO

        • 1. Re: EJB3 bound problem in JBoss AS 6
          kirillica

          Hello guys,

           

          It looks like noone knows how to make EJB3 work in JBoss6 final? ))

          • 2. Re: EJB3 bound problem in JBoss AS 6
            jaikiran

            Which EJB is injecting that @EJB SomeBeanDAO? What kind of bean is that? Can you please post the exact code?

            • 3. Re: EJB3 bound problem in JBoss AS 6
              kirillica

              It's an ordinary bean (page) in JSF application. Say, ordinary class.

              • 4. Re: EJB3 bound problem in JBoss AS 6
                jaikiran

                Please post that code.

                • 5. Re: EJB3 bound problem in JBoss AS 6
                  kirillica

                  As it was said, it has nothing special:

                   

                  for example:

                   

                   

                   

                   

                   

                   

                   

                   

                  @Management

                   

                  (DistanceCalculationScheduleMBean.class

                  )

                  @Service

                   

                  (name = DistanceCalculationSchedule.SERVICE_NAME

                  )

                  public

                   

                  class SomeSchedule extends ServiceMBeanSupport implements

                  SomeScheduleMBean {

                   

                  public final static String SERVICE_NAME = "SomeSchedule"

                  ;

                   

                   

                  @EJB

                   

                  private SomeDAO someDao

                   

                  or:

                   

                   

                   

                   

                   

                   

                   

                   

                  public

                   

                  class

                  BeanBase {

                   

                   

                  @EJB

                   

                  protected SomeDao SomeDao

                  ;

                  ;

                   

                   

                   

                  it works in none of the variants (scheduled service or JSF page)

                  • 6. Re: EJB3 bound problem in JBoss AS 6
                    jaikiran

                    Kirill Linnik wrote:

                     

                    As it was said, it has nothing special:

                     

                    for example:

                       

                     

                     

                     

                    @Management

                     

                    (DistanceCalculationScheduleMBean.class

                    )

                    @Service

                     

                    (name = DistanceCalculationSchedule.SERVICE_NAME

                    )

                    public

                     

                    class SomeSchedule extends ServiceMBeanSupport implements

                    SomeScheduleMBean {

                     

                    It is special. You said it was a ordinary bean (page) in JSF application. It isn't. It is a (JBoss specific) @Service EJB which gets triggered on application startup. And it's getting triggered before the other bean is bound into JNDI. The fix would be to remove the "mappedName" from the @EJB so that the container can setup the correct dependencies. But as you say, leaving out the mappedName won't allow injecting a bean from a different deployment.

                     

                    You can explicitly add a @org.jboss.ejb3.annotationDepends on the SomeSchedule bean to depend on the SomeDAOBean.

                    • 7. Re: EJB3 bound problem in JBoss AS 6
                      kirillica

                      Dear jaikiran pai,

                       

                      It doesn't work in both cases: service and JSF.

                       

                      P.S. Depends annotation has no influence at all.