Jenkins Cobertura build - NoClassDefFoundError - java

I have a test class ProcessorTest with the lines
JSONObject jsonObj = XML.toJSONObject(convert);
DBOb = (DBObject) JSON.parse(jsonObj.toString());
The XML class is from json.org. The class is used else where in the code without a problem.
Everything runs fine on localhost (i.e., all Maven and JUnit tests execute).
When I pushed to Jenkins I get this error:
Jenkins Error
Error Details
net/sourceforge/cobertura/coveragedata/TouchCollector
Stack Trace
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at org.json.XML.__cobertura_init(XML.java)
at org.json.XML.<clinit>(XML.java)
at ProcessorTest.classSetup(ProcessorTest.java:81)
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:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
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.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
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)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 26 more
I'm using Jenkins 1.553 and the Cobertura plugin 1.9.6.
How do I fix this?
The project structure is like this:
-- project1
|
| - core
| - Tests (includes the tests that fail)
-- org.json
|
| - XML.class
When pushed to Jenkins I assume the org.json project is unavailable for the tests.

This exception and stack trace is misleading; it actually results from not having SLF4J + ch.qos.logback included in your classpath (the .ant/lib path or some other classpath available to ant). Cobertura (up to and including 2.1.1, at least) has a specific requirement for the ch.qos.logback SLF4J implementation. If this SLF4J implementation is not included, then the following stack trace can result:
java.lang.NoClassDefFoundError: net/sourceforge/cobertura/coveragedata/TouchCollector
at [org.package.ClassName].__cobertura_init([ClassName].java)
at [org.package.ClassName].<clinit>([ClassName].java)
at [org.package.ClassName]Test.[method]([ClassName]Test.java:113)
Caused by: java.lang.ClassNotFoundException: net.sourceforge.cobertura.coveragedata.TouchCollector
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
In my case, I already had slf4j-simple-1.7.14.jar in my .ant/lib classpath, and I needed to remove it and replace it with logback-core-1.0.13.jar and logback-classic-1.0.13.jar. After that, my instrumented test cases executed without this exception.

Seems like you have a Java version different in your Jenkins machine. Try to install exactly the same version than you have on local.
More info here: https://github.com/cobertura/cobertura/issues/52

This strange behavior could also be related to a different Maven version on your Jenkins build machine than you use locally. It would also be of interest which version of the cobertura-maven-plugin you are using in your pom.xml.
The pure Cobertura library itself (bundled with the maven plugin of your project) uses a bunch of dependencies which might be in conflict with the Cobertura integration of the Jenkins environment. Try to check for asm.jar in your dependency tree. Maybe this causes runtime trouble in the jenkins environment as well.
A setup that works in my institution (with projects that include org.json dependencies):
latest Jenkins version 1.596 in combination with the Jenkins Cobertura-Plugin 1.9.6
latest cobertura-maven-plugin maven plugin for various projects in version 2.6
My strong guess: It is not about the JSON stuff itself, but about the environment of your setup; your Jenkins version 1.553 is a bit outdated. I would advice you to go for an upgrade if possible with your admins/other projects.

Related

maven java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap

