Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFound: oro #126

Open
asleson opened this issue Dec 29, 2016 · 6 comments
Open

NoClassDefFound: oro #126

asleson opened this issue Dec 29, 2016 · 6 comments

Comments

@asleson
Copy link

asleson commented Dec 29, 2016

Hi,

I'm using version 2.4.0 of the Gradle Cobertura plugin. While attempting to integrate it into my current project, I get this error when running the cobertura task:

Caused by: java.lang.NoClassDefFoundError: org/apache/oro/text/regex/MalformedPatternException
	at net.sourceforge.cobertura.dsl.Cobertura.<init>(Cobertura.java:61)
	at net.sourceforge.cobertura.reporting.ReportMain.parseArgumentsAndReport(ReportMain.java:91)
	at net.sourceforge.cobertura.reporting.ReportMain.generateReport(ReportMain.java:141)
	... 107 more
Caused by: java.lang.ClassNotFoundException: org.apache.oro.text.regex.MalformedPatternException
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at net.saliman.gradle.plugin.cobertura.util.ChildFirstUrlClassLoader.loadClass(ChildFirstUrlClassLoader.java:66)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 110 more
:generateCoberturaReport FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///Users/asleson/dev/penta-g/build/gradle-build/reports/tests/test/index.html

It's complaining about not finding a class in the oro project. I thought this was strange, so I tried adding it to the classpath, just to see if the error would go away:

compile "oro:oro:2.0.8"

I still get the NoClassDefFoundError output.

Any idea why? I would think that all the necessary dependencies would be downloaded from the repository.

I know there are unit tests that are failing, but still, this shouldn't cause Cobertura to fail, especially with a NoClassDefFoundError should it?

Thank you!!

@stevesaliman
Copy link
Owner

What happens if you just run gradle test? Do you get the same message about the class not being found?

@asleson
Copy link
Author

asleson commented Dec 30, 2016

The test task runs ok, ignoring the fact that there are failing tests:

1911 tests completed, 1142 failed, 4 skipped
:test FAILED
:generateCoberturaReport SKIPPED
:performCoverageCheck SKIPPED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.

Since Cobertura doesn't run on only the test task (right?) so I wouldn't expect to see the NoClassDefFoundError here, and I don't.

@stevesaliman
Copy link
Owner

So I think we can rule out problems with the test's classpath...

I'm not exactly sure what is happening here. I took a closer look at where oro comes in, and it is used by Cobertura itself, which means it should be brought in automatically when the plugin is added to the buildscript's dependencies. The 2 things that come to mind:

  1. What does your cobertura block look like?
  2. When you run gradle dependencies, does oro show up in the cobertura section? In my project, I see oro show up as a dependency of cobertura, which is a dependency of the cobertura configuration.

@asleson
Copy link
Author

asleson commented Dec 30, 2016

The cobertura block looks like this:

cobertura {
  coverageFormats = ["xml", "html"]
}

When I run gradle dependencies I get this output for Cobertura:

cobertura
\--- net.sourceforge.cobertura:cobertura:2.1.1

Oro does show up under this heading:

default - Configuration for default artifacts.

(it's a ways down in the list):

+--- oro:oro:2.0.8

@stevesaliman
Copy link
Owner

There is nothing in your cobertura block that should effect classpaths, and cobertura itself is being brought in. When cobertura is brought in it should include cobertura's transitive dependencies, including oro, but that doesn't seem to be happening here. Adding oro as a direct dependency shouldn't change its appearance in the cobertura section. Do any transitive dependencies show up? Is this a single module build, or multi-module? And what version of Gradle are you using?

@thadguidry
Copy link
Contributor

I have updated the Wiki with Gradle usage and Jenkins section and a new Troubleshooting section to provide info on how to resolve these kinds of problems in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants