javax.naming.NamingException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • When trying to obtain something from the JNDI namespace {{java:app}} or {{java:module}} during invocation of a SAM's {{validateRequest}} method an exception is thrown. However, right before the SAM is invoked, namely in a {{ServletRequestListener}} as well as right after the SAM is invoked, namely in a Filter or Servlet this operation succeeds. The exception thrown is the following: {noformat} javax.naming.NamingException: Lookup failed for 'java:module/EJBBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.naming.InitialContext.lookup(InitialContext.java:417) at test.TestServerAuthModule.validateRequest(TestServerAuthModule.java:40) at javax.security.authenticationmechanism.DefaultServerAuthContext.validateRequest(DefaultServerAuthContext.java:36) at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1654) at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1521) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:606) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:702) at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:678) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) 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:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) 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:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) 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:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745) Caused by: javax.naming.NamingException: Invocation exception: Got null ComponentInvocation at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getComponentId(GlassfishNamingManagerImpl.java:842) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:714) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471) {noformat} The lookup code is as follows: {code:java} try { // java:global/glassfish-sam-ee-namespaces/EJBBean does work EJBBean ejbBean = (EJBBean) new InitialContext().lookup("java:module/EJBBean"); System.out.println("SAM: " + ejbBean.hello()); } catch (NamingException e) { System.out.println("SAM: Exception"); e.printStackTrace(); } {code} A full reproducer is provided as Maven project at: https://github.com/arjantijms/glassfish-sam-ee-namespaces Building and deploying this project to a stock GlassFish, then requesting http://localhost:8080/glassfish-sam-ee-namespaces/servlet prints the following in the log: {noformat} RequestListener: Hello from EJB SAM: Exception javax.naming.NamingException: Lookup failed for 'java:module/EJBBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} (rest of exception as above) Servlet: Hello from EJB {noformat} Expected is: {noformat} RequestListener: Hello from EJB SAM: Hello from EJB Servlet: Hello from EJB {noformat} Deploying the same application to JBoss WildFly 9.0.1 or 10.0rc3 (with a modified standalone.xml to activate jaspic) indeed prints the above.
    via by arjan tijms,
  • Error javax.naming.NamingException
    via Stack Overflow by BoloBolo
    ,
  • javax.naming.NameNotFoundException: jms
    via Stack Overflow by g123k
    ,
    • javax.naming.NamingException: Lookup failed for 'java:module/EJBBean' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438) at javax.naming.InitialContext.lookup(InitialContext.java:417) at javax.naming.InitialContext.lookup(InitialContext.java:417) at test.TestServerAuthModule.validateRequest(TestServerAuthModule.java:40) at javax.security.authenticationmechanism.DefaultServerAuthContext.validateRequest(DefaultServerAuthContext.java:36) at com.sun.web.security.RealmAdapter.validate(RealmAdapter.java:1654) at com.sun.web.security.RealmAdapter.invokeAuthenticateDelegate(RealmAdapter.java:1521) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:606) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:702) at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:678) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) 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:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) 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:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) 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:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745) Caused by: javax.naming.NamingException: Invocation exception: Got null ComponentInvocation at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getComponentId(GlassfishNamingManagerImpl.java:842) at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:714) at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)

    Users with the same issue

    Unknown visitor1 times, last one,
    Unknown visitor2 times, last one,
    Unknown visitor1 times, last one,