Hi I'm getting this error in eclipse running maven using m2eclipse,
same error happens with any maven functionality (install, clean, ect.)
Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.google.common.collect.MapMaker.makeComputingMap(Lcom/google/common/base/Function;)Ljava/util/concurrent/ConcurrentMap; from class com.google.inject.internal.Annotations$AnnotationChecker
at com.google.inject.internal.Annotations$AnnotationChecker.<init>(Annotations.java:104)
at com.google.inject.internal.Annotations.<clinit>(Annotations.java:122)
at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:362)
at com.google.inject.Key.strategyFor(Key.java:354)
at com.google.inject.Key.get(Key.java:222)
at org.eclipse.sisu.wire.ParameterKeys.<clinit>(ParameterKeys.java:28)
at org.eclipse.sisu.wire.DependencyAnalyzer.<init>(DependencyAnalyzer.java:92)
at org.eclipse.sisu.wire.ElementAnalyzer.<init>(ElementAnalyzer.java:87)
at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:74)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:230)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:136)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:477)
at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:203)
at org.apache.maven.cli.MavenCli.container(MavenCli.java:400)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:207)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
the console points towards slf4j as the last constituent
constituent[39]: file:/C:/eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.5.1.20150109-1819/jars/slf4j-simple-1.7.5.jar
My projects maven depends on guava-17.0 and junit-4.10
This is caused by a bug which was fixed in October 2014. Upgrading Guice (and Guava with it) will solve the problem.
Seems like having a classloader issue with the version of guava that you are Using . for Quick Info go: Here
some issues mainly because of clashes between guava versions (15.0 in the driver vs 13.0.1*).
Upgrade to latest guava using maven or download the jar and it in your build path and add these lines in your weblogic.xml to deploy using your updated guava java .this worked for me.
Check Resolved issue here
<wls:prefer-application-packages>
<wls:package-name>com.ctc.wstx.*</wls:package-name>
<wls:package-name>org.codehaus.stax2.*</wls:package-name>
<wls:package-name>com.sun.xml.messaging.saaj.*</wls:package-name>
<wls:package-name>com.google.common.*</wls:package-name>
<wls:package-name>org.bouncycastle.*</wls:package-name>
</wls:prefer-application-packages>
I had this error and when I changed the jdk version to be 7 instead of 8 the issue disappeared.

SONARCLIPS 3.5.0 Invalid value of sonar.libraries IllegalStateException: No files nor directories matching Eclipse Mars

