Henrique Ordine
Henrique Ordine

Reputation: 3337

mvn jboss:deploy fails with NoClassDefFoundError

When deploying an EJB project to JBoss using JBoss Maven Plugin, I get a NoClassDefFoundError on my JBoss' console about a class that is in one of the dependencies of this EJB project.

This dependency is declared with a Compile scope. Is there another scope that I should use so that my dependencies are also deployed to JBoss? Or how should I solve this?

The error looks like this:

DEPLOYMENTS IN ERROR:
  Deployment "vfszip:/Users/hordine/projects/SoftBudget/soft-budget-ejb/target/soft-budget-ejb.jar/" is in error due to the following reason(s): java.lang.NoClassDefFoundError: br/com/pedra/j2eepatterns/facade/IEntityService

Upvotes: 0

Views: 960

Answers (1)

Charlee Chitsuk
Charlee Chitsuk

Reputation: 9069

I understand that you have packaged the EJB as a jar file. This means there is no any provided dependency as same as a stand-alone jar.

AFAIU, there may be 3 possible ways as the following: -

  1. Package them as an ear and put those dependencies inside the ear/lib. Please see Maven EAR Plugin for further information.

  2. Package them as an war and put those dependencies inside the WEB-INF/lib. Please see Maven WAR Plugin for further information.

  3. Package them as an jar and put those dependencies inside the classpath or application server lib. Please refer to your application server document.

EDITED: If you are using the JavaEE 6, then it is possible to package the EJB as a war file. The The Java EE 6 Tutorial: Packaging Enterprise Beans in WAR Modules told us as

Enterprise beans often provide the business logic of a web application. In these cases, packaging the enterprise bean within the web application’s WAR module simplifies deployment and application organization. Enterprise beans may be packaged within a WAR module as Java programming language class files or within a JAR file that is bundled within the WAR module.

To include enterprise bean class files in a WAR module, the class files should be in the WEB-INF/classes directory.

To include a JAR file that contains enterprise beans in a WAR module, add the JAR to the WEB-INF/lib directory of the WAR module.

WAR modules that contain enterprise beans do not require an ejb-jar.xml deployment descriptor. If the application uses ejb-jar.xml, it must be located in the WAR module’s WEB-INF directory.

I hope this may help.

Upvotes: 1

Related Questions