使用之前工作的间接JNDI找不到本地EJB Bean

问题描述 投票:0回答:1

我在多模块Maven应用程序的单独模块中使用EJB 2.1。我正在使用间接JNDI(即使用java:comp / env /未使用它)。我也是第一次使用EJB 2.1。但由于这只是一个本地简单的EJB所以没有多大问题。关于它的问题是,它正在工作,但突然没有改变任何与之相关的部分,它现在已经停止工作,我得到了NameNotFoundException。事情是正确的,因为它正在工作。我很确定。首先我的代码,

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>

来自Web模块的片段(在服务器上),我从中访问EJB方法。

    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");
    }

我的web.xml中的片段显示了ejb-ref标记

<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>

现在我的异常的堆栈跟踪(命名NotFoundException)

[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
java java-ee ejb jndi ejb-2.x
1个回答
0
投票

问题是binding.xmi文件没有包含在内。包含它并且它起作用。

© www.soinside.com 2019 - 2024. All rights reserved.