Should a new "Invalid value of sonar.libraries / IllegalStateException: No files nor directories matching" defect be reported against the SONARCLIPS 3.5. Or should I try to get defect SONARCLIPS-430 already fixed in SonarQube Eclipse Plugin 3.5 re-opened?
In Eclipse Mars (4.5.0) when I try to use SonarQube Eclipse Plugin 3.5.0.20150804 to analyze a project, it fails with the error
Invalid value of sonar.libraries
and the caused by exception
IllegalStateException: No files nor directories matching [...]
According to SONARCLIPS-430, SonarQube Eclipse 3.5 fixed this issue. But I'm running 3.5 and still encountering the problem. I'm not using Groovy for this project and SONARCLIPS-430 resulted from the stackoverflow question about groovy and SonarQube Eclipse: Sonar Eclipse issue.
The sonar.libraries involved in this analysis is (copied from sonar-project2243985040659442672.properties):
sonar.libraries=C:\tool\Java\jdk1.8.0_51\jre\lib\resources.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\rt.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jsse.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jce.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\charsets.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\jfr.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar,C:\tool\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar,C:/dev/prodtrunk/someProduct/PhysView/PhysViewApi/target/classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/test-classes,C:\mvnrepo\junit\junit\4.12\junit-4.12.jar,C:\mvnrepo\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar,C:\mvnrepo\log4j\log4j\1.2.17\log4j-1.2.17.jar,C:\mvnrepo\org\osgi\org.osgi.compendium\5.0.0\org.osgi.compendium-5.0.0.jar,C:\mvnrepo\org\osgi\org.osgi.core\5.0.0\org.osgi.core-5.0.0.jar,C:/dev/prodtrunk/someProduct/DeviceStructure/target/classes,C:/dev/prodtrunk/someProduct/DeviceStructure/target/test-classes,C:\mvnrepo\org\slf4j\slf4j-api\1.6.6\slf4j-api-1.6.6.jar,C:/dev/prodtrunk/JavaCommon/target/classes,C:/dev/prodtrunk/JavaCommon/target/test-classes,C:\mvnrepo\jython\jython\2.1\jython-2.1.jar,C:\mvnrepo\commons-codec\commons-codec\1.7\commons-codec-1.7.jar,C:\mvnrepo\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar,C:\mvnrepo\commons-cli\commons-cli\1.0\commons-cli-1.0.jar,C:/dev/prodtrunk/someProduct/Logging/Logging/target/classes,C:\mvnrepo\commons-lang\commons-lang\2.5\commons-lang-2.5.jar,C:\mvnrepo\commons-collections\commons-collections\3.2.1\commons-collections-3.2.1.jar,C:\mvnrepo\org\easymock\easymock\3.3.1\easymock-3.3.1.jar,C:\mvnrepo\cglib\cglib\3.1\cglib-3.1.jar,C:\mvnrepo\org\ow2\asm\asm\5.0.3\asm-5.0.3.jar,C:\mvnrepo\org\objenesis\objenesis\2.1\objenesis-2.1.jar,C:/dev/prodtrunk/someProduct/someProductCommon/target/classes,C:\mvnrepo\org\knopflerfish\bundle\desktop\5.0.1\desktop-5.0.1.jar,C:\mvnrepo\com\somecompany\someproduct\ActionProcessing\7.0.0.0-SNAPSHOT\ActionProcessing-7.0.0.0-SNAPSHOT.jar,C:/dev/prodtrunk/someProduct/CircuitManagement/CircuitStructure/target/classes,C:/dev/prodtrunk/someProduct/CircuitManagement/CircuitStructure/target/test-classes,C:/dev/prodtrunk/someProduct/JavaCommon_Bundle/target/classes,C:\mvnrepo\org\hibernate\hibernate-envers\3.6.4.Final\hibernate-envers-3.6.4.Final.jar,C:\mvnrepo\org\hibernate\hibernate-core\3.6.4.Final\hibernate-core-3.6.4.Final.jar,C:\mvnrepo\antlr\antlr\2.7.6\antlr-2.7.6.jar,C:\mvnrepo\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar,C:\mvnrepo\javax\transaction\jta\1.1\jta-1.1.jar,C:\mvnrepo\org\hibernate\hibernate-commons-annotations\3.2.0.Final\hibernate-commons-annotations-3.2.0.Final.jar,C:\mvnrepo\org\hibernate\hibernate-entitymanager\3.6.4.Final\hibernate-entitymanager-3.6.4.Final.jar,C:\mvnrepo\cglib\cglib\2.2\cglib-2.2.jar,C:\mvnrepo\asm\asm\3.1\asm-3.1.jar,C:\mvnrepo\javassist\javassist\3.12.0.GA\javassist-3.12.0.GA.jar,C:\mvnrepo\org\hibernate\hibernate-tools\3.2.0.ga\hibernate-tools-3.2.0.ga.jar,C:\mvnrepo\org\beanshell\bsh\2.0b4\bsh-2.0b4.jar,C:\mvnrepo\freemarker\freemarker\2.3.8\freemarker-2.3.8.jar,C:\mvnrepo\org\hibernate\jtidy\r8-20060801\jtidy-r8-20060801.jar,C:\mvnrepo\org\hibernate\javax\persistence\hibernate-jpa-2.0-api\1.0.0.Final\hibernate-jpa-2.0-api-1.0.0.Final.jar,C:/dev/prodtrunk/someProduct/DatabaseCommon/target/classes,C:/dev/prodtrunk/someProduct/LegacyCommunicationsApi/target/classes,C:/dev/prodtrunk/someProduct/Automation/automation-common/target/classes,C:/dev/prodtrunk/someProduct/DSLink_bundle/target/classes,C:\mvnrepo\org\iot-dsa\dslink\0.8.0\dslink-0.8.0.jar,C:\mvnrepo\org\iot-dsa\logging\0.8.0\logging-0.8.0.jar,C:\mvnrepo\org\iot-dsa\runtime_shared\0.8.0\runtime_shared-0.8.0.jar,C:\mvnrepo\io\vertx\vertx-core\2.1.5\vertx-core-2.1.5.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-databind\2.2.2\jackson-databind-2.2.2.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-annotations\2.2.2\jackson-annotations-2.2.2.jar,C:\mvnrepo\com\fasterxml\jackson\core\jackson-core\2.2.2\jackson-core-2.2.2.jar,C:\mvnrepo\io\netty\netty-all\4.0.21.Final\netty-all-4.0.21.Final.jar,C:\mvnrepo\com\beust\jcommander\1.48\jcommander-1.48.jar,C:\mvnrepo\org\bouncycastle\bcprov-jdk15on\1.51\bcprov-jdk15on-1.51.jar,C:/dev/prodtrunk/someProduct/someProductSystem/someProductSystemApi/target/classes,C:/dev/prodtrunk/PersistenceService/PersistenceService/target/classes,C:/dev/prodtrunk/PersistenceService/PersistenceService/target/test-classes,C:/dev/prodtrunk/ServiceManagement/ServiceManagement/target/classes,C:/dev/prodtrunk/SecretStuff/SecretStuff/target/classes,C:/dev/prodtrunk/SecretStuff/SecretStuff/target/test-classes,C:\mvnrepo\com\somecompany\someproduct\communication\Communication\7.0.0.0-SNAPSHOT\Communication-7.0.0.0-SNAPSHOT.jar,C:\mvnrepo\org\jacorb\jacorb\3.1\jacorb-3.1.jar,C:\mvnrepo\tanukisoft\wrapper\3.5.4\wrapper-3.5.4.jar,C:\mvnrepo\com\sun\xml\bind\jaxb-impl\2.1.5\jaxb-impl-2.1.5.jar,C:\mvnrepo\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar,C:\mvnrepo\javax\activation\activation\1.1\activation-1.1.jar,C:\mvnrepo\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar,C:\mvnrepo\org\slf4j\slf4j-log4j12\1.6.6\slf4j-log4j12-1.6.6.jar,C:/dev/prodtrunk/someProduct/Faults/FaultServiceApi/target/classes,C:/dev/prodtrunk/someProduct/Persistence/target/classes,C:\mvnrepo\org\knopflerfish\bundle\remoteserviceadmin-API\1.0.0\remoteserviceadmin-API-1.0.0.jar,C:\mvnrepo\javax\servlet\servlet-api\2.4\servlet-api-2.4.jar,C:/dev/prodtrunk/someProduct/Automation/automation-service/target/classes,C:/dev/prodtrunk/someProduct/Automation/automation-service/target/test-classes,C:/dev/prodtrunk/someProduct/Configuration/ConfigurationManagement/target/classes,C:\mvnrepo\org\hibernate\hibernate-c3p0\3.6.4.Final\hibernate-c3p0-3.6.4.Final.jar,C:\mvnrepo\c3p0\c3p0\0.9.1\c3p0-0.9.1.jar,C:/dev/prodtrunk/someProduct/Hibernate/target/classes,C:\mvnrepo\org\postgresql\postgresql\9.2-1003-jdbc4\postgresql-9.2-1003-jdbc4.jar,C:\mvnrepo\mysql\mysql-connector-java\5.1.12\mysql-connector-java-5.1.12.jar,C:\mvnrepo\org\codehaus\groovy\groovy-all\2.0.2\groovy-all-2.0.2.jar,C:/dev/prodtrunk/someProduct/LegacyCommunications/target/classes,C:/dev/prodtrunk/someProduct/LegacyCommunications/target/test-classes,C:/dev/prodtrunk/someProduct/PanelManager/target/classes,C:/dev/prodtrunk/someProduct/PanelManager/target/test-classes,C:\mvnrepo\org\knopflerfish\bundle\console\4.0.1\console-4.0.1.jar,C:\mvnrepo\org\knopflerfish\log-API\5.0.0\log-API-5.0.0.jar,C:/dev/prodtrunk/someProduct/Users/UserServiceApi/target/classes,C:/dev/prodtrunk/someProduct/TerminalArbitration/terminalarbitration-common/target/classes,C:/dev/prodtrunk/someProduct/SecretStuffService/target/classes,C:\mvnrepo\com\eclipsesource\jaxrs\publisher\5.0\publisher-5.0.jar,C:\mvnrepo\com\eclipsesource\jaxrs\jersey-all\2.18\jersey-all-2.18.jar
The full exception emitted is
08:57:06.276 ERROR - Invalid value of sonar.libraries for com.somecompany.someproduct.physview:PhysViewImpl
Exception in thread "main" org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.impl.BatchLauncherMain.execute(BatchLauncherMain.java:41)
at org.sonar.runner.impl.BatchLauncherMain.main(BatchLauncherMain.java:59)
Caused by: java.lang.IllegalStateException: No files nor directories matching 'C:/dev/prodtrunk/someProduct/Configuration/ConfigurationStructure/target/test-classes' in directory C:\dev\prodtrunk\someProduct\PhysView\PhysViewImpl
at org.sonar.batch.scan.ProjectReactorBuilder.validateDirectories(ProjectReactorBuilder.java:302)
at org.sonar.batch.scan.ProjectReactorBuilder.defineProject(ProjectReactorBuilder.java:131)
at org.sonar.batch.scan.ProjectReactorBuilder.execute(ProjectReactorBuilder.java:114)
at org.sonar.batch.scan.ProjectScanContainer.projectBootstrap(ProjectScanContainer.java:114)
at org.sonar.batch.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:92)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:90)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:64)
at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:51)
at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:110)
at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
at org.sonar.batch.bootstrap.BootstrapContainer.executeTask(BootstrapContainer.java:185)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
... 6 more
Julien's comment led to the answer. For some reason, we had a maven project with an empty src/test/java. Once, I deleted src/test and src/java, the error went away.

