6 Replies Latest reply on Jan 25, 2005 11:12 AM by Darran Lofthouse

    I am not able to run cleint. Please help me

    Asheesh Shrivastav Newbie

      I am just writing a simple session bean. I have successfuly deployed the bean
      the directory structure is C:\asheesh\classes\com\bizwise\ejb. under This I have kept all my java files including client

      my client code is
      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Properties;
      import com.bizwise.ejb.*;
      //import com.bizwise.ejb.Adder;
      //import com.bizwise.ejb.AdderHome;

      public class BeanClient {

      public static void main(String[] args) {
      // 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("Adder");
      System.out.println("Got reference");

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

      // Create an Adder object from the Home interface
      Adder adder = home.create();
      System.out.println ("2 + 5 = " + adder.add(2, 5));
      }
      catch(Exception e) {
      System.out.println(e.toString());
      }
      }
      }

      Please help me I m getting the below error

      C:\asheesh\classes>java com/bizwise/ejb/BeanClient
      Exception in thread "main" java.lang.NoClassDefFoundError: com/bizwise/ejb/BeanC
      lient (wrong name: BeanClient)
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)

      Please help me




        • 1. Re: I am not able to run cleint. Please help me
          Bernd Zeitler Expert

          Probably the classname and the class files filename are not the same ;-)

          • 2. Re: I am not able to run cleint. Please help me
            Asheesh Shrivastav Newbie

            Thanks.
            But i don't think it is a problem as you can see the class name I am calling is right. I think its the problem in classpath.
            I am again writing my directory structure
            C:\asheesh\classes\com\bizwise\ejb
            Here all the java and class files are residing

            I m calling my cleint as
            C:\asheesh\classes>java com/bizwise/ejb/BeanClient
            I am getting error as

            Exception in thread "main" java.lang.NoClassDefFoundError: com/bizwise/ejb/BeanClient (wrong name: BeanClient)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)

            As per ur instruction if i give a command with wrong file name say
            C:\asheesh\classes>java com/bizwise/ejb/BeanClient1
            Exception in thread "main" java.lang.NoClassDefFoundError: com/bizwise/ejb/BeanClient1

            I get this error. please help me with the problem

            I am pasting my classpath
            .;
            C:\Sun\AppServer\jdk\lib\tools.jar;
            C:\ProgramFiles\EditPlus;
            C:\javaexam\javaprac;C:\asheesh\Titan-JBoss-3.2-12d\workbook\ant;
            %PATH%;
            C:\eclipse\workspace\IBE\src\server;
            C:\eclipse\workspace\IBE\src\shared;
            C:\Sun\AppServer\lib\j2ee.jar;
            c:\IBE;C:\projects\jboss-tutorial;
            C:\Sun\AppServer\lib\j2ee.jar;
            C:\jboss-4.0.0\client\log4.jar;
            C:\jboss-4.0.0\client\jboss-common-client.jar;
            C:\jboss-4.0.0\client\jboss-system-client.jar;
            C:\jboss-4.0.0\client\jnp-client.jar;
            C:\jboss-4.0.0\client\jboss-client.jar;
            C:\jboss-4.0.0\client\jbosssx-client.jar;
            C:\projects\jboss-tutorial\HelloWorld.jar;
            C:\jboss-4.0.0\server\default\deploy;
            C:\jboss-4.0.0\server\default\lib\jboss-j2ee.jar;
            C:\jboss-4.0.0\client;
            C:\projects\jboss-tutorial;
            C:\apache-ant-1.6.2\lib\ant.jar;
            C:\asheesh\classes

            • 3. Re: I am not able to run cleint. Please help me
              Darran Lofthouse Master

              Have you tried

              java com.bizwise.ejb.BeanClient


              • 4. Re: I am not able to run cleint. Please help me
                Darran Lofthouse Master

                Sorry, forget the last post the slashes are fine.

                Your class does not show the package statement at the top, did you just miss this when cutting and pasting or have you missed it out of the class?

                Have you compiled your class? If so does the .class file also reside in the folder 'C:\asheesh\classes\com\bizwise\ejb'

                • 5. Re: I am not able to run cleint. Please help me
                  Asheesh Shrivastav Newbie

                  Thanks Darranal, I really appreciate ur help. I am sorry for not early reply as i was on medical leave. Well I am fine now
                  No I have not put any packae statement. Honestly I just copy and paste the coed to see whether my jboss is working properly an my cleint is able to thrown the right output. So I have no written any codes on my own. its just and paste from the website
                  Also, I have compiled all my java codes and all the class file reside in
                  'C:\asheesh\classes\com\bizwise\ejb' ie all the bean classes and the client classes.

                  Hope this will give u a better view and will be able to help me

                  I really appreciate it and honestly need ur help as I am stuck and is not able to go ahead. Please help me

                  • 6. Re: I am not able to run cleint. Please help me
                    Darran Lofthouse Master

                    If you class is supposed to be in the package com.bizwise.ejb you need to add the following line to the top of the class and compile it again: -

                    package com.bizwise.ejb;


                    Alternatively as it sounds like the class has been compiled in the default package you could take your command prompt into the folder 'C:\asheesh\classes\com\bizwise\ejb' and try executing the command java BeanClient