gpt4 book ai didi

ejb-3.0 - 从 JBoss AS 7.1.1 上的 Servlet 调用部署在 GlassFish 3.1 上的 EJB 3

转载 作者:行者123 更新时间:2023-12-02 00:17:02 32 4
gpt4 key购买 nike

我有一个简单的 session EJB(3.0 规范)部署在带有远程接口(interface)的 GlassFish 3.1 上。这是显示部署的日志片段:

INFO: Portable JNDI names for EJB RandomNumber2Bean : [java:global/RandomNumberEJB/RandomNumber2Bean, java:global/RandomNumberEJB/RandomNumber2Bean!beans.RandomNumber2]
INFO: Glassfish-specific (Non-portable) JNDI names for EJB RandomNumber2Bean : [RandomNumber2, RandomNumber2#beans.RandomNumber2]

我试图从部署在同一台机器上的 JBoss AS 7.1.1 实例上的 Servlet 调用它。这是来自 servlet 的相关代码:

Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
InitialContext initialContext = new javax.naming.InitialContext(props);
RandomNumber2 randomNumber2 = (RandomNumber2) initialContext.lookup("RandomNumber2");

但是,每当我尝试从 servlet 获取 InitialContext 以查找 bean 时,我都会收到以下错误:

javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory com.sun.enterprise.naming.SerialInitContextFactory from classloader ModuleClassLoader for Module "deployment.RandomNumberTesterGlassfish.war:main" from Service Module Loader
at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at test.RandomNumberServlet.doGet(RandomNumberServlet.java:32)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
at java.lang.Thread.run(Thread.java:722)

我已将来自 GlassFish 的客户端 jar appserv-rt.jar 和 gf-client.jar 添加到客户端 Servlet 应用程序的构建路径(我正在使用 Eclipse Juno 部署它)和 %JBOSS_HOME%\standalone\lib\ext 目录。

我在网上找不到任何提到从 JBoss AS 7.1.1 调用部署在 GlassFish 3.1 上的 EJB 的内容。在这一点上我完全不知所措。我能够使用独立客户端调用部署在 GlassFish 上的 EJB,并且能够从独立客户端和 GlassFish 调用部署在 JBoss 上的相同 EJB。

最佳答案

它写在日志中:“Glassfish 特定的(不可移植的)JNDI 名称”。所以,它可能不适用于 JBoss。试试这个:

RandomNumber2 randomNumber2 = (RandomNumber2) initialContext.lookup("java:global/RandomNumberEJB/RandomNumber2Bean");

关于ejb-3.0 - 从 JBoss AS 7.1.1 上的 Servlet 调用部署在 GlassFish 3.1 上的 EJB 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12661750/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com