8

リモート サーバーにデプロイされたステートレス 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);

助けてください。

皆さんありがとう。ジャック。

4

5 に答える 5

3

この回答は遅れている可能性がありますが、同じ問題に直面しました。上記の回答はどれも役に立ちませんでした。この問題を解決するには、次を参照してください。 -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());
于 2014-12-22T17:17:01.687 に答える
1

私のために働いたもの:

私のクライアントは、スタンドアロンの Maven プロジェクトに参加していました。私がする必要があったのは、この依存関係を追加することだけでした:

<dependency>
    <groupId>org.wildfly</groupId>
    <artifactId>wildfly-ejb-client-bom</artifactId>
    <version>10.1.0.Final</version>
    <type>pom</type>
    <scope>runtime</scope>
</dependency>

ejb-remoteの例を見て、この解決策にたどり着きました。

于 2016-10-31T15:58:12.730 に答える
0

クライアント コードは、EJB 3 標準化された JNDI 名を使用して Bean にアクセスする必要があります。

Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
// Not needed but I like to see it when debugging
properties.put(Context.PROVIDER_URL, "http-remoting://localhost:8080/");
// EJB 3 bean naming convention
String jndi = "ejb:/myapp/mymodule/myEjbName!my.own.package.EjbInterface";
Context context = new InitialContext(properties);
obj = context.lookup(jndi);

そして、Bean のエクスポートされた JNDI バインディングについて、WildFly server.log を確認します。java:jboss/exported/myapp/mymodule/myEjbName!my.own.package.EjbInterface

セキュリティ チェックに合格するには、ユーザー名を で定義する必要がありますApplicationRealm

于 2014-11-27T11:18:28.993 に答える