13 Replies Latest reply: Aug 30, 2012 10:21 AM by fatbeard RSS

NoSuchMethodError on jbossesb-4.8

Changgeng Li Newbie

ISPN5.0.0.CR1

 

The stack trace is following. It seems to be caused a version conflict. The org.jboss.logging.Logger class is included in both jboss-common.jar and jboss-logging-3.0.0.Beta5.jar which is one of the dependencies this release needs. Hope there's a workaround for this issue.

 

 

java.lang.NoSuchMethodError: org.jboss.logging.Logger.getMessageLogger(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;

        at org.infinispan.util.logging.LogFactory.getLog(LogFactory.java:51)

        at org.infinispan.manager.DefaultCacheManager.<clinit>(DefaultCacheManager.java:120)

        at net.beaumaris.cachedeployer.InfinispanCacheDeployer.buildCacheManager(InfinispanCacheDeployer.java:175)

        at net.beaumaris.cachedeployer.InfinispanCacheDeployer.start(InfinispanCacheDeployer.java:83)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

        at java.lang.reflect.Method.invoke(Method.java:597)

        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.j

        ...

  • 1. NoSuchMethodError on jbossesb-4.8
    Galder Zamarreño Master

    I'm not sure this is a bug. Where is that jboss common jar coming from? The core module does not depend on that any more. As part of the JBoss TS upgrade for CR1 I had to battle with this issue cos jbossjta was bringing an old jboss-logging-spi version which caused this exception. So, you might wanna check whether the old jboss-logging-spi jar is coming from.

  • 2. Re: NoSuchMethodError on jbossesb-4.8
    Erik Salter Newbie

    We need jboss-common-core to export the cache manager to JNDI. 

     

    I still get the java.lang.NoSuchMethodError even after excluding the old jboss-logging-spi,

     

     

        <dependency>
          <groupId>org.jboss</groupId>
          <artifactId>jboss-common-core</artifactId>
          <version>2.2.16.GA</version>
          <scope>compile</scope>
          <exclusions>
            <exclusion>
              <artifactId>jboss-logging-spi</artifactId>
              <groupId>org.jboss.logging</groupId>
            </exclusion>
          </exclusions>
        </dependency>
    

     

     

    EDIT:  I rewrote the above application to remove the dependency on jboss-common-core, and I still get the same error.

  • 3. NoSuchMethodError on jbossesb-4.8
    Changgeng Li Newbie

    jboss-common.jar is at JBOSS_ESB_HOME/lib directory. The jboss-logging related classes are in this jar file.

    Our application need to be run in jboss esb server 4.8.

  • 4. NoSuchMethodError on jbossesb-4.8
    Galder Zamarreño Master

    If the issue is due to an incompatibility between the jars Infinispan needs and the jars ESB provides, so your only solution is to isolate the deployment that uses Infinispan in order to avoid loading the wrong jboss logging jar.

  • 5. Re: NoSuchMethodError on jbossesb-4.8
    Erik Salter Newbie

    I isolated the classloader according to http://community.jboss.org/wiki/ClassLoadingConfiguration

     

    The SAR jboss-service.xml file looks like:

     

     

    <server>
         <loader-repository>
              org.infinispan:archive=infinispan-deployer.sar 
         </loader-repository>
    </server>
    

     

     

    Different NoClassDefFound issue.

     

    Problem starting service net.beaumaris:InfinispanCacheDeployer=InfinispanCacheDeployer
    java.lang.NoClassDefFoundError: org/infinispan/lifecycle/AbstractModuleLifecycle
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
            at org.jboss.mx.loading.RepositoryClassLoader.findClassLocally(RepositoryClassLoader.java:690)
            at org.jboss.mx.loading.RepositoryClassLoader.findClass(RepositoryClassLoader.java:670)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
            at org.jboss.mx.loading.RepositoryClassLoader.loadClassLocally(RepositoryClassLoader.java:200)
            at org.jboss.mx.loading.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:131)
            at org.jboss.mx.loading.LoadMgr3.nextTask(LoadMgr3.java:399)
            at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:527)
            at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:415)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
            at org.infinispan.util.Util.loadClassStrict(Util.java:101)
            at org.infinispan.util.ModuleProperties.resolveModuleLifecycles(ModuleProperties.java:137)
            at org.infinispan.factories.AbstractComponentRegistry.<clinit>(AbstractComponentRegistry.java:107)
            at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:257)
            at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:232)
    

     

     

  • 6. NoSuchMethodError on jbossesb-4.8
    Galder Zamarreño Master

    Hmmm, that could well be a bug in loadClassStrict because it does not deal with NoClassDefFoundError cases. I'll create one.

  • 7. Re: NoSuchMethodError on jbossesb-4.8
    Erik Salter Newbie

    I have a workaround for now:

     

    I used the Maven Shade plugin on infinispan-core/pom.xml to shade the org.jboss.logging package.  Then I changed the application to use it as a provided dependency. 

     

    ...
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.4</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <relocations>
                    <relocation>
                      <pattern>org.jboss.logging</pattern>
                      <shadedPattern>org.shaded.logging</shadedPattern>
                    </relocation>
                  </relocations>
                </configuration>
              </execution>
            </executions>
          </plugin>         
    

     

  • 8. Re: NoSuchMethodError on jbossesb-4.8
    Galder Zamarreño Master

    Nice little plugin Erik, I wasn't aware of it though we had discussed jarjar internally. I've added this tip to http://community.jboss.org/docs/DOC-13439

  • 9. Re: NoSuchMethodError on jbossesb-4.8
    fatbeard Newbie

    Sorry, to drag up an old thread but i've tried following the instructions you gave in that link Galder. I've downloaded infinispan 5.1.6 source. Edited the pom.xml file in the route of package. Then i ran "mvn package -Dmaven.test.skip.exec=true" to build infinispan-core.

     

    The build ran successfully, but when I look at the resulting jars, they don't seem to have been shaded. I expect to see in the 3rd party libraries org.shaded.logging instead of org.jboss.logging, but i don't see it.

     

    Any ideas?

     

     

    The following is in the distribution profile of the pom.xml (does it matter that i ran mvn with package rather than distribution?)

    config used:

     

                                           <plugin>

                                                    <groupId>org.apache.maven.plugins</groupId>

                                                    <artifactId>maven-shade-plugin</artifactId>

                                                    <version>1.7.1</version>

                                                    <configuration>

                                                            <relocations>

                                                                    <relocation>

                                                                            <pattern>org.jboss.logging</pattern>

                                                                            <shadedPattern>org.shaded.logging</shadedPattern>

                                                                    </relocation>

                                                                    <relocation>

                                                                            <pattern>javax.transaction</pattern>

                                                                            <shadedPattern>javax.shaded.transaction</shadedPattern>

                                                                    </relocation>

                                                                    <relocation>

                                                                            <pattern>org.osgi</pattern>

                                                                            <shadedPattern>org.shaded.osgi</shadedPattern>

                                                                    </relocation>

                                                                    <relocation>

                                                                            <pattern>org.codehaus</pattern>

                                                                            <shadedPattern>org.shaded.codehaus</shadedPattern>

                                                                    </relocation>

                                                            </relocations>

                                                    </configuration>

                                                    <executions>

                                                            <execution>

                                                                    <phase>package</phase>

                                                                    <goals>

                                                                            <goal>shade</goal>

                                                                    </goals>

                                                            </execution>

                                                    </executions>

                                            </plugin>

  • 10. Re: NoSuchMethodError on jbossesb-4.8
    Erik Salter Newbie

    Hi Bryan,

     

    Here's the POM I use for building my version of ISPN.

  • 11. Re: NoSuchMethodError on jbossesb-4.8
    fatbeard Newbie

    Appreciated Erik, that seems to have done the job. Testing it out at the minute. I originally had the plugin under PluginManagement rather than in a Plugins element of it's own.

     

    Brian.

  • 12. Re: NoSuchMethodError on jbossesb-4.8
    Galder Zamarreño Master

    If the plugin is defined in the distribution profile, you need to run: mvn package -Pdistribution

     

    So that the distribution profile kicks in.

  • 13. Re: NoSuchMethodError on jbossesb-4.8
    fatbeard Newbie

    Thanks Galder, I twigged that all right after working through the maven documentation. If I recall correctly the shade plugin generated a nullpointer exception in this pom.xml. However, when i ran it from the infinispan-5.1.6/core/pom.xml in the position outlined by Erik (/project/build/plugins/plugin), it worked fine, when just building core.

     

     

    Edit: Corrected the xpath used above.