DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Integrating FitNesse with Selenium
  • Modern Test Automation With AI (LLM) and Playwright MCP
  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Debugging With Confidence in the Age of Observability-First Systems

Trending

  • Implementing Explainable AI in CRM Using Stream Processing
  • How to Introduce a New API Quickly Using Micronaut
  • Useful System Table Queries in Relational Databases
  • Introducing Graph Concepts in Java With Eclipse JNoSQL, Part 2: Understanding Neo4j
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Mule ClassNotFoundException When Running Tests

Mule ClassNotFoundException When Running Tests

By 
Justin Saliba user avatar
Justin Saliba
·
Aug. 04, 14 · Interview
Likes (0)
Comment
Save
Tweet
Share
8.9K Views

Join the DZone community and get the full member experience.

Join For Free

The Issue

Running tests with Mule sometimes throws a ClassNotFoundException when it tries to lookup org.apache.commons.cli.ParseException. The following is the whole stack trace. If you’re encountering this, then this blog post is for you!

java.lang.NoClassDefFoundError: org/apache/commons/cli/ParseException
	at org.mule.tck.junit4.AbstractMuleTestCase.<clinit>(AbstractMuleTestCase.java:70)
	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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.cli.ParseException
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

The problem stems from the commons-cli-1.2 JAR file that’s installed by Studio when running the populate_m2_repo script. The aim of this script is to install several Mule JARs in your local Maven repository so that you do not need to download them during one of your build processes. This is what is shown in the logs when running the populate_m2_repo script from inside Studio:

[INFO] Installing /Users/justin/Downloads/AnypointStudio/plugins/org.mule.tooling.server.3.5.0.ee_3.5.0.201404290129/mule/lib/boot/commons-cli-1.2.jar to /Users/justin/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar

However, a few lines down, we get the following:

[INFO] Installing /Users/justin/Downloads/AnypointStudio/plugins/org.mule.tooling.server.3.5.0.ee_3.5.0.201404290129/mule/lib/opt/groovy-all-1.8.6.jar to /Users/justin/.m2/repository/commons-cli/commons-cli/1.2/commons-cli-1.2.jar

As you can see, the groovy-all JAR is overwriting the commons-cli JAR, resulting in a ClassNotFoundException.

The Fix

As a current workaround, remove the commons-cli-1.2 JAR file from your repository and run the Maven build process again. Maven will then download the correct commons-cli JAR from the central repository and your build should carry on without any problems. To verify whether you have the correct file, the real commons-cli JAR is only a few kilobytes in size. The incorrect commons-cli JAR (which really is groovy-all-1.8.6) is around 6.2 MB.

Why does this happen?

Opening up groovy-all-1.8.6.jar and searching for files called “pom.xml” results in only one file – that of commons-cli. The populate_m2_repo script is picking up this pom.xml file and subsequently overwrites the Apache Commons CLI JAR. It seems the Groovy guys are not packaging their own pom.xml with the groovy-all JAR, even though the real pom.xml can be found in the Central Maven Repository . This issue seems to remain in the latest nightly build of Groovy…

Hope this clears up any confusion you may have!

JAR (file format) Testing

Published at DZone with permission of Justin Saliba, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Integrating FitNesse with Selenium
  • Modern Test Automation With AI (LLM) and Playwright MCP
  • AI-Driven Test Automation Techniques for Multimodal Systems
  • Debugging With Confidence in the Age of Observability-First Systems

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!