Reputation: 3337
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
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: -
Package them as an ear
and put those dependencies inside the ear/lib
. Please see Maven EAR Plugin for further information.
Package them as an war
and put those dependencies inside the WEB-INF/lib
. Please see Maven WAR Plugin for further information.
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 aWAR module
, the class files should be in theWEB-INF/classes
directory.To include a
JAR file
that containsenterprise bean
s in aWAR module
, add theJAR
to theWEB-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 usesejb-jar.xml
, it must be located in theWAR
module’sWEB-INF
directory.
I hope this may help.
Upvotes: 1