-
1. Re: getTimerService() not allowed during injection (EJB3 4.5
matt10 Jan 27, 2009 5:41 AM (in response to matt10)Having reviewed the EJB3 specification (EJB3 4.5.2) and as the @Service construct is outside of the EJB3 specification, I am filing a JIRA.
Matt -
3. Re: getTimerService() not allowed during injection (EJB3 4.5
jaikiran Jan 27, 2009 10:21 AM (in response to matt10)Can you please post the entire exception stacktrace and the piece of code which is causing this?
While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted. -
4. Re: getTimerService() not allowed during injection (EJB3 4.5
matt10 Jan 27, 2009 10:46 AM (in response to matt10)Code causing exception (simplified):
@Service(objectName="mysystem:service=Application") @Local(LocalApplication.class) @Management(IServiceManagement.class) final public class Application implements LocalApplication, IServiceManagement { public void start() throws Exception { logger.info("Starting "+applicationName+" Application service"); cancelAllTimers(); initialize(); } private void cancelAllTimers() { Collection timers = getTimerService().getTimers(); for (Iterator it = timers.iterator();it.hasNext();) { Timer t = (Timer)it.next(); t.cancel(); } } private void initialize() { TimerService service = app.getTimerService(); service.createTimer(30000, 30000, "EVERY_30_SECONDS"); // ... } }
Exception stacktrace and relevant server.log:2009-01-27 10:26:11,491 INFO [org.mytoolkit.server.AbstractApplication] (main) Create MyApp Application service 2009-01-27 10:26:11,492 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: org.mytoolkit.MyApplication.application.Application ejbName: Application 2009-01-27 10:26:11,501 INFO [org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase] (main) Binding the following Entries in Global JNDI: MyApp/Application/local - EJB3.x Default Local Business Interface MyApp/Application/local-org.mytoolkit.server.LocalApplication - EJB3.x Local Business Interface 2009-01-27 10:26:11,533 INFO [org.mytoolkit.server.AbstractApplication] (main) Starting MyApp Application service 2009-01-27 10:26:11,533 INFO [org.mytoolkit.server.AbstractApplication] (main) Cancelling all timers 2009-01-27 10:26:11,545 ERROR [org.jboss.ejb3.service.ServiceContainer] (main) Encountered an error in start of Application java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.jboss.ejb3.service.ServiceContainer.invokeOptionalMethod(ServiceContainer.java:427) at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:311) at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:884) at sun.reflect.GeneratedMethodAccessor269.invoke(Unknown Source) 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:241) at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70) 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:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.system.ServiceController.doChange(ServiceController.java:688) at org.jboss.system.ServiceController.start(ServiceController.java:460) at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:146) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:104) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:45) 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:1439) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405) at org.jboss.Main.boot(Main.java:209) at org.jboss.Main$1.run(Main.java:547) 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:415) ... 53 more Caused by: java.lang.IllegalStateException: getTimerService() not allowed during injection (EJB3 4.5.2) at org.jboss.ejb3.EJBContextImpl.getTimerService(EJBContextImpl.java:175) at org.mytoolkit.server.AbstractApplication.getTimerService(AbstractApplication.java:147) at org.mytoolkit.server.AbstractApplication.cancelAllTimers(AbstractApplication.java:157) at org.mytoolkit.server.AbstractApplication.start(AbstractApplication.java:112) ... 58 more 2009-01-27 10:26:11,548 INFO [org.mytoolkit.server.AbstractApplication] (main) Stopping MyApp Application service 2009-01-27 10:26:11,557 INFO [org.jboss.ejb3.EJBContainer] (main) STOPPED EJB: org.mytoolkit.MyApplication.application.Application ejbName: Application 2009-01-27 10:26:11,557 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=Application,service=EJB3 state=Create java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at org.jboss.ejb3.service.ServiceContainer.invokeOptionalMethod(ServiceContainer.java:427) at org.jboss.ejb3.service.ServiceContainer.lockedStart(ServiceContainer.java:311) at org.jboss.ejb3.EJBContainer.start(EJBContainer.java:884) at sun.reflect.GeneratedMethodAccessor269.invoke(Unknown Source) 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:241) at org.jboss.kernel.plugins.dependency.ExecutionWrapper.execute(ExecutionWrapper.java:47) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchExecutionWrapper(KernelControllerContextAction.java:109) at org.jboss.kernel.plugins.dependency.KernelControllerContextAction.dispatchJoinPoint(KernelControllerContextAction.java:70) 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:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.system.ServiceController.doChange(ServiceController.java:688) at org.jboss.system.ServiceController.start(ServiceController.java:460) at org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:146) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:104) at org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:45) 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:1439) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178) at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210) at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098) at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348) at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598) at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062) at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822) at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553) at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781) at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.loadProfile(ProfileServiceBootstrap.java:304) at org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:205) at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:405) at org.jboss.Main.boot(Main.java:209) at org.jboss.Main$1.run(Main.java:547) 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:415) ... 53 more Caused by: java.lang.IllegalStateException: getTimerService() not allowed during injection (EJB3 4.5.2) at org.jboss.ejb3.EJBContextImpl.getTimerService(EJBContextImpl.java:175) at org.mytoolkit.server.AbstractApplication.getTimerService(AbstractApplication.java:147) at org.mytoolkit.server.AbstractApplication.cancelAllTimers(AbstractApplication.java:157) at org.mytoolkit.server.AbstractApplication.start(AbstractApplication.java:112) ... 58 more 2009-01-27 10:26:11,560 INFO [org.mytoolkit.server.AbstractApplication] (main) Destroy invoked 2009-01-27 10:26:11,561 ERROR [org.mytoolkit.common.EntityClassPool] (main) EntityClassPool does not exist on call to EntityClassPool.dispose() ----- <snip> --------- 2009-01-27 10:26:11,867 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS): *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=ApplicationInstance,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=ApplicationInstance,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=AsteriskCallStatsByDateDataset,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=AsteriskCallStatsByDateDataset,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=AsteriskIntegrationModule,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=AsteriskIntegrationModule,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=ClientsModule,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=ClientsModule,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=CoreTestModule,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=CoreTestModule,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=DailyRecentTrendsDataset,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=DailyRecentTrendsDataset,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=DebtorCallModule,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=DebtorCallModule,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **} jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=EmailAccountsModule,service=EJB3 -> <UNKNOWN jboss.j2ee:ear=MyApp.ear,jar=MyApplication.jar,name=EmailAccountsModule,service=EJB3>{Described:** UNRESOLVED Demands 'MyApplication:service=Application' **}
-
5. Re: getTimerService() not allowed during injection (EJB3 4.5
alrubinger Jan 28, 2009 2:49 AM (in response to matt10)I've commented on the JIRA.
Matt, first step is for us to bundle up the isolated code you'd posted into an integration test (just like we'd done earlier this week).
Then I'll have a look. ;)
S,
ALR -
6. Re: getTimerService() not allowed during injection (EJB3 4.5
matt10 Feb 5, 2009 7:26 AM (in response to matt10)ALR - Re. EJBTHREE-1701. (timer service not available in service start).
I recall you said you had worked around the issue.. Can I see the code change(s) you made? I need to work around this issue myself, if I can start on it I do need some advice on the correct solution.
Cheers,
Matt -
7. Re: getTimerService() not allowed during injection (EJB3 4.5
alrubinger Feb 5, 2009 9:27 PM (in response to matt10)All I did was a simple hack to see how far we could get around the problems specific to ServiceContainer:
[alrubinger@localhost trunk]$ svn di core/src/ Index: core/src/main/java/org/jboss/ejb3/EJBContextImpl.java =================================================================== --- core/src/main/java/org/jboss/ejb3/EJBContextImpl.java (revision 83875) +++ core/src/main/java/org/jboss/ejb3/EJBContextImpl.java (working copy) @@ -39,6 +39,7 @@ import org.jboss.ejb3.annotation.SecurityDomain; import org.jboss.ejb3.interceptors.container.InvocationHelper; import org.jboss.ejb3.security.helpers.EJBContextHelper; +import org.jboss.ejb3.session.SessionSpecContainer; import org.jboss.ejb3.tx.TxUtil; import org.jboss.logging.Logger; import org.jboss.security.RealmMapping; @@ -171,7 +172,7 @@ public TimerService getTimerService() throws IllegalStateException { Invocation invocation = CurrentInvocation.getCurrentInvocation(); - if(InvocationHelper.isInjection(invocation)) + if(this.getContainer() instanceof SessionSpecContainer && InvocationHelper.isInjection(invocation)) throw new IllegalStateException("getTimerService() not allowed during injection (EJB3 4.5.2)"); return getContainer().getTimerService(); }
Then started to run into problems w/ the EJB2 TimerService:Caused by: java.lang.IllegalStateException: TimerService.getTimers should not be access from this bean method: IN_EJB_CREATE at org.jboss.ejb.AllowedOperationsAssociation.assertAllowedIn(AllowedOperationsAssociation.java:158)
...which is on the chopping block anyway, to be replaced by new componentized TimerServce SPI and Impls:
https://jira.jboss.org/jira/browse/EJBTHREE-1697
S,
ALR