1 Reply Latest reply on Dec 17, 2005 5:37 PM by dirk.koehler

    Re: java.lang.NoClassDefFoundError

      Hi all,
      I wrote a small java program that will use the EJB that has been deployed (I believe that the following lines mean a successfull deployment)

      21:11:30,664 INFO [EjbModule] Deploying First
      21:11:30,851 INFO [EJBDeployer] Deployed: file:/C:/jboss-4.0.2/server/default/deploy/FirstEJB.jar
      21:11:30,945 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=file:/C:/jboss-4.0.2/server/default/deploy/jmx-console.war/
      21:11:31,273 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-

      Now I have this program..

      import javax.ejb.*;
      import java.rmi.*;
      import javax.rmi.*;
      import javax.naming.*;
      import com.stardeveloper.ejb.session.First;
      import com.stardeveloper.ejb.session.FirstHome;
      import java.util.Properties;

      public class FirstEJBClient
      public static void main(String[] args) throws Exception
      long t1 = System.currentTimeMillis();
      Properties props = new Properties();
      props.put(Context.PROVIDER_URL, "localhost:8080");
      Context ctxt = new InitialContext(props);
      FirstHome home = (FirstHome)ctxt.lookup("JndiFirst");
      First bean = home.create();
      String time = bean.getTime();
      long t2 = System.currentTimeMillis();

      I compiled the code as:

      C:\Documents and Settings\Administrator>%JAVA_HOME%\bin\javac -classpath C:\jboss-4.0.2\client\jboss-j2ee.jar;C:\TEST\EJB\FirstEJB\Fi
      rstEJB.jar C:\TEST\EJB\FirstEJBClient.java

      C:\Documents and Settings\Administrator>

      There are no compilation errors, but as I try to run the JAVA program as

      C:\Documents and Settings\ayusman_dikshit>%JAVA_HOME%\bin\java -classpath C:\jboss-4.0.2\client\jboss-j2ee.jar;C:\TEST\EJB\FirstEJB\Fir
      stEJB.jar C:\TEST\EJB\FirstEJBClient
      Exception in thread "main" java.lang.NoClassDefFoundError: C:\TEST\EJB\FirstEJBClient

      I have set C:\TEST\EJB in my classpath,
      any suggestions, on this problem???

        • 1. Re: java.lang.NoClassDefFoundError

          I suggest to post such problems in a java forum... it's not EJB related if you can't get your main running...

          1) cd C:\TEST\EJB\

          2) %JAVA_HOME%\bin\java -classpath .;C:\jboss-4.0.2\client\jboss-j2ee.jar;C:\TEST\EJB\FirstEJB\Fir
          stEJB.jar FirstEJBClient