[webbeans-issues] [JBoss JIRA] Commented: (WBRI-329) NPE in org.jboss.webbeans.ejb.SessionBeanInterceptor @PostConstruct

Pete Muir (JIRA) jira-events at lists.jboss.org
Thu Aug 6 07:36:29 EDT 2009


    [ https://jira.jboss.org/jira/browse/WBRI-329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12479230#action_12479230 ] 

Pete Muir commented on WBRI-329:
--------------------------------

Ken,

In the example you give, I would expect an EJB container to inject foo, bar and call init(). I would expect the EJB container to request 299 injection for the object (either directly via the 299 SPI or indirectly via the app server - this depends on the architecture of the app server and and EJB container), which would cause em to be injected. However, I notice that the spec says that "First, the container performs Java EE component environment injection according to the semantics required by the Java EE platform specification.". In this case, "the container" refers to the Java EE container, not the 299 container specifically, so I propose adding a method to the Web Beans SPI that enables you to toggle the EE injection on/off depending on whether you want Web Beans to perform this injection on EE component classes. WDYT?

Specifically, you would use InjectionTarget SPI:

InjectionTarget it = beanManager.createInjectionTarget(beanManager.createAnnotatedType(ejbBeanClass));
it.inject(ejbBeanInstance, beanManager.createCreationalContext(null));

As EJB will call @PostConstruct/@PreDestroy itself I would continue with this scheme. If you were dealing with a non-contextual instance which doesn't support calling these lifecycle callbacks, you would need to call

it.postConstruct(instance);
it.preDestroy(instance);

to have the callbacks called.

> NPE in org.jboss.webbeans.ejb.SessionBeanInterceptor @PostConstruct
> -------------------------------------------------------------------
>
>                 Key: WBRI-329
>                 URL: https://jira.jboss.org/jira/browse/WBRI-329
>             Project: Web Beans
>          Issue Type: Bug
>          Components: Enterprise Beans, Glassfish integration
>         Environment: 1.0.0.PREVIEW2.SP2 in 7/30/09 GlassFish V3 workspace
>            Reporter: Ken Saks
>
> SessionBeanInterceptor @PostConstruct is throwing an NPE when the ejb container creates an instance of any session bean component type.   The trace below is for a Singleton.   These are all cases where there is no 299-specific interaction that causes the bean instance creation.   It's just the ejb container creating the instance through some other path , e.g. to eagerly instantiate the Singleton during application startup or to resolve a direct JNDI lookup() from some application code.   I haven't tried a stateful session bean creation via 299-apis or injection yet.  
> SessionBeanInterceptor.initBean() first calls  (EnterpriseBean<Object>) EnterpriseBeanProxyMethodHandler.getEnterpriseBean(), which returns null. 
>  It then calls (EnterpriseBean<Object>) CurrentManager.rootManager().getNewEnterpriseBeanMap().get(beanClass), which also returns null.   That leads to the NPE on the line "this.beanId = this.bean.getId();"   
> SEVERE: Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
> javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton SimpleSingleton
> 	at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:689)
> 	at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:432)
> 	at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:93)
> 	at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:62)
> 	at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:138)
> 	at org.glassfish.internal.data.EngineRef.start(EngineRef.java:126)
> 	at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:223)
> 	at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:193)
> 	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:290)
> 	at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:174)
> 	at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:270)
> 	at com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:422)
> 	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:437)
> 	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:524)
> 	at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:140)
> 	at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:313)
> 	at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:180)
> 	at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
> 	at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
> 	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:208)
> 	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:752)
> 	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:660)
> 	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:911)
> 	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:164)
> 	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
> 	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
> 	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
> 	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
> 	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
> 	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
> 	at com.sun.grizzly.NIOContext.execute(NIOContext.java:510)
> 	at com.sun.grizzly.SelectorHandlerRunner.handleSelectedKey(SelectorHandlerRunner.java:357)
> 	at com.sun.grizzly.SelectorHandlerRunner.handleSelectedKeys(SelectorHandlerRunner.java:257)
> 	at com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:194)
> 	at com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:129)
> 	at com.sun.grizzly.util.FixedThreadPool$BasicWorker.dowork(FixedThreadPool.java:379)
> 	at com.sun.grizzly.util.FixedThreadPool$BasicWorker.run(FixedThreadPool.java:360)
> 	at java.lang.Thread.run(Thread.java:637)
> Caused by: javax.ejb.CreateException: Initialization failed for Singleton SimpleSingleton
> 	at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:521)
> 	at com.sun.ejb.containers.AbstractSingletonContainer.access$100(AbstractSingletonContainer.java:70)
> 	at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:687)
> 	... 37 more
> Caused by: java.lang.NullPointerException
> 	at org.jboss.webbeans.ejb.SessionBeanInterceptor.initBean(SessionBeanInterceptor.java:110)
> 	at org.jboss.webbeans.ejb.SessionBeanInterceptor.postConstruct(SessionBeanInterceptor.java:62)
> 	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 com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:939)
> 	at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:61)
> 	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:372)
> 	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:355)
> 	at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:514)
> 	... 39 more

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the weld-issues mailing list