dポイントプレゼントキャンペーン実施中!

今回初めて、JBossを利用してステートレスJavaBeanをクライアントからアクセスしようとしています。クライアントでJBossサーバのアドレスを"localhost"または"127.0.0.1"とするとアクセスできますが、実際のIPアドレスを指定すると以下のエラーが出ます。

Could not obtain connection to any of these urls: 10.200.33.181:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

もし、原因などが判る方がいらっしゃれば、アドバイスをお願いします。

【環境】
JBoss jboss-4.2.0.GA
Java Sun JDK1.6.0
サーバOS Windows XP/Redhat Enterprise Linux4(両方とも同じ現象)
【インターフェースプログラム】
package sample;
public interface Bank {
String getName();
}
【Bean本体プログラム】
package sample;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;

@Stateless
@Remote
@Local
public class BankBean implements Bank {

public String getName() {

return "Hello World";
}
}
【クライアントプログラム】
package sample;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import java.util.Properties;

public class Client {

public static void main(String[] args) {

Properties props = new Properties();

props.put("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs",
"org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "10.200.33.181:1099"); // エラー
//props.put("java.naming.provider.url", "127.0.0.1:1099"); // OK
// props.put ("java.naming.provider.url", "158.214.125.162:1099"); // エラー
//props.put ("java.naming.provider.url", "MY-SERVER"); // エラー
// props.put ("java.naming.provider.url", "localhost:1099"); // OK

try {

Context ctx = new InitialContext(props);
Bank ejb = (Bank) ctx.lookup("BankBean/remote"); // エラー発生場所
System.out.println(ejb.getName());
} catch (NamingException e) {

System.err.println(e.getMessage());
e.printStackTrace();
}
}
}

A 回答 (1件)

JBoss4.2からセキュリティー上の観点からバインド(監視)するアドレスの


デフォルト(初期設定)が127.0.0.1(稼動PC自身)になったのです。
いままで(4.0.x系)は全てのIPアドレスをバインドしていました(設定0.0.0.0)

◆公式文書(readme.htmlより)
JBossAS now binds its services to localhost (127.0.0.1) *by default*, instead of binding to all available interfaces (0.0.0.0). This was primarily done for security reasons because of concerns of users going to production without having secured their servers properly. To enable remote access by binding JBoss services to a particular interface, simply run jboss with the -b option, but be aware you still need to secure you server properly.

となっています。
セキュリティ的にはこの状態も望ましいかもしれません。
とりあえず今までと同じように動作させたい場合 -b オプションを使って

/usr/local/jboss/bin/run.sh -b 0.0.0.0

のようにバインドするIPを通知してあげればOKです。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!