7 Replies Latest reply on Jun 30, 2010 6:59 AM by mldv

    how to deploy a service pojo depending on ejb timer

    mldv

      I’m new to EJB3 and I’ve the following problem.

      I’m using jboss5.eap.

      I have a service POJO (annotated with org.jboss.ejb3.annotation.Depends, org.jboss.ejb3.annotation.Service, javax.ejb.Local:

      @Service

      @Local(MyInterfaceService.class)

      @Depends(“EJB Global JNDI name”)

      public class MyService implements MyInterfaceService {

       

      and I want to access a stateless EJB from the create() method of this Service POJO.

       

            @EJB

            private ITimer myEJBTimer;

      My EJB is a multiple Timer Object using the TimerService object.

       

      Deploying I get the following warning and errors:

      2010-06-23 13:03:04,080 WARN  [org.jboss.injection.EJBRemoteHandler] (main) EJBTHREE-1828: EJBInjectionContainer jboss.j2ee:ear=ear-name.ear,jar=jarname.jar,name=MyService,service=EJB3 is unconfigured, using legacy resolve

      2010-06-23 13:03:04,502 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

      DEPLOYMENTS MISSING DEPENDENCIES:

        Deployment "jboss.j2ee:ear= ear-name.ear,jar= jarname.jar,name= MyService,service=EJB3" is missing the following dependencies:

          Dependency "<UNKNOWN jboss.j2ee:ear= ear-name.ear,jar= jarname.jar,name= MyService,service=EJB3>" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'EJB Global JNDI name' **")

      I understand that my stateless EJB will not yet be bound before my Service POJO create method is called.

      I’ve tried several way of writing the annotation, with and without parameters with no success.

      Obviously if I change my code into

                  InitialContext ctx = new InitialContext();

                  myEJBTimer = (ITimer) ctx.lookup("'EJB Global JNDI name' ");

      I have no problems

      My question is: Is it possible to make my code work with annotation?

      Thanks.

      ml

        • 1. Re: how to deploy a service pojo depending on ejb timer
          jaikiran
          @Depends(“EJB Global JNDI name”)

          The value of @Depends is incorrect. It should be the MBean name of the EJB container on which you want to depend. For example:

           

          @Depends("jboss.j2ee:ear=ear-name.ear,jar=jarname.jar,name=TheTimerBean,service=EJB3")
          • 2. Re: how to deploy a service pojo depending on ejb timer
            mldv

            I’ve changed the @Depends.annotation as you suggested.

            @Depends("jboss.j2ee:ear=ear-name.ear,jar=jarname.jar,name=TheTimerBean,service=EJB3")

            I still get

            WARN  [EJBRemoteHandler] EJBTHREE-1828: EJBInjectionContainer

            I was wondering if it might depends on

            https://jira.jboss.org/browse/JBPAPP-3834?page=com.atlassian.jirafisheyeplugin%3Afisheye-issuepanel

             

            thanks

            • 3. Re: how to deploy a service pojo depending on ejb timer
              jaikiran

              Is it just the WARN message or do you see any error or exception stacktraces?

              • 4. Re: how to deploy a service pojo depending on ejb timer
                mldv

                I see the following error :

                 

                09:47:26,750 ERROR [AbstractKernelController] Error installing to Create: name=jboss.j2ee:ear=ear-name.ear,jar=jarname.jar,name=MyService,service=EJB3 state=Configured

                java.lang.RuntimeException: java.lang.reflect.InvocationTargetException

                        at org.jboss.ejb3.service.ServiceContainer.invokeOptionalMethod(ServiceContainer.java:406)

                        at org.jboss.ejb3.service.ServiceContainer.create(ServiceContainer.java:206)

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                        at java.lang.reflect.Method.invoke(Method.java:597)

                        at org.jboss.reflect.plugins.introspection.ReflectionUtils.invoke(ReflectionUtils.java:59)

                        at org.jboss.reflect.plugins.introspection.ReflectMethodInfoImpl.invoke(ReflectMethodInfoImpl.java:150)

                        at org.jboss.joinpoint.plugins.BasicMethodJoinPoint.dispatch(BasicMethodJoinPoint.java:66)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction$JoinpointDispatchWrapper.execute(KernelControllerContextAction.java:243)

                        at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:111)

                        at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:72)

                        at org.jboss.kernel.plugins.dependency.LifecycleAction.installActionInternal(LifecycleAction.java:221)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:54)

                        at org.jboss.kernel.plugins.dependency.InstallsAwareAction.installAction(InstallsAwareAction.java:42)

                        at org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)

                        at org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)

                        at org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:775)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:121)

                        at org.jboss.deployers.vfs.deployer.kernel.BeanMetaDataDeployer.deploy(BeanMetaDataDeployer.java:51)

                        at org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)

                        at org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)

                        at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1440)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1158)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1179)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1211)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1099)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:823)

                        at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)

                        at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:782)

                        at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)

                        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)

                        at org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:403)

                        at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1633)

                        at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:935)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1083)

                        at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:985)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:775)

                        at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:540)

                        at org.jboss.system.server.profileservice.repository.AbstractProfileService.registerProfile(AbstractProfileService.java:308)

                        at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:256)

                        at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)

                        at org.jboss.Main.boot(Main.java:221)

                        at org.jboss.Main$1.run(Main.java:556)

                        at java.lang.Thread.run(Thread.java:619)

                Caused by: java.lang.reflect.InvocationTargetException

                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                        at java.lang.reflect.Method.invoke(Method.java:597)

                        at org.jboss.ejb3.service.ServiceContainer.invokeOptionalMethod(ServiceContainer.java:394)

                        ... 61 more

                Caused by: java.lang.NullPointerException

                        at MyService.create(MyService.java:39)

                        ... 66 more

                09:47:27,313 INFO  [ProfileServiceBootstrap] Loading profile: ProfileKey@13864b2[domain=default, server=default,]

                09:47:27,313 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

                 

                DEPLOYMENTS IN ERROR:

                  Deployment "jboss.j2ee:ear=ear-name.ear,jar=jarname.jar,name=MyService,service=EJB3" is in error due to the following reason(s): java.lang.NullPointerException

                 

                09:47:27,360 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080

                09:47:27,422 INFO  [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009

                09:47:27,422 INFO  [ServerImpl] JBoss (Microcontainer) [5.0.0.GA (build: SVNTag=JBPAPP_5_0_0_GA date=200910202128)] Started in 50s:223ms

                 

                 

                 

                thanks

                • 5. Re: how to deploy a service pojo depending on ejb timer
                  jaikiran

                  The NullPointerException is coming from your code:

                   

                  Caused by: java.lang.NullPointerException

                          at  MyService.create(MyService.java:39)

                   

                  So you'll have to see what's wrong with line 39 of that class in your application.

                  • 6. Re: how to deploy a service pojo depending on ejb timer
                    mldv

                    on line 39 there is a call to the ejb method for the creation of the timer (ctx.getTimerService().createTimer)

                     

                    with the lookup of the EJB the same code give me no problem.

                     

                    @Service

                    @Local(MyInterfaceService.class)

                    @Depends("jboss.j2ee:ear=earname.ear,jar=jarname.jar,name=TheTimerBean,service=EB3")

                    public class MyService implements MyInterfaceService {

                    @EJB

                    private ITimer myEJBTimer;

                     

                    @Override

                    public void create() throws Exception {

                    line 39           myEJBTimer.attiva();

                          }

                     

                    }

                     

                    thanks

                    • 7. Re: how to deploy a service pojo depending on ejb timer
                      mldv

                      Here is the code of my stateless EJB

                      My EJB is a multiple Timer Object using the TimerService object.

                       

                      @Stateless

                      @Local(ITimer.class)

                      public class TheTimerBean implements ITimer {

                       

                       

                            @Resource

                            private SessionContext ctx;

                       

                            @Override

                            public void attiva() {

                                  ctx.getTimerService().createTimer(1 * 1000, 1 * 1000, null);

                       

                            }

                       

                            @Timeout

                            public void timeOutMethod(Timer timer) {

                                  …

                            }

                       

                      }

                      Thanks