2 Replies Latest reply on Jun 10, 2003 8:59 PM by topcool

    ask a question about ejb client

    topcool Newbie

      I have deployed a ejb to jboss
      but when I run my ejb client ,occur a error as follow:
      this is my classpath:
      D:\Temp\jboss>set classpath=.; D:/jboss-3.0.6/client/concurrent.jar; D:/jboss-3.
      0.6/client/jaas.jar; D:/jboss-3.0.6/client/jboss-common-client.jar; D:/jboss-3.0
      .6/client/jboss-client.jar; D:/jboss-3.0.6/client/jbossmq-client.jar; D:/jboss-3
      .0.6/client/jboss-system-client.jar; D:/jboss-3.0.6/client/jboss-j2ee.jar; D:/jb
      oss-3.0.6/client/jbosssx-client.jar; D:/jboss-3.0.6/client/jboss-jsr77.jar; D:/j
      boss-3.0.6/client/jmx-rmi-connector-client.jar; D:/jboss-3.0.6/client/jnet.jar;
      D:/jboss-3.0.6/client/jnp-client.jar; D:/jboss-3.0.6/client/jcert.jar; D:/jboss-
      3.0.6/client/log4j.jar; D:/jboss-3.0.6/client/jbossall-client.jar;D:\Temp\jboss\
      testejb\src\a.jar;

      error :
      D:\Temp\jboss\testejb\client>java InterestClient
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
      aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
      rg.jnp.interfaces.NamingContextFactory]

      and this is my source:

      import javax.naming.InitialContext;
      import javax.rmi.PortableRemoteObject;
      import java.util.*;
      import javax.naming.*;

      import org.jboss.docs.interest.Interest;
      import org.jboss.docs.interest.InterestHome;

      /** This simple application tests the 'Interest' Enterprise JavaBean which is
      implemented in the package 'org.jboss.docs.interest'. For this to work, the
      Bean must be deployed on an EJB server.
      */
      class InterestClient
      {
      /** This method does all the work. It creates an instance of the Interest EJB on
      the EJB server, and calls its `calculateCompoundInterest()' method, then prints
      the result of the calculation.
      */
      public static void main(String[] args)
      {
      // Enclosing the whole process in a single `try' block is not an ideal way
      // to do exception handling, but I don't want to clutter the program up
      // with catch blocks
      try
      {
      // Get a naming context
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL,"jnp://localhost:1099");
      //properties.put(Context.PROVIDER_URL_PKGS,"org.jboss.naming:org.jnp.interfaces");

      InitialContext jndiContext = new InitialContext(properties);
      System.out.println("Got context");

      // Get a reference to the Interest Bean
      Object ref = jndiContext.lookup("java:comp/env/ejb/Interest");
      System.out.println("Got reference");

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

      // Create an Interest object from the Home interface
      Interest interest = home.create();

      // call the calculateCompoundInterest() method to do the calculation
      System.out.println("Interest on 1000 units, at 10% per period, compounded over 2 periods is:");
      System.out.println(interest.calculateCompoundInterest(1000, 0.10, 2));
      }
      catch(Exception e)
      {
      System.out.println(e.toString());
      }
      }
      }

      who can tell me why about this error

      thanks in advance!~

        • 1. Re: ask a question about ejb client
          Jaime Salvador Newbie

          Try to put in your classpath the file:

          C:\jboss-3.0.7\server\default\lib\jnpserver.jar

          JaimeZ

          • 2. Re: ask a question about ejb client
            topcool Newbie

            I doubt why jboss is so hard to use,
            which .jar file should be put into classpath?
            I (include many friends )don't know it.

            weblogic is a good example ,It need only one .jar file

            weblogic.jar that should be put into classpath

            I try that file jboss-3.0.7\server\default\lib\jnpserver.jar

            error as follow:

            D:\Temp\jboss\testejb\client>java InterestClient
            javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
            aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
            rg.jnp.interfaces.NamingContextFactory]

            this is classpath:
            D:\Temp\jboss>set classpath=.; D:/jboss-3.0.6/client/concurrent.jar; D:/jboss-3.
            0.6/client/jaas.jar; D:/jboss-3.0.6/client/jboss-common-client.jar; D:/jboss-3.0
            .6/client/jboss-client.jar; D:/jboss-3.0.6/client/jbossmq-client.jar; D:/jboss-3
            .0.6/client/jboss-system-client.jar; D:/jboss-3.0.6/client/jboss-j2ee.jar; D:/jb
            oss-3.0.6/client/jbosssx-client.jar; D:/jboss-3.0.6/client/jboss-jsr77.jar; D:/j
            boss-3.0.6/client/jmx-rmi-connector-client.jar; D:/jboss-3.0.6/client/jnet.jar;
            D:/jboss-3.0.6/client/jnp-client.jar; D:/jboss-3.0.6/client/jcert.jar; D:/jboss-
            3.0.6/client/log4j.jar; D:/jboss-3.0.6/client/jbossall-client.jar; D:/jboss-3.0.
            6/server/default/lib/jnpserver.jar;D:\Temp\jboss\testejb\src\a.jar;

            I am angry at jboss, and I want to say it is a bad software

            why it is hard to use?

            kao ~