1

从昨天晚上开始我就在尝试这个,我们正在集成两个不同的构建,但仍然无法让所有会话 bean 查找工作。ProjectBeanRemote 位于 project.beans 包中。使用“java:global/JavaFinalProjectS-ejb ...”的查找正在使用一些 bean,但有些没有被查找。使用的持久性单元是 EclipseLink,名称是 JavaFinalProjectS-ejbPU。两种查找方式都引发了命名异常。

       public class ControlServlet extends HttpServlet {

/**
 * Processes requests for both HTTP
 * <code>GET</code> and
 * <code>POST</code> methods.
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        /*
         * TODO output your page here. You may use following sample code.
         */
        HttpSession sessObj=request.getSession();
        if(null==sessObj.getAttribute("proBeaSesObj"))
        {
            InitialContext initContObj=new InitialContext();
            Object initObj=initContObj.lookup("java:global/JavaFinalProjectS-ejb/ProjectBean");
            ProjectBeanRemote proBeaObj=(ProjectBeanRemote)
                    initContObj.lookup(ProjectBeanRemote.class.getName());
            sessObj.setAttribute("proBeaSesObj", proBeaObj);
            this.sendRequestForward(proBeaObj, request, response, out,sessObj);
        }
        else
        {
            ProjectBeanRemote proBeaObj=(ProjectBeanRemote)sessObj.getAttribute("proBeaSesObj");
            this.sendRequestForward(proBeaObj, request, response, out,sessObj);
        }
    }
    catch(Exception g)
    {
        g.printStackTrace();
    }
    finally {            
        out.close();
    }
}

这是堆栈跟踪

                SEVERE: javax.naming.NamingException: Lookup failed for 'java:global/JavaFinalProjectS-ejb/ProjectBean' 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.NameNotFoundException: ProjectBean not found]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at project.servlets.ControlServlet.processRequest(ControlServlet.java:47)
at project.servlets.ControlServlet.doPost(ControlServlet.java:96)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
             Caused by: javax.naming.NameNotFoundException: ProjectBean not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
... 32 more

SEVERE:     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518)
SEVERE:     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
SEVERE:     at javax.naming.InitialContext.lookup(InitialContext.java:411)
SEVERE:     at javax.naming.InitialContext.lookup(InitialContext.java:411)
SEVERE:     at project.servlets.ControlServlet.processRequest(ControlServlet.java:47)
SEVERE:     at project.servlets.ControlServlet.doPost(ControlServlet.java:96)
SEVERE:     at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
SEVERE:     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
SEVERE:     at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
SEVERE:     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
SEVERE:     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
SEVERE:     at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
SEVERE:     at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
SEVERE:     at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
SEVERE:     at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
SEVERE:     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
SEVERE:     at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
SEVERE:     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
SEVERE:     at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
SEVERE:     at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
SEVERE:     at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
SEVERE:     at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
SEVERE:     at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
SEVERE:     at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
SEVERE:     at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
SEVERE:     at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
SEVERE:     at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
SEVERE:     at java.lang.Thread.run(Thread.java:722)
SEVERE: Caused by: javax.naming.NameNotFoundException: ProjectBean not found
SEVERE:     at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:248)
SEVERE:     at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:215)
SEVERE:     at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
SEVERE:     at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:219)
SEVERE:     at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:77)
SEVERE:     at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:119)
SEVERE:     at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:505)
SEVERE:     ... 32 more

欢迎任何帮助,已经尝试了很多查找方法,但仍然无法全部正常工作。

4

0 回答 0