JBoss:EAR中的WAR文件在类路径上找不到JAR库 [英] JBoss: WAR file in EAR can't find JAR library on classpath
问题描述
我在JBoss 4.3-eap上部署了捆绑的战争,jar和配置文件(.properties文件)的问题。这是我的耳朵结构:
I am having a problem deploying an ear with bundled wars, jars, and configuration files (.properties files) on JBoss 4.3-eap. Here is my ear structure:
+app.ear
+lib
*.jar libraries that the war's use
+classes
*.properties and other configuration files
+META-INF
application.xml
jbos-app.xml
app.war
app2.war
appn.war
我的jboss中有以下-app.xml:
I have the following in my jboss-app.xml :
<jboss-app>
<jmx-name>app.startup.JbossStartUpServer:service=JbossStartUpService</jmx-name>
</jboss-app>
我的application.xml如下所示:
My application.xml looks like this:
<application id="app_id">
<display-name>App>/display-name>
<description>TheApp>/description>
<!--
<module id="core">
<java>lib/core.jar</java>
</module>
<module id="tag">
<java>lib/tag.jar</java>
</module>
-->
<module id="app">
<web>
<web-uri>app.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module id="app2">
<web>
<web-uri>app2.war</web-uri>
<context-root>/app2</context-root>
</web>
</module>
<module id="appn">
<web>
<web-uri>appn.war</web-uri>
<context-root>/appn</context-root>
</web>
</module>
<security-role id="secRole">
<description>users</description>
<role-name id="appRoleName">users</role-name>
</security-role>
<library-directory>lib</library-directory>
</application>
基本上,在部署耳朵时,遇到一个我的一个战争找不到的问题一个类在 core.jar
文件( java.lang.NoClassDefFoundErro
r)。我认为这是因为战争没有找到这个图书馆,即使它在 lib
文件夹/类路径中。如果我尝试取消注释前两个模块以添加第一方库( core.jar
和 tag.jar
)突然之间,不能再找到这些属性文件(他们现在位于 lib / classes
中,所以我希望他们被拿起来理想情况下,我想将类放在自己的目录中,并将它分开添加到类路径,但现在我只是想让这个工作)。
Basically, upon deploying the ear, I run into an issue where one of my wars can't find a class in the core.jar
file (java.lang.NoClassDefFoundErro
r). I think this is due to the fact that the war is not finding this library, even though it is in the lib
folder/classpath. If I try to uncomment the first two modules to add the first party libraries (core.jar
and tag.jar
), all of a sudden the properties files can no longer be found (they are located, for now, in lib/classes
, so that, I hope anyway, they are picked up by the classloader. Ideally I'd like to put classes in its own directory and add it to the classpath separately, but for now I am just trying to make this work).
我已经尝试过其他一些事情,包括手动添加 core.jar
到战争的 manifest.mf
文件,在 jboss-service.xml
文件中将 UseJBossWebLoader
更改为true在 jboss-web.deployer
之下,以及上述的各种组合,没有成功。我从类路径( lib
文件夹)中输入类
目录,并且我的任何属性文件都没有被拾取,或战争无法从罐子里进入适当的课堂。我认为必须有一些配置是错误的,虽然我已经尝试阅读JBoss做EAR部署和类加载的方式,但我似乎不能适应我目前的设置。
I have tried some other things, including manually adding core.jar
to the war's manifest.mf
file, changing UseJBossWebLoader
to true in the jboss-service.xml
file under the jboss-web.deployer
, and various combinations of the above, to no success. I either lose the classes
directory from the classpath (lib
folder) and none of my properties files get picked up, or the war can't access the proper class from the jar. I think there must be some configuration that is wrong, and while I've tried reading up on the way JBoss does EAR deployments and classloading, I can't seem to adapt it to my current setup.
任何建议将不胜感激。
Any suggestions would be greatly appreciated.
以下是我一直在看的网站:
Raible Designs JBoss ClassLoader Logic
Here are some sites that I have been looking at:
Raible Designs JBoss ClassLoader Logic
这些只是我看过的几个网站。这些问题也可能来自于项目的设置,因为这是一个大的已建立的项目(在一定程度上)从Weblogic部署迁移到Jboss。所以如果有什么应该工作,但是没有,这可能是一些代码/项目配置的问题。不幸的是,我现在还不知道它是否与JBoss相关的问题,或项目的问题。
These are just a few of the sites I have looked at. The problems might stem from the setup of the project as well, as this is a large established project that is (to an extent) being migrated from a weblogic deployment to Jboss. So if there is anything that SHOULD work, but doesn't, it might be an issue with some of the code/project configuration. Unfortunately, I am not at the point yet where I can tell if its a JBoss related problem, or a problem with the project.
推荐答案
p> application.xml
中的< library-directory>
标签是JavaEE5功能,我不认为JBoss 4.3完全符合JavaEE5(可以做EJB3,是的,但只是部分支持)。
The <library-directory>
tag in application.xml
is a JavaEE5 feature, and I don't think that JBoss 4.3 is fully JavaEE5-compliant (it can do EJB3, yes, but it's only partial support).
所以你需要回到使用明确声明的JAR文件:
So you need to go back to using explicitly declared JAR files:
<module>
<java>lib/core.jar</java>
</module>
对于您的属性文件,您需要添加他们所在的目录作为java模块,所以例如:
As for your properties files, you need to add the directory that they're in as a java module, so for your example:
<module>
<java>lib/classes</java>
</module>
这篇关于JBoss:EAR中的WAR文件在类路径上找不到JAR库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!