How to configure JBOSS 5.1.0 GA ClassLoader

I am facing some problems trying to load libs from my application instead of what comes with JBoss.

I try to use the latest and best SLF4J in my application, and in doing so I get the following messages:

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. 

In my application, I have the following banks located in my WAR lib directory:

  • July to SLF4J-1.6.1.jar
  • SLF4J-api-1.6.1.jar
  • SLF4J-log4j12-1.6.1.jar

My project is being deployed as an EAR with WAR. All libraries are in WAR.

Based on some research, it was suggested that a jboss-classloading.xml file is created for JBoss 5.1. I created one for my 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> 

This means that the EAR file is loaded first.

I also created one for my 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> 

In this configuration, I get the following error in the startup logs:

 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) 

What is the correct way to load jars from my project to JBoss?

+6
source share
2 answers

You should use something like:

 <jboss-app> <loader-repository> com.example:archive=unique-archive-name </loader-repository> </jboss-app> 

in META-INF / jboss-app.xml to define your own class loader.

We use it for our own deployment of Hibernate ATMs inside the application.

See https://community.jboss.org/wiki/ClassLoadingConfiguration for more details.

0
source

I know this thread is very old, but today I had a similar problem, so I think the problem itself can happen to someone.

I needed to run two similar β€œears” in different contexts with the same package / class names inside my subprojects (JBoss 5.1.0 GA).

So, after some research and attempts to use the full version of "jboss-classloading.xml" presented here and by some blogs, I used a simpler version of the file "jboss-classloading.xml" on my EAR (without any specific 'jboss-classloading .xml 'for my JAR / WAR / etc subprojects):

 <classloading xmlns="urn:jboss:classloading:1.0" domain="IsolatedDomain" export-all="NON_EMPTY" import-all="true"> </classloading> 

This has been included in the EAR catalog of the META-INF project . Hope this helps others with similar problems.

I got a working version from this site:

https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html

0
source

Source: https://habr.com/ru/post/900481/


All Articles