0 Replies Latest reply on Jul 10, 2012 5:45 AM by Tullio Bettinazzi

    Linkage error deployng slf4j.

    Tullio Bettinazzi Newbie

      I'm tryng to deploy my web application using a war.

       

      If I deploy it with everything in my war everithing works.

       

      Now I'm trying to make some libraries as shared (in my test case slf4j) and then I created a module :

       

      <module xmlns="urn:jboss:module:1.1" name="axioma.pax">

          <resources>

              <resource-root path="slf4j-log4j12-1.6.1.jar"/>

              <resource-root path="slf4j-api-1.6.1.jar"/>

              <resource-root path="log4j-1.2.16.jar"/>

          </resources>

          <dependencies>

              <module name="org.slf4j"/>

          </dependencies>

      </module>

       

      Then I defined such module as global module in standalone.xml :

              <subsystem xmlns="urn:jboss:domain:ee:1.0">

                  <global-modules>

                      <module name="axioma.pax" slot="main"/>

                  </global-modules>

              </subsystem>

       

      Finaly I inserted in the WEB-INF of my war the following jboss-deployment-structure.xml :

      <jboss-deployment-structure>

        <!-- This corresponds to the top level deployment. For a war this is the war's module, for an ear -->

        <!-- This is the top level ear module, which contains all the classes in the EAR's lib folder     -->

        <deployment>

          <!-- Exclusions allow you to prevent the server from automatically adding some dependencies     -->

          <exclusions>

              <module name="org.slf4j" />

              <module name="org.slf4j.impl" />

              <module name="org.slf4j.ext" />

              <module name="org.slf4j.jcl-over-slf4j" />

          </exclusions>

          <!-- This allows you to define additional dependencies, it is the same as using the Dependencies: manifest attribute -->

          <dependencies>

            <module name="axioma.pax" />

          </dependencies>

        </deployment>

      </jboss-deployment-structure>

       

      When I deploy my war I get :

      11:18:26,350 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/]] (MSC service thread 1-1) Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lifecycleBeanPostProcessor' defined in URL [vfs:/I:/Jboss/bin/content/oc-1.5.0.war/WEB-INF/classes/oc-context.xml]: Instantiation of bean failed; nested exception is java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.slf4j.impl.Log4jLoggerFactory.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/impl/Log4jLoggerFactory, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface org/slf4j/ILoggerFactory have different Class objects for the type org/slf4j/Logger used in the signature

          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:707) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:449) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]

          at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]

          at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)

          at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)

          at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) [rt.jar:1.6.0_31]

          at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.6.0_31]

          at java.lang.Thread.run(Unknown Source) [rt.jar:1.6.0_31]

      Caused by: java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.slf4j.impl.Log4jLoggerFactory.getLogger(Ljava/lang/String;)Lorg/slf4j/Logger;" the class loader (instance of org/jboss/modules/ModuleClassLoader) of the current class, org/slf4j/impl/Log4jLoggerFactory, and the class loader (instance of org/jboss/modules/ModuleClassLoader) for interface org/slf4j/ILoggerFactory have different Class objects for the type org/slf4j/Logger used in the signature

          at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:81) [slf4j-log4j12-1.6.1.jar:1.6.1]

          at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:53) [slf4j-log4j12-1.6.1.jar:1.6.1]

          at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) [slf4j-api-1.6.1.jar:1.6.1]

          at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111) [slf4j-api-1.6.1.jar:1.6.1]

          at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268) [slf4j-api-1.6.1.jar:1.6.1]

          at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241) [slf4j-api-1.6.1.jar:1.6.1]

          at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254) [slf4j-api-1.6.1.jar:1.6.1]

          at org.apache.shiro.spring.LifecycleBeanPostProcessor.<clinit>(LifecycleBeanPostProcessor.java:51) [shiro-spring-1.2.0.jar:1.2.0]

          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.6.0_31]

          at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]

          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) [rt.jar:1.6.0_31]

          at java.lang.reflect.Constructor.newInstance(Unknown Source) [rt.jar:1.6.0_31]

          at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]

          ... 20 more

         

      What's wrong ?

      Did I forget something ?

      I tried also to delete dependencies in my jboss-deployment-structure.xml in order to see if error changed but it seems to ignore the dependency and exclusions.

      Tks

      Tullio