1 Reply Latest reply on Feb 4, 2008 9:05 AM by phejl

    java.lang.NoClassDefFoundError: ${main/class} only on JBoss

    htran_888

      Hi All,

      I am encountering the following errors when running the Enterprise Application Client using JBoss 4.2.2 AS:

      --------------------------------------------------------------------------------------
      Deploying C:\Documents and Settings\abc\EnterpriseAppEE5-JBoss422\dist\EnterpriseAppEE5-JBoss422.ear

      java.lang.NoClassDefFoundError: ${main/class}
      Exception in thread "main" – when running application client for the first few times. This was followed by the error messages below:

      C:\Documents and Settings\abc\EnterpriseAppEE5-JBoss422\nbproject\build-impl.xml:261:

      The following error occurred while executing this line:
      C:\Documents and Settings\abc\EnterpriseAppEE5-JBoss422\nbproject\build-impl.xml:282: Classname must not be null.
      BUILD FAILED (total time: 1 second)
      Exception in thread "main" java.lang.NullPointerException
      at enterpriseappee5JBoss422.Main.main(Main.java:13)

      Java Result: 1
      run-EnterpriseAppEE5-JBoss422-app-client:

      --------------------------------------------------------------------------------------

      Below are the Enterprise Application property runs in Netbeans 6.0, jdk1.6.0_03, Windows XP, SP2:

      EnterpriseAppEE5-JBoss422-ejb => Run => Main Class - enterpriseappee5jboss422.Main.
      EnterpriseAppEE5-JBoss422 = > Run => Client Module - EnterpriseAppEE5-JBoss422-app-client, Main Class – blank.


      Codes for the stateless session bean (EnterpriseAppEE5-JBoss422-ejb) is:

      package ejb;
      import javax.ejb.Remote;
      
      @Remote
      public interface SessionRemote {
      
       public String getResult();
      
      }

      package ejb;
      
      import javax.ejb.Stateless;
      
      @Stateless
      public class SessionBean implements SessionRemote {
      
       public String getResult() {
       return "This is EJB 3.0 Bean";
       }
      }


      Code for the application client (EnterpriseAppEE5-JBoss422-app-client) is:

      package enterpriseappee5JBoss422x;
      
      import ejb.SessionRemote;
      import javax.ejb.EJB;
      
      public class Main {
      
       @EJB
       private static SessionRemote sessionBean;
      
       public static void main(String[] args) {
      
       System.err.println("result=" + sessionBean.getResult());
       }
      }


      I have had no success after having tried adjusting the following settings in Netbeans Enterprise application properties:

      EnterpriseAppEE5-JBoss422 = > Run => Client Module - EnterpriseAppEE5-JBoss422-app-client, Main Class – ejb.Main or enterpriseappee5JBoss422.Main.


      There were no such issue when running the same codes in the same environment but with Glass Fish (v2) instead of JBoss 4.2.2 AS.

      The URL for the above tutorial can be found in http://testwww.netbeans.org/kb/articles/appclient-entappclient.html.

      I have tried to follow the suggestion from (http://www.jboss.com/index.html?module=bb&op=viewtopic&t=126495) without success.

      I am confused about the need to have a Main Class when there is already a Client class which can call the main method already. E.g. ConverterClient in J2EE EJB tutorial (http://docs.sun.com/app/docs/doc/819-3669/bnbnc?l=en&q=javaeetutorial5&a=view).

      Thanks,

      George