毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

jboss7.1.1部署ejb3javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 and discovery

更新时间:2012-6-6:  来源:毕业论文
import java.util.Properties;

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

import com.xrd.ejb3.HelloWorld;

public class EJBClient {

public static void main(String[] args) {
Properties props = new Properties();
props.setProperty(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
try{
InitialContext ctx = new InitialContext(props);
HelloWorld hw = (HelloWorld) ctx.lookup("ejb:/helloworld//HelloWorldBean!com.xrd.ejb3.HelloWorld");
System.out.println(hw.sayHello("测试EJB3.0"));
}catch(NamingException e){
System.out.println(e.getMessage());
}

}

}

//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=localhost
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.default.username=admin
remote.connection.default.password=1234
最后这两句的值admin ,1234 是自己的用户名和密码
运行bin目录下的add-user.bat 增加即可

注意这句:ejb:/ 后面的helloworld 是打包后的名称,com.xrd.ejb3.HelloWorld 一定要写全包路径
HelloWorld hw = (HelloWorld) ctx.lookup("ejb:/helloworld//HelloWorldBean!com.xrd.ejb3.HelloWorld");

测试结果:
2012-5-19 1:55:58 org.jboss.ejb.client.EJBClient <clinit>
INFO: JBoss EJB Client version 1.0.5.Final
2012-5-19 1:55:58 org.xnio.Xnio <clinit>
INFO: XNIO Version 3.0.3.GA
2012-5-19 1:55:58 org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.0.3.GA
2012-5-19 1:55:58 org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 3.2.3.GA
2012-5-19 1:55:59 org.jboss.ejb.client.remoting.VersionReceiver handleMessage
INFO: Received server version 1 and marshalling strategies [river]
2012-5-19 1:55:59 org.jboss.ejb.client.remoting.RemotingConnectionEJBReceiver associate
INFO: Successful version handshake completed for receiver context EJBReceiverContext{clientContext=org.jboss.ejb.client.EJBClientContext@105738, receiver=Remoting connection EJB receiver [connection=Remoting connection <18088c0>,channel=jboss.ejb,nodename=hmily]} on channel Channel ID 85653753 (outbound) of Remoting connection 00f11404 to localhost/127.0.0.1:4447
2012-5-19 1:55:59 org.jboss.ejb.client.remoting.ChannelAssociation$ResponseReceiver handleMessage
WARN: Unsupported message received with header 0xffffffff
测试EJB3.0说:你好,EJB!

JBoss7.11 测试,另外很多人反应JBoss起几分钟后会断掉,不抱错,是因为JBOss没有加用户

上一页  [1] [2] [3] 

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。