我遗漏了什么?我正在尝试从一个独立的java应用程序向部署在Jboss 6.4EAP中的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“在同一个app中很有用," module”在同一个模块中也是有用的,对吧?因此,全球听起来更像这样。
我还在服务器中添加了一个应用程序用户"testapplication“。
来自JournalCrudFacadeBean的代码片段如下所示:
@Stateless
public class JournalCrudFacadeBean implements JournalCrudRemoteInterface {
public String create(Date date) throws RemoteException
{
String id = "A id"
System.out.println( id );
return id;
}界面中的代码片段如下所示:
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)你们觉得怎么样,伙计们,你们看到我哪里做错了吗?向Fredrik致以最好的问候
发布于 2021-10-19 06:42:18
检查您的查找名称是否正确。您可以在Jboss的管理控制台->运行时选项卡-> JNDI视图中查看它。你的查找中有没有JNDI
java:global/app-0.0.1-SNAPSHOT/se.testcompany.testapplication-server-0.0.1-SNAPSHOT/JournalCrudFacadeBean!se.testcompany.testapplication.rmi_interface.JournalCrudRemoteInterfacehttps://stackoverflow.com/questions/69625946
复制相似问题