gpt4 book ai didi

java - Wildfly 远程 EJB 调用

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:54:40 27 4
gpt4 key购买 nike

我正在尝试调用部署在远程服务器上的无状态 EJB。我可以从本地 JBoss 环境调用 bean,但是当我将 remote.connection.default.host 更改为远程机器的主机时,我的客户端代码不起作用。

这是我的jboss-ejb-client.properties:

endpoint.name=client-endpoint

remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false

remote.connections=default

remote.connection.default.host=SERVERIP/HOSTNAME
remote.connection.default.port=8080
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=username
remote.connection.default.password=Password

我的客户端代码如下所示:

Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
String jndi = "jndi_name";
Context context = new InitialContext(properties);
obj = context.lookup(jndi);

请帮忙。

谢谢大家。 jack 。

最佳答案

这个答案可能晚了,但我遇到了同样的问题,以上答案都没有帮助我,要解决这个问题,请引用以下内容:http://blog.jonasbandi.net/2013/08/jboss-remote-ejb-invocation-unexpected.html

适用于我的代码如下:

Properties jndiProperties=new Properties();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put(Context.PROVIDER_URL, "http-remoting://127.0.0.1:8080/");
//This property is important for remote resolving
jndiProperties.put("jboss.naming.client.ejb.context", true);
//This propert is not important for remote resolving
jndiProperties.put("org.jboss.ejb.client.scoped.context", "true");

Context context=new InitialContext(jndiProperties);


/*
java:global/JEETest_Project/EJBTest_Project/GenericStateless!test.stateless.GenericStateless
java:app/EJBTest_Project/GenericStateless!test.stateless.GenericStateless
java:module/GenericStateless!test.stateless.GenericStateless
java:jboss/exported/JEETest_Project/EJBTest_Project/GenericStateless!test.stateless.GenericStateless
java:global/JEETest_Project/EJBTest_Project/GenericStateless
java:app/EJBTest_Project/GenericStateless
java:module/GenericStateless
*/

//None of the above names work for remote EJb resolution ONLY THIS WORKS -
//"/JEETest_Project/EJBTest_Project/GenericStateless!test.stateless.GenericStateless"

GenericStateless bean=(GenericStateless)context.lookup("/JEETest_Project/EJBTest_Project/GenericStateless!test.stateless.GenericStateless");

//GenericStateless bean=(GenericStateless)c.lookup("GenericStateless!test.stateless.GenericStateless");
System.out.println(bean.getInt());

关于java - Wildfly 远程 EJB 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24452075/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com