Issue with Jenkins Junit cases running with maven

from last few week, I am facing a strange issue regarding the junit test case in the jenkins, when I say strange the same workspace if I try to run from the command prompt working fine and execute the junit test case but when running with jenkin it is throwing error for junit as test case UNC paths are not supported. Defaulting to Windows directory. and lso class not found. and the error is:
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) # projectdemo ---
[INFO] Surefire report directory: MBP\workspace\target\surefire-reports
MBP\workspace'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:150)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:91)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
... 4 more
Caused by: java.lang.RuntimeException: Unable to create test class 'com.db.proj.demo.services.integration.impl.test.TestImpl'
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:109)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.locateTestClasses(DefaultDirectoryScanner.java:78)
at org.apache.maven.surefire.junit4.JUnit4Provider.scanClassPath(JUnit4Provider.java:164)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:86)
... 9 more
Caused by: java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at org.apache.maven.surefire.util.DefaultDirectoryScanner.loadClass(DefaultDirectoryScanner.java:105)
... 12 more
[ERROR] There are test failures.
Please refer to MBP\workspace\target\surefire-reports for the individual test results.
It is working fine till few day backs, but I don't if anything else need to declared for junit to pass in jenkin.
Note: I have declared a maven project in jenkin with svn as source repository.
In my humble opinion, the error is clear: java.lang.ClassNotFoundException: com.db.proj.demo.services.integration.impl.test.TestImpl
You should revise that in your svn repository the TestImpl class changes has been committed. If the problem persists, try to configure your Jenkins project to an older version in which you are sure it used to compile fine. Step by step, you are likely to find out what problem has been introduced, but it is bound to be related to a non-commit class.

