【发布时间】:2021-12-06 02:12:12
【问题描述】:
我错过了什么? 我正在尝试从独立的 java 应用程序向部署在 Jboss 6.4 EAP 中的 server-app-ear 进行远程 RMI 调用。 (我用standalone-full.xml 启动Jboss)
在我的服务器中,我在启动期间得到了这个日志记录:
07:47:56,928 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015973: Starting subdeployment (runtime-name: "se.testcompany.testapplication-server-0.0.1-SNAPSHOT.jar")
07:47:57,156 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-6) JNDI bindings for session bean named JournalCrudFacadeBean in deployment unit subdeployment "se.testcompany.testapplication-server-0.0.1-SNAPSHOT.jar" of deployment "app-0.0.1-SNAPSHOT.ear" are as follows:
java:global/app-0.0.1-SNAPSHOT/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean!se.testcompany.testapplication.rmi_interface.JournalCrudRemoteInterface
java:app/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean!se.testcompany.testapplication.rmi_interface.JournalCrudRemoteInterface
java:module/JournalCrudFacadeBean!se.testcompany.testapplication.rmi_interface.JournalCrudRemoteInterface
java:global/app-0.0.1-SNAPSHOT/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean
java:app/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean
java:module/JournalCrudFacadeBean
在我看来,我应该能够使用这些“名称”之一(可能是“全局”)“查找”JournalCrudFacadeBean,对吧?我猜“app”在同一个应用程序中很有用,而“模块”在同一个模块中是有用的,对吧?所以 global 听起来更像它。
我还在服务器中添加了一个应用程序用户“testapplication”。
来自 JournalCrudFacadeBean 的 sn-p 看起来像:
@Stateless
public class JournalCrudFacadeBean implements JournalCrudRemoteInterface {
public String create(Date date) throws RemoteException
{
String id = "A id"
System.out.println( id );
return id;
}
界面中的 sn-p 如下所示:
public interface JournalCrudRemoteInterface extends Remote
{
public String create(Date date) throws RemoteException;
在我的独立应用程序中,我拨打如下电话:
private String create()
{
String id = "Inget svar";
try
{
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
//jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.PROVIDER_URL, "remoting://localhost:4447");
jndiProperties.put("remote.connection.default.username", "testapplication");
jndiProperties.put("remote.connection.default.password", "!234qwer");
final InitialContext ctx = new InitialContext( jndiProperties );
JournalCrudRemoteInterface journalCrudRemoteInterface = (JournalCrudRemoteInterface) ctx.lookup( "java:global/app-0.0.1-SNAPSHOT/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean!se.testcompany.testapplication.rmi_interface.JournalCrudRemoteInterface" );
//JournalCrudRemoteInterface journalCrudRemoteInterface = (JournalCrudRemoteInterface) ctx.lookup( "java:global/app-0.0.1-SNAPSHOT/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean" );
id = journalCrudRemoteInterface.create(new Date());
System.out.println(id);
}
catch (Exception e)
{
id = e.getClass().getName() + " " + e.getMessage();
e.printStackTrace();
}
finally
{
}
return id;
}
在客户端我得到了这些依赖:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ rmi-client ---
[INFO] se.testcompany.testapplication:rmi-client:jar:0.0.1-SNAPSHOT
[INFO] +- org.wildfly:wildfly-naming-client:jar:1.0.14.Final:compile
[INFO] | +- org.wildfly.common:wildfly-common:jar:1.2.0.Final:compile
[INFO] | +- org.wildfly.client:wildfly-client-config:jar:1.0.0.Final:compile
[INFO] | +- org.wildfly.security:wildfly-elytron:jar:1.1.0.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | +- org.jboss.marshalling:jboss-marshalling:jar:2.0.0.Final:compile
[INFO] | +- org.jboss.marshalling:jboss-marshalling-river:jar:2.0.0.Final:compile
[INFO] | +- org.jboss.remoting:jboss-remoting:jar:5.0.0.Final:compile
[INFO] | +- org.jboss.xnio:xnio-api:jar:3.5.1.Final:compile
[INFO] | +- org.jboss.xnio:xnio-nio:jar:3.5.1.Final:compile
[INFO] | \- org.jboss.threads:jboss-threads:jar:2.2.1.Final:compile
[INFO] \- se.testcompany.testapplication:rmi-interface:jar:0.0.1-SNAPSHOT:compile
但是当我调用它时,我得到:
INFO: JBoss Remoting version 5.0.0.Final
javax.naming.NameNotFoundException: global -- service jboss.naming.context.java.jboss.exported.global
at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
各位,你们觉得我哪里做错了吗? 最好的祝福 弗雷德里克
【问题讨论】: