英文:
Wildfly module classloading
问题
我在使用Wildfly的类加载过程中遇到了一个相当奇怪的问题。我有一个Java EE Web应用程序,结构如下:
some.ear
+- some.war
+- EJBs.jar
无论是war文件还是jar文件都需要一些Spring类来正常运行。我定义了一个包含相关类的Spring模块。在jboss-deployment-structure
中,我有一个如下所示的部分:
<jboss-deployment-structure>
<deployment>
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</deployment>
启动我的Web应用程序后,部署war存档时出现ClassNotFoundException
错误。
如果我添加一个额外的部分
<sub-deployment name="some.war">
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</sub-deployment>
它就能正常工作。
我理解的是,主部署部分中的每个模块在所有子部署中也应该可见。
是否有人能够解决这个问题?
英文:
I have come across a rather curious issue with wildfly classloading. I have a java-ee webapp, structured as follows:
some.ear
+- some.war
+- EJBs.jar
both the war and the jar require some spring classes to function properly. I defined a spring module containing the relevant classes. Within jboss-deployment-structure
I have a section as follows:
<jboss-deployment-structure>
<deployment>
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</deployment>
After launching my webapp, I get a ClassNotFoundException
when deploying the war-archive.
If I add an additional section
<sub-deployment name="some.war">
<dependencies>
...
<module name="org.springframework.spring-web"/>
...
</dependencies>
</sub-deployment>
it works.
My understanding is, that every module from the main-deployment section should also be visible in all sub-deployments.
Can anyone shed some light on this issue?
答案1
得分: 2
每个子部署都需要它自己的模块依赖。如果您将模块库包含在EAR/lib
目录中,而不是创建一个模块,那么您就不需要为每个子部署添加模块依赖。
英文:
Each sub-deployment would need it's own set of module dependencies. If you were to include the module libraries in the EAR/lib
directory instead of creating a module then you'd not need to add the module dependency for each sub-deployment.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论