Nutch without Solr & with MySQL:

I am new to Nutch, just setup using following url : Nutch+MySQL
I ran following command because the command mentioned in url is deprecated and not available with Nutch 2.3.
I ran the following command.
bin/crawl urls 1 null 10
Injecting seed URLs
/home/Aayush/NUTCH_HOME/runtime/local/bin/nutch inject urls -crawlId 1
InjectorJob: starting at 2015-03-15 17:14:50
InjectorJob: Injecting urlDir: urls
InjectorJob: java.lang.ClassNotFoundException: org.apache.gora.sql.store.SqlStore
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:259)
at org.apache.nutch.storage.StorageUtils.getDataStoreClass(StorageUtils.java:93)
at org.apache.nutch.storage.StorageUtils.createWebStore(StorageUtils.java:77)
at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:218)
at org.apache.nutch.crawl.InjectorJob.inject(InjectorJob.java:252)
at org.apache.nutch.crawl.InjectorJob.run(InjectorJob.java:275)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.nutch.crawl.InjectorJob.main(InjectorJob.java:284)
And I get the following error.
Error running:
/home/Aayush/NUTCH_HOME/runtime/local/bin/nutch inject urls -crawlId 1
Failed with exit value 255.
I found somewhere that Nutch + MySQL is not supported by Gora version 0.5 you have to downgrade the version to 0.2.1. I downgraded the version in ivy.xml and then removed the directory build and runtime. And again rebuild the project using ant.
After rebuilding and rerunning I still get the above mentioned error.
Please provide any information/help.
Thank you for reading.

