2 Replies Latest reply on Mar 7, 2003 2:59 PM by raja05

    Client accessing EJB...

    jlenriquez

      Hi everyone!

      I got my JBoss 3.0 up and running on Win2k Pro... I deployed a sample EJB and spit out this ff. messages:

      16:00:11,250 INFO [EjbModule] Creating
      16:00:11,310 INFO [EjbModule] Deploying StringProcessor
      16:00:11,390 INFO [EjbModule] Created
      16:00:30,838 INFO [EjbModule] Starting
      16:00:30,908 INFO [EjbModule] Started

      I assume that EJB deployment goes well at this point, though when I try to access the StringProcessor EJB using this client (having main()):

      =============================================
      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Properties;
      import com.javapro.ejb.StringProcessor;
      import com.javapro.ejb.StringProcessorHome;

      public class Client {

      public static void main(String[] args) {

      // first argument must be the input
      if (args.length==0) {
      System.out.println("Please specify the input to convert to upper case.");
      return;
      }
      String input = args[0];

      // preparing properties for constructing an InitialContext object
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "localhost:1099");

      try {
      // Get an initial context
      InitialContext jndiContext = new InitialContext(properties);
      System.out.println("Got context");

      // Get a reference to the Bean
      Object ref = jndiContext.lookup("StringProcessor");
      System.out.println("Got reference");

      // Get a reference from this to the Bean's Home interface
      StringProcessorHome home = (StringProcessorHome)
      PortableRemoteObject.narrow (ref, StringProcessorHome.class);

      // Create an Adder object from the Home interface
      StringProcessor sp = home.create();
      System.out.println ("Uppercase of '" + input + "' is " +
      sp.toUpperCase(input));
      }
      catch(Exception e) {
      System.out.println(e.toString());
      }
      }
      }
      =============================================

      I only passed-through this output:

      C:\JWork>java Client lightwave

      Got context
      javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: com.javapro.ejb.StringProcessorHome]

      It seems that i am getting the context right and has been successsfully connected to provider url localhost:1099, but having some trouble communicating with the class files...

      anyone here who have some ideas or pass experiences with this kind of error?

      and btw for some troubleshooting history i'd tried including in the classpath some of the jar files located at the jboss\client folder but with no luck still the same error persists...

      any replies would be gladly appreciated... ^_^

        • 1. Re: Client accessing EJB...

          Put StringProcessorHome (and StringProcessor) on the classpath when starting the client app. And you'll most likely need some jboss libs as well; there is one jar that contains it all; i think it is called jbossclient-all.jar or something alike.

          hth
          Peter

          • 2. Re: Client accessing EJB...
            raja05

            do you have these classes
            import com.javapro.ejb.StringProcessor;
            import com.javapro.ejb.StringProcessorHome

            in ur classpath?