如何配置JBOSS 5.1.0 GA ClassLoader

boy*_*715 6 jboss classloader

我试图从我的应用程序加载libs而不是JBoss附带的问题时遇到了一些问题.

我试图在我的应用程序中使用最新和最好的SLF4J,并且这样做我收到以下消息:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [vfszip:/C:/devtools/workspace/g2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1302541739184/deploy/ecotrakEar.ear/ecotrak.war/WEB-INF/lib/slf4j-log4j12-1.6.1.jar/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [vfszip:/C:/devtools/jboss-5.1.0.GA/common/lib/slf4j-jboss-logging.jar/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Run Code Online (Sandbox Code Playgroud)

在我的应用程序中,我在WAR lib目录中有以下jar:

  • 七月至SLF4J-1.6.1.jar
  • SLF4J-API-1.6.1.jar
  • SLF4J-log4j12-1.6.1.jar

我的项目部署为带有WAR的EAR.所有库都驻留在WAR中.

根据一些研究,有人建议为JBoss 5.1创建一个jboss-classloading.xml文件.我为我的EAR创建了一个:

<classloading xmlns="urn:jboss:classloading:1.0"
  name="ecotrak.ear"
  domain="ecotrak.ear"
  export-all="NON_EMPTY"
  import-all="true"
  parent-first="false">
</classloading>
Run Code Online (Sandbox Code Playgroud)

这标识了首先加载EAR文件.

我还为我的WAR创建了一个:

<classloading xmlns="urn:jboss:classloading:1.0"
  name="ecotrak.war"
  domain="ecotrak.war"
  parent-domain="ecotrak.ear"
  top-level-classloader="true"
  export-all="NON_EMPTY"
  import-all="true"
  parent-first="true">
</classloading>
Run Code Online (Sandbox Code Playgroud)

使用此配置,我在启动日志中收到以下错误:

11:18:07,949 ERROR [[/ecotrak]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.trace(SLF4JLocationAwareLog.java:107)
Run Code Online (Sandbox Code Playgroud)

在JBoss之前加载来自我项目的jar的正确方法是什么?

vim*_*vim 0

你应该使用类似的东西:

<jboss-app>
   <loader-repository> 
   com.example:archive=unique-archive-name 
   </loader-repository> 
</jboss-app>
Run Code Online (Sandbox Code Playgroud)

在 META-INF/jboss-app.xml 中定义自己的类加载器。

我们将它用于应用程序内自己的 Hibernate jar 部署。

有关详细信息,请参阅https://community.jboss.org/wiki/ClassLoadingConfiguration