glassfish
  1. glassfish
  2. GLASSFISH-20566

Deployment of a EJB fails with CDI if the bean is described by a descriptor instead of an annotation

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 4.0_b89_RC5
    • Fix Version/s: 4.1.1
    • Component/s: cdi
    • Labels:
      None
    • Environment:

      Linux

      Description

      A NP is thrown in in org.glassfish.weld.services.JCDIServiceImpl#_createJCDIInjectionContext(EjbDescriptor ejb, T instance), when a bean is being described by a deployment descriptor in the corresponding jar instead of using annotations :

      [glassfish 4.0] [SEVERE] [ejb.stateless_ejbcreate_exception]
      [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=135 _ThreadName=admin-listener(11)]
      [timeMillis: ...] [levelValue: 1000] [[EJB5070: Exception creating stateless session bean : [MyTimerBean]]]

      [glassfish 4.0] [WARNING] [ejb.system_exception] [javax.enterprise.system.container.ejb.com.sun.ejb.containers]
      [tid: _ThreadID=135 _ThreadName=admin-listener(11)] [timeMillis: ...] [levelValue: 900]
      [[ EJB5184:A system exception occurred during an invocation on EJB MyTimerBean,
      method: public void MyTimerBean.cancelAllTimers()]]

      [glassfish 4.0] [WARNING] [] [javax.enterprise.system.container.ejb.com.sun.ejb.containers]
      [tid: _ThreadID=135 _ThreadName=admin-listener(11)] [timeMillis: ...] [levelValue: 900] [[

      javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
      at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:435)
      at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2516)
      at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1906)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:204)
      at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:123)
      at com.sun.proxy.$Proxy266.cancelAllTimers(Unknown Source)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:239)
      at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150)
      at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)
      at MyTimer_DynamicStub.cancelAllTimers(_MyTimer_DynamicStub.java)
      ...
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
      at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
      at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
      at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
      at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
      at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1949)
      at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:475)
      at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)
      at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)
      at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
      at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
      at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
      at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
      at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
      at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
      at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
      at org.glassfish.deployment.admin.InstanceDeployCommand.execute(InstanceDeployCommand.java:213)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
      at java.security.AccessController.doPrivileged(Native Method)
      at javax.security.auth.Subject.doAs(Subject.java:356)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
      at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
      at org.glassfish.admin.rest.resources.admin.CommandResource.executeCommand(CommandResource.java:396)
      at org.glassfish.admin.rest.resources.admin.CommandResource.execCommandMultInMultOut(CommandResource.java:256)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:601)
      at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125)
      at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
      at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
      at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
      at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
      at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
      at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
      at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
      at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
      at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
      at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:331)
      at org.glassfish.admin.rest.adapter.JerseyContainerCommandService$3.service(JerseyContainerCommandService.java:165)
      at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:181)
      at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
      at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
      at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
      at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.portunif.PUFilter.handleRead(PUFilter.java:231)
      at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
      at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
      at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
      at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
      at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
      at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
      at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
      at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:700)
      at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:246)
      at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:430)
      ... 124 more
      Caused by: javax.ejb.CreateException: Could not create stateless EJB
      at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:514)
      at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:97)
      at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:698)
      ... 126 more
      Caused by: java.lang.reflect.InvocationTargetException
      at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1641)
      at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:456)
      ... 128 more
      Caused by: java.lang.NullPointerException
      at java.util.concurrent.ConcurrentHashMap.hash(ConcurrentHashMap.java:333)
      at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:988)
      at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:1163)
      at org.jboss.weld.manager.BeanManagerImpl.getBean(BeanManagerImpl.java:178)
      at org.glassfish.weld.services.JCDIServiceImpl._createJCDIInjectionContext(JCDIServiceImpl.java:198)
      at org.glassfish.weld.services.JCDIServiceImpl.createJCDIInjectionContext(JCDIServiceImpl.java:179)
      at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1631)
      ... 129 more
      ]]

      RootCause :

      org.glassfish.weld.services.JCDIServiceImpl#_createJCDIInjectionContext(EjbDescriptor ejb, T instance)

      org.jboss.weld.ejb.spi.EjbDescriptor ejbDesc = weldManager.getEjbDescriptor(ejb.getName());
      // Get an the Bean object
      Bean<?> bean = weldManager.getBean(ejbDesc);

      It sounds like the second experience under https://java.net/jira/browse/GLASSFISH-15888 .
      The bda only shows up beans, that are being described by annotations. It seems that the deployment descriptors are ignored.

        Activity

        sd_ created issue -
        Hide
        jjsnyder83 added a comment -

        Please attach the application with source code.

        Show
        jjsnyder83 added a comment - Please attach the application with source code.
        jjsnyder83 made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Cannot Reproduce [ 5 ]
        Hide
        jjsnyder83 added a comment -

        The reason it is failing is because the ejb classes are not in the ejb jar but are in another jar in the application's classpath. I checked with Marina and she said that the way your application is packaged is valid but the GF CDI code is written such that it expects the ejbs to be in the same jar as the ejb descriptor. I will have to think about how to fix this.

        In the mean time because this is not a cdi application you can issue the following asadmin command to disable cdi and your application will deploy without any exceptions:

        $GFHOME/bin/asadmin set configs.config.server-config.cdi-service.enable-implicit-cdi=false

        Show
        jjsnyder83 added a comment - The reason it is failing is because the ejb classes are not in the ejb jar but are in another jar in the application's classpath. I checked with Marina and she said that the way your application is packaged is valid but the GF CDI code is written such that it expects the ejbs to be in the same jar as the ejb descriptor. I will have to think about how to fix this. In the mean time because this is not a cdi application you can issue the following asadmin command to disable cdi and your application will deploy without any exceptions: $GFHOME/bin/asadmin set configs.config.server-config.cdi-service.enable-implicit-cdi=false
        jjsnyder83 made changes -
        Resolution Cannot Reproduce [ 5 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        jjsnyder83 made changes -
        Attachment JCDIServiceBugEar.ear [ 52115 ]
        tlcksnyder made changes -
        Fix Version/s 4.0.1 [ 16061 ]
        jjsnyder83 made changes -
        Assignee jjsnyder83 [ jjsnyder83 ] phil.zampino [ phil.zampino ]
        Hide
        phil.zampino added a comment -

        Removed unnecessary restriction that EJB classes be packaged in the EJB JAR in which the corresponding descriptor is packaged. Now, EJB classes packaged outside the JAR containing their descriptor will be correctly loaded.

        Committed revision 62240.

        Show
        phil.zampino added a comment - Removed unnecessary restriction that EJB classes be packaged in the EJB JAR in which the corresponding descriptor is packaged. Now, EJB classes packaged outside the JAR containing their descriptor will be correctly loaded. Committed revision 62240.
        phil.zampino made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        phil.zampino made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Hide
        phil.zampino added a comment -

        The previous fix breaks the CDI TCK. So, this issue needs to be revisited.

        Show
        phil.zampino added a comment - The previous fix breaks the CDI TCK. So, this issue needs to be revisited.
        phil.zampino made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Romain Grécourt made changes -
        Fix Version/s 4.1 [ 16387 ]
        Fix Version/s 4.0.1 [ 16061 ]
        Hide
        atrajano added a comment -

        I have encountered the same problem and I have distilled it to a smaller example code that I put into https://github.com/trajano/test/tree/nullpointer-cdi

        The scenario I have is I have described the bean Hello3Impl which implements Hello3 via ejb-jar.xml in an test-ejb which I had referenced in test-ejb2. The annotation

        @EJB
        Hello3 hello3;
        

        Does not return a null, but when executing the echo method I get an error. To test the scenario use http://localhost:8080/test-war/hello and this is the error I got

        2015-08-10T23:06:42.592-0400|Warning: StandardWrapperValve[net.trajano.test.web.HelloServlet]: Servlet.service() for servlet net.trajano.test.web.HelloServlet threw exception
        javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
        	at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:435)
        	at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2579)
        	at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1971)
        	at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:204)
        	at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
        	at com.sun.proxy.$Proxy323.echo(Unknown Source)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:239)
        	at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150)
        	at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226)
        	at net.trajano.test.api.__Hello3_Remote_DynamicStub.echo(net/trajano/test/api/__Hello3_Remote_DynamicStub.java)
        	at net.trajano.test.api._Hello3_Wrapper.echo(net/trajano/test/api/_Hello3_Wrapper.java)
        	at net.trajano.test.ejb2.HelloEjb2.echo(HelloEjb2.java:34)
        	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081)
        	at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153)
        	at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786)
        	at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656)
        	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
        	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
        	at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46)
        	at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52)
        	at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
        	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
        	at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608)
        	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
        	at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140)
        	at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source)
        	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        	at java.lang.reflect.Method.invoke(Method.java:606)
        	at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883)
        	at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822)
        	at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369)
        	at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758)
        	at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746)
        	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212)
        	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
        	at com.sun.proxy.$Proxy324.echo(Unknown Source)
        	at net.trajano.test.web.HelloServlet.doGet(HelloServlet.java:48)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
        	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
        	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
        	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
        	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
        	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
        	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
        	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
        	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
        	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415)
        	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282)
        	at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
        	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
        	at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
        	at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
        	at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
        	at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
        	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
        	at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
        	at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
        	at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
        	at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
        	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
        	at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
        	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
        	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
        	at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
        	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
        	at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
        	at java.lang.Thread.run(Thread.java:745)
        Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB
        	at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:700)
        	at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:246)
        	at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:430)
        	... 77 more
        Caused by: javax.ejb.CreateException: Could not create stateless EJB
        	at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:514)
        	at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:97)
        	at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:698)
        	... 79 more
        Caused by: java.lang.reflect.InvocationTargetException
        	at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1706)
        	at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:456)
        	... 81 more
        Caused by: java.lang.NullPointerException
        

        I did it this way rather than in "@PostConstruct" so it will allow the application to be deployed rather than failing on deployment. The code works correctly on WildFly.

        Show
        atrajano added a comment - I have encountered the same problem and I have distilled it to a smaller example code that I put into https://github.com/trajano/test/tree/nullpointer-cdi The scenario I have is I have described the bean Hello3Impl which implements Hello3 via ejb-jar.xml in an test-ejb which I had referenced in test-ejb2 . The annotation @EJB Hello3 hello3; Does not return a null , but when executing the echo method I get an error. To test the scenario use http://localhost:8080/test-war/hello and this is the error I got 2015-08-10T23:06:42.592-0400|Warning: StandardWrapperValve[net.trajano.test.web.HelloServlet]: Servlet.service() for servlet net.trajano.test.web.HelloServlet threw exception javax.ejb.EJBException: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:435) at com.sun.ejb.containers.BaseContainer.getContext(BaseContainer.java:2579) at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1971) at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:204) at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79) at com.sun.proxy.$Proxy323.echo(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:239) at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:150) at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenStubBase.invoke(CodegenStubBase.java:226) at net.trajano.test.api.__Hello3_Remote_DynamicStub.echo(net/trajano/test/api/__Hello3_Remote_DynamicStub.java) at net.trajano.test.api._Hello3_Wrapper.echo(net/trajano/test/api/_Hello3_Wrapper.java) at net.trajano.test.ejb2.HelloEjb2.echo(HelloEjb2.java:34) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1081) at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1153) at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:4786) at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:656) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608) at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:46) at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:52) at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:608) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163) at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:140) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:883) at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:822) at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:369) at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:4758) at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4746) at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:212) at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88) at com.sun.proxy.$Proxy324.echo(Unknown Source) at net.trajano.test.web.HelloServlet.doGet(HelloServlet.java:48) at javax.servlet.http.HttpServlet.service(HttpServlet.java:687) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:415) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:282) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545) at java.lang.Thread.run(Thread.java:745) Caused by: javax.ejb.EJBException: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:700) at com.sun.ejb.containers.util.pool.NonBlockingPool.getObject(NonBlockingPool.java:246) at com.sun.ejb.containers.StatelessSessionContainer._getContext(StatelessSessionContainer.java:430) ... 77 more Caused by: javax.ejb.CreateException: Could not create stateless EJB at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:514) at com.sun.ejb.containers.StatelessSessionContainer.access$000(StatelessSessionContainer.java:97) at com.sun.ejb.containers.StatelessSessionContainer$SessionContextFactory.create(StatelessSessionContainer.java:698) ... 79 more Caused by: java.lang.reflect.InvocationTargetException at com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1706) at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:456) ... 81 more Caused by: java.lang.NullPointerException I did it this way rather than in "@PostConstruct" so it will allow the application to be deployed rather than failing on deployment. The code works correctly on WildFly.
        Hide
        atrajano added a comment - - edited

        Attempting to disable CDI using bean-discovery-mode="none" does not help either.

        Show
        atrajano added a comment - - edited Attempting to disable CDI using bean-discovery-mode="none" does not help either.
        Romain Grécourt made changes -
        Fix Version/s 4.1.1 [ 17211 ]
        Fix Version/s 4.1 [ 16387 ]

          People

          • Assignee:
            phil.zampino
            Reporter:
            sd_
          • Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: