[jboss-user] [JBoss and NetBeans] - java.lang.NoClassDefFoundError: ${main/class} only on JBoss

htran_888 do-not-reply at jboss.com
Thu Dec 27 22:51:30 EST 2007

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


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).



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4115839#4115839

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4115839

More information about the jboss-user mailing list