abhihello123
abhihello123

Reputation: 1728

Local EJB Bean Not Found using Indirect JNDI which was working earlier

I am using EJB 2.1 in a separate module in a multi-module Maven Application. I am using indirect JNDI (ie. using java:comp/env/ Not used it much). Also I am using EJB 2.1 for the first time. But since this is only a local simple EJB so not much problem. The wiered bit about it is that it was working but suddenly without having changed any part relevant to it, it has stopped working now and I am getting NameNotFoundException. The things are done correctly as it was working. I am pretty sure about it. First my code,

ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
    <display-name>sr-g0a-ejb</display-name>
    <enterprise-beans>
        <session id="CreateAclService">
            <ejb-name>CreateAclService</ejb-name>
            <local-home>com.sre.g0a.CreateAclServiceLocalHome</local-home>
            <local>com.sre.g0a.CreateAclServiceLocal</local>
            <ejb-class>com.sre.g0a.CreateAclServiceBean</ejb-class>
            <session-type>Stateless</session-type>
            <transaction-type>Container</transaction-type>
            <security-identity>
                <description></description>
                <run-as>
                    <description></description>
                    <role-name>ACL_TECH_USER</role-name>
                </run-as>
            </security-identity>
        </session>
    </enterprise-beans>
    <assembly-descriptor>
        <security-role>
            <description>
            ACL_TECH_USER</description>
            <role-name>ACL_TECH_USER</role-name>
        </security-role>
        <method-permission>
            <role-name>ACL_TECH_USER</role-name>
            <method>
                <ejb-name>CreateAclService</ejb-name>
                <method-intf>Local</method-intf>
                <method-name>createAclRole</method-name>
                <method-params>
                    <method-param>com.sre.edms.bsc.types.EDMSAcl</method-param>
                    <method-param>com.sre.edms.bsc.ids.EDMSDocumentID</method-param>
                </method-params>
            </method>
        </method-permission>
        <container-transaction>
            <method>
                <ejb-name>CreateAclService</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>NotSupported</trans-attribute>
        </container-transaction>
    </assembly-descriptor>
</ejb-jar>

The Snippet from the web module (on the server) where from I am accessing the EJB method.

    Hashtable<String, String> hashTable = new Hashtable<String, String>();
    hashTable.put(Context.INITIAL_CONTEXT_FACTORY,
    "com.ibm.websphere.naming.WsnInitialContextFactory");
    //hashTable.put(Context.PROVIDER_URL, "corbaloc:iiop:localhost:9080");
    Context initialContext;
    try {
        initialContext = new InitialContext(hashTable);
        CreateAclServiceLocalHome home = (CreateAclServiceLocalHome) initialContext
        .lookup("java:comp/env/ejb/CreateAclService");
        //.lookup("ejblocal:ejb/CreateAclServiceLocal");
        CreateAclServiceLocal service = home.create();
        eDMSAcl = service.createAclRole(eDMSAcl, edmsDocumentID);
    } catch (NamingException ne) {
        LOGGER.log(Level.WARNING, "NamingException Occured", ne);
        throw new GEMException("Failed to create ACL. NamingException Occured");
    } catch (CreateException ce) {
        LOGGER.log(Level.WARNING, "CreateException Occured", ce);
        throw new GEMException("Failed to create ACL");
    } catch (BscServiceException be) {
        LOGGER.log(Level.WARNING, "BscServiceException Occured", be);
        throw new GEMException("Failed to create ACL");
    }

Snippet from my web.xml which shows the ejb-ref tag

<ejb-local-ref id="EJBLocalRef_1343037878938">
    <description>
    </description>
    <ejb-ref-name>ejb/CreateAclService</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.sre.g0a.CreateAclServiceLocalHome</local-home>
    <local>com.sre.g0a.CreateAclServiceLocal</local>
    <ejb-link>sr-g0a-ejb.jar#CreateAclService</ejb-link>
</ejb-local-ref>

Now the stacktrace of my Exception (NamingNotFoundException)

[7/24/12 12:34:26:629 IST] 00001720 GEMEBesUtil   W   NamingException Occured
                                 com.ibm.websphere.naming.CannotInstantiateObjectException: A NameNotFoundException occurred on an indirect lookup on the name java:comp/env/ejb/CreateAclService. The name java:comp/env/ejb/CreateAclService maps to a JNDI name in deployment descriptor bindings for the application performing the JNDI lookup. Make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context.  [Root exception is javax.naming.NameNotFoundException: Name ejb not found in context "ejblocal:".]
    at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1081)
    at com.ibm.ws.naming.urlbase.UrlContextHelper.processBoundObjectForLookup(UrlContextHelper.java:181)
    at com.ibm.ws.naming.java.javaURLContextRoot.processBoundObjectForLookup(javaURLContextRoot.java:850)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1454)
    at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
    at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)
    at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)
    at com.sre.g0a.server.util.GEMEBesUtil.createEDMSAcl(GEMEBesUtil.java:250)
    at com.sre.g0a.server.util.GEMEBesUtil.formSrGemDocForCreation(GEMEBesUtil.java:180)
    at com.sre.g0a.server.services.ImportComponentServiceImpl.createDocument(ImportComponentServiceImpl.java:65)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
    at java.lang.reflect.Method.invoke(Method.java:611)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:551)
    at com.sre.g0a.server.integration.GWTSpringController.processCall(GWTSpringController.java:57)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1188)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:763)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:454)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1020)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
    at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Caused by: javax.naming.NameNotFoundException: Name ejb not found in context "ejblocal:".
    at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1969)
    at com.ibm.ws.naming.ipbase.NameSpace.retrieveBinding(NameSpace.java:1376)
    at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1219)
    at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1141)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1425)
    at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1475)
    at com.ibm.ws.naming.util.IndirectJndiLookupObjectFactory$1.run(IndirectJndiLookupObjectFactory.java:373)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ws.naming.util.IndirectJndiLookupObjectFactory.getObjectInstanceExt(IndirectJndiLookupObjectFactory.java:223)
    at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:990)
    ... 44 more

Upvotes: 0

Views: 9563

Answers (1)

abhihello123
abhihello123

Reputation: 1728

The problem was the binding.xmi file was not getting included. Included that and it worked.

Upvotes: 0

Related Questions