JBoss:EAR 中的 WAR 文件在类路径上找不到 JAR 库 [英] JBoss: WAR file in EAR can't find JAR library on classpath

查看:57
本文介绍了JBoss:EAR 中的 WAR 文件在类路径上找不到 JAR 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 JBoss 4.3-eap 上部署带有捆绑战争、jar 和配置文件(.properties 文件)的 Ear 时遇到问题.这是我的耳朵结构:

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.jartag.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.NoClassDefFoundError). 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 添加到 war 的 manifest.mf 文件中,将 UseJBossWebLoader 更改为 truejboss-web.deployer 下的 jboss-service.xml 文件,以及上面的各种组合,都没有成功.我要么丢失了类路径(lib 文件夹)中的 classes 目录并且我的属性文件都没有被拾取,或者战争无法从 jar 访问正确的类.我认为一定有一些配置是错误的,虽然我已经尝试阅读 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.

任何建议将不胜感激.

以下是我一直在查看的一些网站:
Raible Designs JBoss ClassLoader 逻辑

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.

推荐答案

标签在 application.xml 是一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