I recently stumbled on a ClassCastException on using the following piece code in a web app deployed on JBoss:
LoggerContext logCtx = (LoggerContext) LoggerFactory.getILoggerFactory();
After some digging I managed to figure out the reason.
JBoss root classloader already uses slf4j for its own puropses and probably binds its own implementation. When the web app classloader kicks in, it's already too late, the slf4j is already bound.
A solution would be to intervene at the web app running and load JBoss's slf4j library. I have done that by adding JBoss specific deployment descriptor to the WEB-INF directory, namely, the file jboss-deployment-structure.xml:
<?xml version="1.0"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
<exclusions>
<module name="org.slf4j"/>
</exclusions>
</deployment>
<jboss-deployment-structure>
Friday, 8 January 2016
Subscribe to:
Comments (Atom)
Blog Archive
-
►
2018
(9)
- ► 08/05 - 08/12 (2)
- ► 07/01 - 07/08 (2)
- ► 06/17 - 06/24 (2)
- ► 05/20 - 05/27 (2)
- ► 05/13 - 05/20 (1)
-
▼
2016
(6)
- ► 03/13 - 03/20 (2)
- ► 02/14 - 02/21 (2)
- ► 01/10 - 01/17 (1)
-
►
2015
(2)
- ► 12/20 - 12/27 (1)
- ► 12/06 - 12/13 (1)
-
►
2010
(2)
- ► 09/26 - 10/03 (1)
- ► 03/07 - 03/14 (1)
-
►
2009
(2)
- ► 11/08 - 11/15 (1)
- ► 09/20 - 09/27 (1)
