Class loading problem regarding ear's lib directory

本文探讨了在JBoss上部署包含子部署的EAR文件时遇到的问题,子部署无法访问到EAR级别的库文件,导致ClassNotFoundException异常。通过调整ejb-jar.xml配置文件中的异常类声明格式,成功解决了类加载问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have an ear artifact like this:

 

asepdemo-ear-1.1.0-SNAPSHOT.ear

- lib

  - aseplib-commons-1.4.4-SNAPSHOT.jar (contains class AsepException)

  - ...

- aseplib-server-1.4.4-SNAPSHOT.jar

- ...

 

It seems that my subdeployment aseplib-server does not have access to the libs in the lib directory:

 

11:09:42,683 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.subunit."asepdemo-ear-1.1.0-SNAPSHOT.ear"."asepli

b-server-1.4.4-SNAPSHOT.jar".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."asepdemo-ear-1.1.0-SNAPSHOT.ear"."aseplib-server-1.4.4-SN

APSHOT.jar".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "aseplib-server-1.4.4-SNAPSHOT.jar" of deployment "asepdemo-ear-1.1.0-SNAPSHOT.ear"

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)

        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)

        at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)

        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_21]

        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_21]

        at java.lang.Thread.run(Thread.java:619) [:1.6.0_21]

Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException:

                                de.xy.platform.errorhandling.AsepException

                         from [Module "deployment.asepdemo-ear-1.1.0-SNAPSHOT.ear.aseplib-server-1.4.4-SNAPSHOT.jar:main" from Service Module Loader]

        at org.jboss.as.ejb3.deployment.EjbJarDescription.prepareApplicationExceptions(EjbJarDescription.java:155)

        at org.jboss.as.ejb3.deployment.EjbJarDescription.prepareEjbJarConfiguration(EjbJarDescription.java:144)

        at org.jboss.as.ejb3.deployment.EjbJarDescription.createEjbJarConfiguration(EjbJarDescription.java:132)

        at org.jboss.as.ejb3.deployment.processors.EjbJarConfigurationProcessor.deploy(EjbJarConfigurationProcessor.java:46)

        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)

        ... 5 more

 

 

Is there any configuration needed?

 

I already added

 

<jboss-deployment-structure>

  <!-- Make sub deployments isolated by default, so they cannot see each others classes without a Class-Path entry -->

  <ear-subdeployments-isolated>false</ear-subdeployments-isolated>

</jboss-deployment-structure>

正确答案:

So the problem was not really related to class loading. If you have an ejb-jar.xml like

 

       <application-exception>

            <exception-class>

              de.xyz.platform.errorhandling.AsepException

            </exception-class>

            <rollback>true</rollback>

        </application-exception>

 

dear JBoss is not even capable of triming away white spaces, but it tries to load "

         de.xyz.platform.errorhandling.AsepException

" class.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值