【发布时间】:2016-12-26 18:39:17
【问题描述】:
我正在尝试设置 Jboss 服务器“客户端”(版本 5.1.0)以使用来自另一个 Jboss 服务器(10.90.0.91)的远程 EJB,但我无法使用Jboss 客户端。
我可以在我的客户端上使用这个简单的代码获取远程 EJB:
InitialContext ctx = null;
try {
Hashtable<String, String> jndiProps = new Hashtable<String, String>();
jndiProps.put(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiProps.put(InitialContext.PROVIDER_URL, "jnp://10.90.0.91:1099");
ctx = new InitialContext(jndiProps);
return ctx.lookup(jndiName);
} catch (NamingException e) {
throw new RuntimeException(e);
}
这很好用。
现在我想用这个属性设置 Jboss 客户端。但是,如果我编辑现有的 jndi.properties 文件,本地化为 server/{application}/conf/ 来自:
# DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING
#
java.naming.factory.initial=org.jboss.iiop.naming.ORBInitialContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
收件人:
# DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING
#
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://10.90.0.91:1099
我在启动 Jboss 客户端时收到一些错误(显然,我不知道自己在做什么 :)):
2016-08-19 10:17:41,645 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=HASessionStateService state=Create
javax.naming.NameAlreadyBoundException: Default
at org.jnp.server.NamingServer.bind(NamingServer.java:209)
at org.jnp.server.NamingServer.bind(NamingServer.java:167)
[...]
2016-08-19 10:17:42,767 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=ProfileServiceProxyFactory state=Create
javax.naming.NameAlreadyBoundException: ProfileService
at org.jnp.server.NamingServer.bind(NamingServer.java:209)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[...]
2016-08-19 10:17:44,778 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (main) Error installing to Start: name=jboss:service=ClientUserTransaction state=Create mode=Manual requiredState=Installed
javax.naming.NameAlreadyBoundException: UserTransaction
at org.jnp.server.NamingServer.bind(NamingServer.java:209)
at sun.reflect.GeneratedMethodAccessor487.invoke(Unknown Source)
[...]
在决赛中:
2016-08-19 10:17:51,993 ERROR [org.jboss.system.server.profileservice.ProfileServiceBootstrap] (main) Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
DEPLOYMENTS MISSING DEPENDENCIES:
Deployment "ProfileServiceInvocationHandler" is missing the following dependencies:
Dependency "ProfileServiceProxyFactory" (should be in state "Configured", but is actually in state "**ERROR**")
Dependency "ProfileServiceProxyFactory" (should be in state "Configured", but is actually in state "**ERROR**")
DEPLOYMENTS IN ERROR:
Deployment "jboss:service=ClientUserTransaction" is in error due to the following reason(s): javax.naming.NameAlreadyBoundException: UserTransaction
Deployment "HASessionStateService" is in error due to the following reason(s): javax.naming.NameAlreadyBoundException: Default
Deployment "ProfileServiceProxyFactory" is in error due to the following reason(s): javax.naming.NameAlreadyBoundException: ProfileService, **ERROR**
所以,我认为我无法触及该文件中已经存在的 JNDI 属性。
如果 jndi.properties 文件因为 JBoss 本身正在使用而无法更改,我可以在哪个位置将 JNDI 查找设置设置为 Jboss 5 中的远程 EJB?如何在不将 jndi.properties 文件放在我的 WAR 文件中的情况下将 jndi.properties 文件配置为在应用程序类路径中可用?
谢谢!
【问题讨论】:
-
您提到了 jboss 客户端,但我认为您的意思是 jboss 服务器。因此,您希望 server1 成为 server2 的客户端,其中 server2 提供 EJB。如果这是真的,那么我认为您不能更改 jndi.properties,因为那是针对 server1 配置的。在 server1 上运行的战争中,您需要类似于示例客户端代码的内容。您的示例客户端代码中的这些属性可以在其自己的配置文件中。
-
嗨!是的,它是一个 jboss 服务器“客户端”。一些关于Jboss的文档说在Jboss的jndi.properties中可以配置这个属性:docs.jboss.org/jbossas/docs/Server_Configuration_Guide/4/html/…
-
两台服务器都运行 JBoss AS 5.x 吗?
-
@SteveC,是的,两台服务器
标签: java jboss ejb ejb-3.0 jboss5.x