5 Replies Latest reply on Sep 1, 2003 11:27 AM by event_horizon

    cant get initialcontext (newbie)

    event_horizon Newbie

      Hi, I am a total newbie to the world of EJBs and am just trying out my first one. I am working with JBoss 3.2.2 with Tomcat on my Linux box (Red Hat 8). However, I am having a lot of trbl getting the client code to work. Here is the dump of the exception that I get whenever I run the client (I have tried to look for answers everywhere and have tried to do the things that others did when they had similar problems but with no luck. So I am sorry this is not the first time this question is on this forum)

      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:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:195)
      at examples.HelloClient.main(HelloClient.java:30)
      Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:219)
      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
      ... 4 more

      Here's a part of my client code:

      ...
      Properties props = System.getProperties();
      Context ctx = new InitialContext(props);
      Object obj = ctx.lookup("HelloHome");
      ...

      My jndi.properties file:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://localhost:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces.jnp

      My ejb-jar.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-Sun Microsystems, Inc.//DTD Enterprise
      JavaBeans 2.0//EN" " http://java.sun.com/dtd/ejb-jar_2_0.dtd">
      <ejb-jar>
      <enterprise-beans>

      <ejb-name>Hello</ejb-name>
      hellopackage.HelloHome
      hellopackage.Hello
      <local-home>hellopackage.HelloLocalHome</local-home>
      <ejb-class>hellopackage.HelloBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>

      </enterprise-beans>
      </ejb-jar>


      I have included the EJB jar file, jboss-j2ee.jar and jnp-client.jar files in my classpath when i run the client. Can anyone help me with this?

      Thanks