Gradle JRE vs JDK please add lib/tools.jar from your JDK

I'm running java tests with gradle.
here is the exception I have:
java.lang.RuntimeException: java.lang.IllegalStateException: Unable to load Java agent; please add lib/tools.jar from your JDK to the classpath
at org.powermock.modules.agent.PowerMockClassRedefiner.redefine(PowerMockClassRedefiner.java:59)
at org.powermock.modules.agent.support.PowerMockAgentTestInitializer.redefine(PowerMockAgentTestInitializer.java:49)
at org.powermock.modules.agent.support.PowerMockAgentTestInitializer.initialize(PowerMockAgentTestInitializer.java:41)
at com.blablacompany.app.weight.WeightMilestonesViewBeanUnitTest.setUpMock(WeightMilestonesViewBeanUnitTest.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:80)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:47)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: Unable to load Java agent; please add lib/tools.jar from your JDK to the classpath
at org.powermock.modules.agent.JDK6AgentLoader.getVirtualMachineImplementationFromEmbeddedOnes(JDK6AgentLoader.java:97)
at org.powermock.modules.agent.JDK6AgentLoader.loadAgent(JDK6AgentLoader.java:70)
at org.powermock.modules.agent.AgentInitialization.initializeAccordingToJDKVersion(AgentInitialization.java:40)
at org.powermock.modules.agent.PowerMockAgent.verifyInitialization(PowerMockAgent.java:83)
at org.powermock.modules.agent.PowerMockAgent.instrumentation(PowerMockAgent.java:76)
at org.powermock.modules.agent.PowerMockClassRedefiner.redefine(PowerMockClassRedefiner.java:57)
... 37 more
It turns out that for some reason my gradle uses JRE's folder as java.home and this is why it can not find the tools.jar.
I on't think that I want manually add it to my classpath though. I'm wondering if there any way to tell gradle to use JDK's java home instead of JRE's?
I also tried overriding it using org.gradle.java.home in gradle.properties file and it did not work. Any help is greatly appreciated.
WHen I run the same tests from my IDE(Intellij IDEA) all tests are passed successfully. I'm running all it on Mac OS.
println System.getenv("JAVA_HOME")
println System.properties['java.home']
displays:
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.7.0_55.jdk/Contents/Home/jre
It's not a JDK vs. JRE problem. The values of JAVA_HOME vs. java.home are correct and expected (see other SO question on this topic). tools.jar is necessary to execute tools such as javac and javadoc. However, neither the JDK's javac command line compiler nor Gradle's JavaCompile task will automatically put tools.jar on the compile class path of user code. Instead you'll have to add it explicitly. For example:
def jdkHome = System.getenv("JAVA_HOME")
dependencies {
compile files("$jdkHome/lib/tools.jar")
}
Ok, seems that JRE is actually the right one that I need to use. No reason java.home to be set to JDK.
So the way I solved it was just adding tools library to my classpath:
testCompile ([fileTree(dir: "${System.properties['java.home']}/../lib", include: '*tools.jar'),fileTree(dir: "lib/test", include: '*.jar') ])
Initially the reason why I did not wanted to do this was that once I added it I had a bunch of
java 7 errors: java.lang.VerifyError: Expecting a stackmap frame at branch target 10
I did fix it by adding "-noverify" parameter to my tests closure:
Closure basicTestConfiguration = {
jvmArgs "-Dactivemq.directory=${testActivemqDir}",
"-Duser.timezone=Etc/UTC",
"-javaagent:${configurations.testAgent.singleFile}",
"-XX:MaxPermSize=256m",
"-noverify"
...
}
and applying this closure to my test suite:
postCommitSuite basicTestConfiguration
Edited
Check this out http://www.gradle.org/docs/current/userguide/build_environment.html.
Especially this section
The configuration is applied in following order (in case an option is configured in multiple locations the last one wins):
from gradle.properties located in project build dir.
from gradle.properties located in gradle user home.
from system properties, e.g. when -Dsome.property is used in the command line.

Categories

Resources