尝试创建简单的无状态EJB无法与初始上下文进行映射

时间:2018-09-25 19:19:50

标签: java java-ee-6 netbeans-8 jboss6.x

接口

@Local
public interface NewSessionBeanLocal {

}

Bean类

@Stateless
public class NewSessionBean implements NewSessionBeanLocal , NewSessionBeanRemote {


}

客户端类 我也把jboss-client.jar添加到库中

public class ClientDemo {

    public static void main(String[] args) throws NamingException {
        // TODO code application logic here

    Hashtable env = new Hashtable();

    env.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
    env.put("java.naming.provider.url","jnp://localhost:1099");
    env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
    Context iniCtx = new InitialContext(env);

    }

}

但是,控制台仍然出现错误。

> javax.naming.NoInitialContextException

complete error log.
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
    at javax.naming.InitialContext.init(InitialContext.java:242)
    at javax.naming.InitialContext.<init>(InitialContext.java:216)
    at clinetdemo.ClientDemo.main(ClientDemo.java:27)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:278)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:671)
    ... 4 more
  

我正在使用netbeans IDE,JEE 6,Jboss 6尝试创建一个简单的   无状态EJB无法与初始上下文进行映射。请帮我   这个。

0 个答案:

没有答案