This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello All, I am trying to deploy an EJB which uses an external Java class to perform the business logic. I packed the EJB, along with the deployment descriptors and the external Java class into a jar file and tried deploying the EJB bean. I am always getting a "NoClassFoundError" on the external class when deploying the EJB. Somehow the application server i.e., JBoss 3.2.1 is unable to load the external Java class. I tried packing the external jar file and copied the jar file into the "server/default/lib" but in vain. I also tried "CLASSPATH" point to the jar file but the error still persisted. Do we have to edit the ejb-jar.xml file and can we use <resource-ref> for external Java classes or is it reserved for external EJB's? Can anyone help me?
I suspect that it's not the external class that is the problem but rather some other class that that class depends on. NoClassDefFound exceptions are tricky to track down, but often it isn't the class that is in the exception message. Take a look at that class's imports (and the imports of those classes) to see what class in the tree is missing.
I tried packing the external jar file and copied the jar file into the "server/default/lib" but in vain. I also tried "CLASSPATH" point to the jar file but the error still persisted. Can anyone help me?
Business Classes should not be in the server classpath as they're problably not used for most of the applications. You should package the classes together with your .jar or .ear file. It's also a good idea to read about the classloader of the app server u're using. regards.