javax.naming.NamingException:无法连接到任何服务器。尝试使用的服务器:[远程://本地主机:18080]

时间:2018-09-23 08:57:33

标签: java-ee

这是我的代码:

    public class HelloService{
        public static void main (String[] args) throws NamingException
        {
        String jndiName="MyEJBProj-ejb/HelloService!ejbpack.HelloServiceRemote";
        Properties jndiProps = new Properties();
        jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,         
        "org.jboss.naming.remote.client.InitialContextFactory");
        jndiProps.put(Context.PROVIDER_URL,"remote://localhost:18080");

        jndiProps.put("jboss.naming.client.ejb.context", true);
        Context ctx = new InitialContext(jndiProps);
        HelloServiceRemote proxy=(HelloServiceRemote) ctx.lookup(jndiName);
        System.out.println(proxy.sayHello("hello"));    }
    } 

请,您对此错误有一个了解吗?

0 个答案:

没有答案