2

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

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

@VarunKrissh, glad that I could be of help. Can you mark my answer as correct so that it is beneficial to the future users?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.