jboss7.x - slf4j don't work in JBOSS when using openJpa module -
my ear application runs fine when don't use openjpa. once use open jpa "slf4j fail load class blaaa ". how configure openjpa module use sl4j provide pom.xml , avoid error?
i use jboss 7.1.1
pom.xml
<properties> <slf4j.version>1.7.3</slf4j.version> <logback.version>1.0.10</logback.version> </properties> <dependency> <groupid>org.slf4j</groupid> <artifactid>slf4j-api</artifactid> <version>${slf4j.version}</version> </dependency> <dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-classic</artifactid> <version>${logback.version}</version> </dependency> <dependency> <groupid>ch.qos.logback</groupid> <artifactid>logback-core</artifactid> <version>${logback.version}</version> </dependency>
.......
openjpa module.xml
<module xmlns="urn:jboss:module:1.1" name="org.apache.openjpa"> <resources> <resource-root path="openjpa-2.2.0.jar"/> <resource-root path="openjpa-all-2.2.0.jar"/> </resources> <dependencies> <module name="javax.persistence.api"/> <module name="javax.transaction.api"/> <module name="javax.validation.api"/> <module name="org.apache.commons.lang"/> <module name="org.apache.commons.collections"/> <module name="org.slf4j"/> </dependencies> </module>
jboss-deployment-structure.xml
<?xml version="1.0" encoding="utf-8"?> <jboss-deployment-structure> <deployment> <!-- exclusions allow prevent server automatically adding dependencies --> <exclusions> <module name="org.slf4j" /> <module name="org.slf4j.impl" /> </exclusions> </deployment> </jboss-deployment-structure>
error
10:17:53,854 error [stderr] (msc service thread 1-4) slf4j: failed load class "org.slf4j.impl.staticloggerbinder". 10:17:53,860 error [stderr] (msc service thread 1-4) slf4j: defaulting no-operation (nop) logger implementation 10:17:53,866 error [stderr] (msc service thread 1-4) slf4j: see http://www.slf4j.org/codes.html#staticloggerbinder further details. 10:17:53,873 severe [javax.enterprise.resource.webcontainer.jsf.config] (msc service thread 1-4) critical error during deployment: : java.lang.linkageerror: loader constraint violation: when resolving interface method "org.slf4j.iloggerfactory.getlogger(ljava/lang/string;)lorg/slf4j/logger;" class loader (instance of org/jboss/modules/moduleclassloader) of current class, org/slf4j/loggerfactory, , class loader (instance of org/jboss/modules/moduleclassloader) resolved class, org/slf4j/iloggerfactory, have different class objects type org/slf4j/logger used in signature @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:242) [openjpa-all-2.2.0.jar:2.2.0] @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:254) [openjpa-all-2.2.0.jar:2.2.0] @ net.sf.ehcache.cachemanager.<clinit>(cachemanager.java:131) [ehcache-ee-2.6.2.jar:] @ com.zreflect.emyed.whiteboard.controller.cachecontroller.<init>(cachecontroller.java:39) [classes:] @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) [rt.jar:1.6.0_25] @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) [rt.jar:1.6.0_25] @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) [rt.jar:1.6.0_25] @ java.lang.reflect.constructor.newinstance(constructor.java:513) [rt.jar:1.6.0_25] @ java.lang.class.newinstance0(class.java:355) [rt.jar:1.6.0_25] @ java.lang.class.newinstance(class.java:308) [rt.jar:1.6.0_25] @ com.sun.faces.mgbean.beanbuilder.newbeaninstance(beanbuilder.java:188) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanbuilder.build(beanbuilder.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.createandpush(beanmanager.java:409) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:269) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:256) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.config.configurelistener.contextinitialized(configurelistener.java:255) [jsf-impl-2.1.7-jbossorg-2.jar:] @ org.apache.catalina.core.standardcontext.contextlistenerstart(standardcontext.java:3392) [jbossweb-7.0.13.final.jar:] @ org.apache.catalina.core.standardcontext.start(standardcontext.java:3850) [jbossweb-7.0.13.final.jar:] @ org.jboss.as.web.deployment.webdeploymentservice.start(webdeploymentservice.java:90) [jboss-as-web-7.1.1.final.jar:7.1.1.final] @ org.jboss.msc.service.servicecontrollerimpl$starttask.startservice(servicecontrollerimpl.java:1811) @ org.jboss.msc.service.servicecontrollerimpl$starttask.run(servicecontrollerimpl.java:1746) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) [rt.jar:1.6.0_25] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) [rt.jar:1.6.0_25] @ java.lang.thread.run(thread.java:662) [rt.jar:1.6.0_25] 10:17:54,007 error [org.apache.catalina.core.containerbase.[jboss.web].[default-host].[/emyed-whiteboard]] (msc service thread 1-4) exception sending context initialized event listener instance of class com.sun.faces.config.configurelistener: java.lang.runtimeexception: java.lang.linkageerror: loader constraint violation: when resolving interface method "org.slf4j.iloggerfactory.getlogger(ljava/lang/string;)lorg/slf4j/logger;" class loader (instance of org/jboss/modules/moduleclassloader) of current class, org/slf4j/loggerfactory, , class loader (instance of org/jboss/modules/moduleclassloader) resolved class, org/slf4j/iloggerfactory, have different class objects type org/slf4j/logger used in signature @ com.sun.faces.config.configurelistener.contextinitialized(configurelistener.java:292) [jsf-impl-2.1.7-jbossorg-2.jar:] @ org.apache.catalina.core.standardcontext.contextlistenerstart(standardcontext.java:3392) [jbossweb-7.0.13.final.jar:] @ org.apache.catalina.core.standardcontext.start(standardcontext.java:3850) [jbossweb-7.0.13.final.jar:] @ org.jboss.as.web.deployment.webdeploymentservice.start(webdeploymentservice.java:90) [jboss-as-web-7.1.1.final.jar:7.1.1.final] @ org.jboss.msc.service.servicecontrollerimpl$starttask.startservice(servicecontrollerimpl.java:1811) @ org.jboss.msc.service.servicecontrollerimpl$starttask.run(servicecontrollerimpl.java:1746) @ java.util.concurrent.threadpoolexecutor$worker.runtask(threadpoolexecutor.java:886) [rt.jar:1.6.0_25] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:908) [rt.jar:1.6.0_25] @ java.lang.thread.run(thread.java:662) [rt.jar:1.6.0_25] caused by: java.lang.linkageerror: loader constraint violation: when resolving interface method "org.slf4j.iloggerfactory.getlogger(ljava/lang/string;)lorg/slf4j/logger;" class loader (instance of org/jboss/modules/moduleclassloader) of current class, org/slf4j/loggerfactory, , class loader (instance of org/jboss/modules/moduleclassloader) resolved class, org/slf4j/iloggerfactory, have different class objects type org/slf4j/logger used in signature @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:242) [openjpa-all-2.2.0.jar:2.2.0] @ org.slf4j.loggerfactory.getlogger(loggerfactory.java:254) [openjpa-all-2.2.0.jar:2.2.0] @ net.sf.ehcache.cachemanager.<clinit>(cachemanager.java:131) [ehcache-ee-2.6.2.jar:] @ com.zreflect.emyed.whiteboard.controller.cachecontroller.<init>(cachecontroller.java:39) [classes:] @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) [rt.jar:1.6.0_25] @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:39) [rt.jar:1.6.0_25] @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:27) [rt.jar:1.6.0_25] @ java.lang.reflect.constructor.newinstance(constructor.java:513) [rt.jar:1.6.0_25] @ java.lang.class.newinstance0(class.java:355) [rt.jar:1.6.0_25] @ java.lang.class.newinstance(class.java:308) [rt.jar:1.6.0_25] @ com.sun.faces.mgbean.beanbuilder.newbeaninstance(beanbuilder.java:188) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanbuilder.build(beanbuilder.java:102) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.createandpush(beanmanager.java:409) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:269) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.mgbean.beanmanager.create(beanmanager.java:256) [jsf-impl-2.1.7-jbossorg-2.jar:] @ com.sun.faces.config.configurelistener.contextinitialized(configurelistener.java:255) [jsf-impl-2.1.7-jbossorg-2.jar:] ... 8 more
it looks you're getting 2 different versions of sfl4j. add <scope>provided</scope>
slf4j dependency. other option provide jboss-deployment-structure.xml exclude servers slf4j.
example jboss-deployment-structure.xml:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclusions> <module name="org.slf4j" /> </exclusions> </deployment> </jboss-deployment-structure>
also make sure don't have transitive slf4j dependencies, sfl4j-jdk14.jar.