VarunKrish
VarunKrish

Reputation: 179

JBOSS 7.0 - unable to connect to server using http-remoting protocol

All,

I am trying to invoke an EJB from remote standalone program. EJB is properly deployed on JBOSS 7.0. I am using the below code to do the lookup:

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();  
       }  

But I am getting the below exception and unable to proceed further. Can anyone let me know what I am missing:

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]

My Server is up and running and I am using standalone-full.xml file

Upvotes: 2

Views: 3138

Answers (1)

VHS
VHS

Reputation: 10194

I think http-remoting: protocol is not available in your version of JBoss (AS 7).

Change your provider URL from

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

to

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

Also, make sure you have all the necessary JBoss EJB remoting project libraries in your classpath of your client.

Upvotes: 2

Related Questions