我需要将 .ear 部署到具有称为 GateKepper 的无状态会话 bean 的遗留 JBoss 应用程序。我正在对该应用程序的本地副本进行测试,我希望它与生产版本几乎相同。我执行查找:
protected GateKeeper lookupGateKeeper() {
String gateKeeperBeanName = null;
try {
Properties p = getClasspathProperties();
InitialContext ctx = new InitialContext(p);
gateKeeperBeanName = p.getProperty("gatekeeper.name");
return (GateKeeper) ctx.lookup( gateKeeperBeanName );
}
catch (IOException e) {
throw new GateKeeperLookupException("Gatekeeper [" + gateKeeperBeanName + "] not found.", e);
} catch (NamingException e) {
throw new GateKeeperLookupException("Gatekeeper [" + gateKeeperBeanName + "] not found.", e);
}
}
其中gatekeeperBeanName 是“com.xxxxx.mercury.GateKeeper”,这是我在下面介绍的远程和本地接口的完全限定类名,我插入的属性是 java.naming 的标准:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=jnp://localhost:1099
GateKeeper 接口(com.xxxxx.mercury.GateKeeper)上的注解是
@Remote
@Local
public interface GateKeeper {
public String processRequest(String request);
}
在应用程序启动期间,将记录以下内容:
2014-12-08 15:30:53,648 DEBUG [org.jboss.naming.NamingService] (main) !Starting jboss:service=Naming
2014-12-08 15:30:53,648 DEBUG [org.jboss.naming.NamingService] (main) !System.setProperty, key=java.naming.factory.initial, value=org.jnp.interfaces.NamingContextFactory
2014-12-08 15:30:53,648 DEBUG [org.jboss.naming.NamingService] (main) !System.setProperty, key=java.naming.factory.url.pkgs, value=org.jboss.naming:org.jnp.interfaces
2014-12-08 15:30:53,655 DEBUG [org.jboss.naming.NamingService] (main) !Creating NamingServer stub, theServer=org.jnp.server.NamingServer@5f7f84e5,rmiPort=1098,clientSocketFactory=null,serverSocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076
2014-12-08 15:30:53,711 DEBUG [org.jboss.naming.NamingService] (main) !NamingServer stub: NamingServer_Stub[UnicastRef2 [liveRef: [endpoint:[192.168.1.109:1098,org.jboss.net.sockets.DefaultSocketFactory@ad093076](local),objID:[36e9dd2d:14a282a12d7:-7fff, 5578168918392374819]]]]
2014-12-08 15:30:53,716 DEBUG [org.jboss.naming.NamingService] (main) !Started jndi bootstrap jnpPort=1099, rmiPort=1098, backlog=50, bindAddress=/0.0.0.0, Client SocketFactory=null, Server SocketFactory=org.jboss.net.sockets.DefaultSocketFactory@ad093076
2014-12-08 15:30:53,720 DEBUG [org.jboss.naming.NamingService] (main) !InitialContext Environment:
2014-12-08 15:30:53,720 DEBUG [org.jboss.naming.NamingService] (main) !key=java.naming.factory.initial, value=org.jnp.interfaces.NamingContextFactory
2014-12-08 15:30:53,720 DEBUG [org.jboss.naming.NamingService] (main) !key=java.naming.factory.url.pkgs, value=org.jboss.naming:org.jnp.interfaces:org.jboss.naming:org.jnp.interfaces
2014-12-08 15:30:53,722 DEBUG [org.jboss.naming.NamingService] (main) !Listening on port 1099
2014-12-08 15:30:53,724 DEBUG [org.jboss.naming.NamingService] (main) !Started jboss:service=Naming
所以看起来命名服务真的启动了,为什么当我尝试查找 GateKeeper 时
我得到:
com.xxxxxcorp.vas.txws.web.GateKeeperLookupException: Gatekeeper [com.xxxxx.mercury.GateKeeper] not found.
com.xxxxxcorp.vas.txws.web.TxnServlet.lookupGateKeeper(TxnServlet.java:134)
com.xxxxxcorp.vas.txws.web.TxnServlet.getGateKeeper(TxnServlet.java:119)
com.xxxxxcorp.vas.txws.web.TxnServlet.get(TxnServlet.java:66)
com.xxxxxcorp.vas.txws.web.TxnServlet.doGet(TxnServlet.java:58)
javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
显然,发生了 IOException 或 NamingException。有没有人在启动和运行命名解析时遇到困难,谁能发现我做错了什么?
编辑 如果这在任何方面都很重要,jboss-service.xml 对 NamingService 有这样的说法:
<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming"
xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
<!-- The call by value mode. true if all lookups are unmarshalled using
the caller's TCL, false if in VM lookups return the value by reference.
-->
<attribute name="CallByValue">false</attribute>
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
<attribute name="Port">1099</attribute>
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses
-->
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<!-- The port of the RMI naming service, 0 == anonymous -->
<attribute name="RmiPort">1098</attribute>
<!-- The RMI service bind address. Empty == all addresses
-->
<attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
<!-- The thread pool service used to control the bootstrap lookups -->
<depends optional-attribute-name="LookupPool"
proxy-type="attribute">jboss.system:service=ThreadPool</depends>
</mbean>
<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
</mbean>