Over a million developers have joined DZone.

Mule ESB and the NoSuchMethodError: org.mule.util.ClassUtils.getClass exception

· Integration Zone

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Currently I am adding some SAML related functionality to a Mule3 implementation of one of our clients. To work with the SAML objects I make use of the OpenSAML library that is provided here as open source.

I added the following dependencies to my pom.xml to make it work:

<!-- SAML dependencies -->
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml</artifactId>
  <version>2.5.1-1</version>
</dependency>
<dependency>
  <groupId>joda-time</groupId>
  <artifactId>joda-time</artifactId>
  <version>2.1</version>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>openws</artifactId>
  <version>1.4.2-1</version>
</dependency>
<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>xmltooling</artifactId>
  <version>1.3.2-1</version>
  <exclusions>
    <exclusion>
      <artifactId>log4j-over-slf4j</artifactId>
      <groupId>org.slf4j</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.7.2</version>
</dependency>

However, after adding these dependencies and running a test with the Mule instance I received this exception:

java.lang.NoSuchMethodError: org.mule.util.ClassUtils.getClass(Ljava/lang/String;Z)Ljava/lang/Class;
at org.mule.util.ClassUtils.initializeClass(ClassUtils.java:356)
at org.mule.lifecycle.NotificationLifecycleObject.(NotificationLifecycleObject.java:45)
at org.mule.lifecycle.phases.MuleContextStopPhase.(MuleContextStopPhase.java:66)
at org.mule.lifecycle.phases.MuleContextStopPhase.(MuleContextStopPhase.java:56)
at org.mule.lifecycle.RegistryBrokerLifecycleManager.registerPhases(RegistryBrokerLifecycleManager.java:43)
at org.mule.lifecycle.RegistryLifecycleManager.(RegistryLifecycleManager.java:57)
at org.mule.lifecycle.RegistryBrokerLifecycleManager.(RegistryBrokerLifecycleManager.java:33)
at org.mule.registry.AbstractRegistryBroker.(AbstractRegistryBroker.java:37)
at org.mule.registry.DefaultRegistryBroker.(DefaultRegistryBroker.java:27)
at org.mule.DefaultMuleContext.createRegistryBroker(DefaultMuleContext.java:159)
at org.mule.DefaultMuleContext.(DefaultMuleContext.java:150)
at org.mule.context.DefaultMuleContextBuilder.buildMuleContext(DefaultMuleContextBuilder.java:89)
at org.mule.context.DefaultMuleContextFactory.buildMuleContext(DefaultMuleContextFactory.java:199)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:189)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:75)
at org.mule.tck.AbstractMuleTestCase.createMuleContext(AbstractMuleTestCase.java:520)
at org.mule.tck.AbstractMuleTestCase.setUp(AbstractMuleTestCase.java:446)
at junit.framework.TestCase.runBare(TestCase.java:132)
at org.mule.tck.AbstractMuleTestCase.runBare(AbstractMuleTestCase.java:301)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at org.mule.tck.AbstractMuleTestCase.run(AbstractMuleTestCase.java:280)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:208)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:158)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:86)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:95)


Which was weird because I wouldn’t expect OpenSAML libraries to influence the org.mule.util package! After googling around I discovered that the exception is caused when an older version of Apache commons-lang is being put on the classpath. So by excluding this dependency from the project the issue was fixed:

<dependency>
  <groupId>org.opensaml</groupId>
  <artifactId>opensaml</artifactId>
  <version>2.5.1-1</version>
  <exclusions>
    <exclusion>
      <artifactId>commons-lang</artifactId>
      <groupId>commons-lang</groupId>
    </exclusion>
  </exclusions>
</dependency>

Just too bad that the message looks like to suggest there is something wrong with the Mule libraries. With this exclusion in place the ‘commons-lang-2.1.jar’ is not added to the classpath but the ‘commons-lang-2.4.jar’ which is expected by Mule to be available.

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

Topics:

Published at DZone with permission of Pascal Alma, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}