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 ]

Java.net JIRA | arjan tijms | 1 year ago
  1. 0

    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.

    Java.net JIRA | 1 year ago | arjan tijms
    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 ]
  2. 0

    JDBCRealm authentication works with Servlet @WebFilter but throws NamingEcception when using security constraint in web.xml

    Stack Overflow | 2 years ago | Sheba
    javax.security.auth.login.LoginException: Unable to connect to datasource java:app/jdbc/sampleresource for database user null.
  3. 0

    why does the javax.naming.NamingException occur here?

    Stack Overflow | 5 years ago | Suhail Gupta
    javax.naming.NamingException: Lookup failed for 'java:comp/env/jdbc/photog' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    code throws an exception when i directly run the helper class

    Stack Overflow | 5 years ago | Suhail Gupta
    javax.naming.NamingException: Lookup failed for 'java:comp/env/jdbc/photog' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]
  6. 0

    Error javax.naming.NamingException

    Stack Overflow | 6 years ago | BoloBolo
    javax.naming.NamingException: Lookup failed for 'java:comp/env' in SerialContext [Root exception is javax.naming.NamingException: Invocation exception: Got null ComponentInvocation ]

    20 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.naming.NamingException

      Invocation exception: Got null ComponentInvocation

      at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getComponentId()
    2. Glassfish Naming
      SerialContext.lookup
      1. com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.getComponentId(GlassfishNamingManagerImpl.java:842)
      2. com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:714)
      3. com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:167)
      4. com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)
      4 frames