Dhe*_*rik 7 java jboss ejb jboss5.x ejb-3.0
我正在尝试设置Jboss服务器"客户端"(版本5.1.0)以使用来自另一个Jboss服务器(10.90.0.91)的远程EJB,但我不能使用Jboss客户端上的jndi.properties文件来执行此操作.
我可以在客户端上使用这个简单的代码获取远程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);
}
Run Code Online (Sandbox Code Playgroud)
这很好用.
现在我想用这个属性设置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
Run Code Online (Sandbox Code Playgroud)
至:
# 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
Run Code Online (Sandbox Code Playgroud)
当我启动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)
[...]
Run Code Online (Sandbox Code Playgroud)
在决赛中:
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**
Run Code Online (Sandbox Code Playgroud)
所以,我想我无法触及该文件中已存在的JNDI属性.
如果jndi.properties文件由于JBoss本身使用而无法更改,那么在哪个位置将我的JNDI查找设置放到Jboss 5中的远程EJB中?如何在应用程序类路径中配置jndi.properties文件,而不将jndi.properties文件放在WAR文件中?
谢谢!
org.jboss.naming.ExternalContext另一种方法是在 jboss-service.xml 文件中配置 MBean :
<mbean code="org.jboss.naming.ExternalContext"
name="jboss.jndi:service=ExternalContext,jndiName=external/server2">
<attribute name="JndiName">external/server2</attribute>
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://10.90.0.91:1099
<!-- other properties as needed -->
</attribute>
<attribute name="InitialContext"> javax.naming.IntialContext </attribute>
<attribute name="RemoteAccess">false</attribute>
</mbean>
Run Code Online (Sandbox Code Playgroud)
执行查找的 java 代码将变为:
Context initialContext = new InitialContext();
return initialContext.lookup("external/server2/" + jndiName);
Run Code Online (Sandbox Code Playgroud)
设置后,您甚至可以使用本地管理控制台中的 JNDIView 导航远程 JNDI 树。
更多信息可以在org.jboss.naming.ExternalContext MBean中找到。
| 归档时间: |
|
| 查看次数: |
815 次 |
| 最近记录: |