jboss 4.2 配置监听所有IP的EJB服务

在使用jboss-4.2.3.GA发布EJB3.0服务的时候,采用默认的jboss配置(也就是配置文件不做任何变更,启动服务的时候也不附加任何参数),可以在本地使用localhost:1099
也就是这里

props.setProperty(Context.PROVIDER_URL, "localhost:1099");



后来,希望将服务部署在一台机器上(服务器),用另外的机器(客户端)调用服务器上的服务,体验ejb的分布式服务。于是便将服务器启动了,在客户端使用这样的代码(服务器地址是150.18.23.128):

props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.PROVIDER_URL, "150.18.23.128:1099");


连接服务器。结果,客户端说服务器不鸟ta, :o :cry: 。客户端是这样说的:
[code="java"]javax.naming.CommunicationException: Could not obtain connection to any of these urls: 150.18.23.128:1099 and discovery failed with error: javax.naming.CommunicationException: Receive timed out [Root exception is javax.naming.CommunicationException: Failed to connect to server 150.18.23.128:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 150.18.23.128:1099 ]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1562)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:634)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.foshanshop.ejb3.app.MyQueueSender.main(MyQueueSender.java:33)
Caused by: javax.naming.CommunicationException: Failed to connect to server 150.18.23.128:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server 150.18.23.128:1099 ]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:274)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1533)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server 150.18.23.128:1099
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:248)
... 5 more
Caused by: java.net.ConnectException: Connection timed out: connect[/code]

于是刘若英大姐开唱了:后来…………
后来,查了很多资料,试了一大通,试过配置host,修改jboss的配置文件,修改连接的url……

行不通……

最后 通过 搜索:jboss.bind.address,找到了 [url]http://feng88724.iteye.com/blog/263211[/url]:Jboss无法通过IP地址访问,只能用localhost\127.0.0.1访问

(感谢该博文帮助我解决了问题^_^)

于是,这样处理

在jboss\jboss-4.2.3.GA\bin 新建了 startmy.bat,在里面添加以下内容
run.bat -b 0.0.0.0

运行startmy.bat启动服务,这样客户端就可以访问服务端的服务了,配置还是
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.setProperty(Context.PROVIDER_URL, "150.18.23.128:1099");


另外一种启动的方式是: 在cmd中运行 run.bat -b 0.0.0.0,效果是一样的
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值