JBOSS 7.0 - 无法使用http-remoting协议连接到服务器

问题描述 投票:2回答:1

所有,

我试图从远程独立程序调用EJB。 EJB已在JBOSS 7.0上正确部署。我使用以下代码进行查找:

Properties jndiProps = new Properties();  
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
         jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");
        jndiProps.put(Context.SECURITY_PRINCIPAL, "user1");
         jndiProps.put(Context.SECURITY_CREDENTIALS, "password@123?");
         jndiProps.put("jboss.naming.client.ejb.context", true);  

         try { 
         Context ctx = new InitialContext(jndiProps);  
         HelloWorld d= (HelloWorld)   ctx.lookup("HelloWorldSessionBean/HelloWorldBean!com.ibytecode.business.HelloWorld");
//             String s=d.sayHello();
//             System.out.println(s);

       }  
       catch(Exception ne) {  
                       ne.printStackTrace();  
       }  

但我得到以下异常,无法继续进行。任何人都可以让我知道我错过了什么:

Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]
javax.naming.NamingException: Failed to connect to any server. Servers tried: [http-remoting://localhost:8080]

我的服务器已启动并正在运行,我使用的是standalone-full.xml文件

java jboss7.x
1个回答
2
投票

我认为你的JBoss版本(AS 7)中没有http-remoting:协议。

更改您的提供商URL

jndiProps.put(Context.PROVIDER_URL, "http-remoting://localhost:8080");

jndiProps.put(Context.PROVIDER_URL, "remote://localhost:4447");

此外,请确保在客户端的类路径中包含所有必需的JBoss EJB远程处理项目库。

© www.soinside.com 2019 - 2024. All rights reserved.