JBoss - 战争库依赖项 [英] JBoss - War library dependencies

查看:24
本文介绍了JBoss - 战争库依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加一些依赖项 jar 文件.但是这些文件放在 lib/endorsedWEB_INF/lib.jar 中时会导致 jboss 实例启动错误.我想这是因为 JBoss 的扁平类加载器结构.如果有人在 jboss-web.xml

I am trying to add some dependencies jar files. But these files when put in lib/endorsed or in WEB_INF/lib.jar results in startup error for jboss instances. I suppose this is happening because flat classloader structure of JBoss. If somebody has implemented the classloader settings in jboss-web.xml

<class-loading> 
      <loader-repository>com.example:archive=unique-archive-name</loader-repository> 
</class-loading>

谁能给我举个真实的例子?

Can somebody give me a real life example ?

还有我应该在哪里放置这些 jar 文件 - jboss 的 lib/endorsed,或者部署文件夹或 WEB_INF/lib 中的 lib 文件夹

Also where should I place these jar files - lib/endorsed of jboss, or lib folder in deploy folder or in WEB_INF/lib

推荐答案

Duffymo 关于不要将 jar 放入 endorsed 的指令被忽略,后果自负.

Duffymo's directive on not putting jars in endorsed is ignored at your peril.

一些额外的细节:

将库放置在您的 WEB-INF/lib 中是可移植性和一致性的最佳实践,因为它遵守创建自给自足和可分发的 Web 档案的标准规定,但您需要密切关注注意您在 jboss-web.xml 中放入的 class-loading 声明.

Placing libraries in your WEB-INF/lib is a best practice for portability and consistency as it adheres to a standard provision for creating self-sufficient and distributable web archives, but you need to pay close attention to the class-loading declaration you're putting in your jboss-web.xml.

假设一个简单的场景没有类加载声明和一个虚构的example.jar:

Assume a simple scenario without the class-loading declaration and a fictional example.jar:

  • 如果您将 example.jar 放在 WEB-INF/lib 并且不会 也存在于 jboss//lib 中,那么 example.jar 只会对那个特定的 WAR 可见.
  • 如果您将 example.jar 放在 WEB-INF/lib 并且这样做 也存在于 jboss//lib 中,WEB-INF/lib 中的实例基本上将被忽略并且 WAR 将使用 JBoss 服务器实例的统一类加载器来从 jboss//lib/example.jar 加载 example 类.(假设没有类加载覆盖,这同样适用于同一服务器实例中的任何其他 WAR 或 EAR.)
  • If you place example.jar in WEB-INF/lib and it does not also exist in jboss//lib, then example.jar will only be visible to that specific WAR.
  • If you place example.jar in WEB-INF/lib and it does also exist in jboss//lib, the instance in WEB-INF/lib will essentially be ignored and the WAR will use the JBoss server instance's unified class loader to load the example classes from jboss//lib/example.jar. (The same would apply to any other WARs or EARs in the same server instance, assuming no class-loading overrides.)

class-loading 声明在您有两个不同版本的 example.jar 的情况下(例如)是必要的:- jboss//lib:example1.0.jar- WEB-INF/lib:example2.0.jar

The class-loading declaration is necessary in cases (such as) where you have two different versions of example.jar: - jboss//lib: example1.0.jar - WEB-INF/lib: example2.0.jar

在这种情况下,JBoss 将为您的 WAR 创建一个独特且独立的类加载器,这将避免使用 jboss//lib/example1.0.jar 以支持 WEB-INF/lib/example2.0.jar 在您的 WAR 上下文中.

In this case, JBoss will create a unique and isolated classloader for your WAR which will avoid jboss//lib/example1.0.jar in favour of WEB-INF/lib/example2.0.jar in the context of your WAR.

总而言之,如果您只在 jboss 服务器实例中运行一个 WAR 和/或您没有冲突的 JAR 问题,请放弃 class-loading 声明并将您的 JAR 放在 jboss//lib.它使 WAR 文件更轻量级,整体部署可能更简单,并且在热部署期间您不会因额外的类版本而消耗额外的内存.

In summary, if you're only running one WAR in the jboss server instance and/or you have no conflicting JAR issues, ditch the class-loading declaration and put your JARs in jboss//lib. It makes the WAR file more lightweight, overall deployment may be simpler and you will not consume additional memory with extra class versions during hot-deploys.

这篇关于JBoss - 战争库依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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