0

我在多模块 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>

我正在访问 EJB 方法的 Web 模块(在服务器上)的片段。

    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>

现在我的异常的堆栈跟踪(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
4

1 回答 1

0

问题是 binding.xmi 文件没有被包含在内。包括它,它起作用了。

于 2012-07-24T13:09:49.113 回答