7 Replies Latest reply on Mar 12, 2002 4:59 AM by Adrian Brock

    how to test my ejb in jboss?

    zhebbincopng Newbie

      hello every one
      i wrote a simple cart session bean(Cart.class,CartHome.class,CartBean.class),packaged them into a jar file,and deployed it in the jboss2.4.4,now i want to test it.

      according the tutorial in this website,i wrote a "CartTestClient.class" and a "jndi.properties"file,the "jndi.properties" as follow:

      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


      i set the classpath ENVIRONMENT VARIABLE to point to file:

      ..........F:\myjava\jboss\client\jndi.properties

      go to the directory that contain the "CartTestClient.class",type:

      java com.mansion.ejb.CartTestClient

      the output is:

      F:\myjava\jboss\client>java com.mansion.ejb.CartTestClient
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
      aces.NamingContextFactory. Root exception is java.lang.ClassNotFoundException:
      org.jnp.interfaces.NamingContextFactory
      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:195)
      at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav
      a:45)
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
      52)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
      )
      at javax.naming.InitialContext.init(InitialContext.java:222)
      at javax.naming.InitialContext.(InitialContext.java:178)
      at com.mansion.ejb.CartTestClient.main(CartTestClient.java:37)



      my "jndi.properties" and "CartTestClient.class" are within the same directory.

      my "CartTestClient.java" as follow:


      package com.mansion.ejb;

      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.*;
      public class CartTestClient {
      private CartHome cartHome = null;

      public static void main(String[] args) {
      try{
      Context initial=new InitialContext();
      Object objref=initial.lookup("tt");
      CartHome home=(CartHome)PortableRemoteObject.narrow(objref,CartHome.class);
      Cart shoppingCart=home.create("Duke","123");

      ...................
      ...................
      ...................


      }catch(Exception e){
      e.printStackTrace();
      }
      }
      }


      why? which one is wrong?"jndi.properties" or "CartTestClient.java"?


      thanks for any helps!