First of all there are so many posts around this subject but i failed to resolve this issue.
I have my own maven repository and the process of bringing new jar into it is difficult, because of organisation security compliance.
what i am looking for is exclude jars from plugin and add available dependency inside plugin. please suggest required configuration?
Currently project build is failing because few essential jars are missing.
pom-
<dependencies>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>1.1.0</version>
<classifier>hadoop2</classifier>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.4</version>
<scope>test</scope>
</dependency></dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
<!-- ${argLine} -->
<suiteXmlFiles> <suiteXmlFile>${project.basedir}/src/test/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<debugForkedProcess>true</debugForkedProcess>
<!-- <skip>true</skip>-->
</configuration>
</plugin>
</plugins>
</build>
Build error:
[WARNING] Missing POM for org.apache.maven.surefire:surefire-testng:jar:2.18.1
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.055s
[INFO] Finished at: Mon Aug 15 11:50:31 MST 2016
[INFO] Final Memory: 62M/363M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project cxp: Unable to generate classpath: org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-testng:jar:2.18.1
[ERROR]
[ERROR] Try downloading the file manually from the project website.
[ERROR]
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-testng -Dversion=2.18.1 -Dpackaging=jar -Dfile=/path/to/file
[ERROR]
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-testng -Dversion=2.18.1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR]
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-testng:jar:2.18.1
[ERROR]
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR]
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] prod ****************************************************, releases=true, snapshots=true)
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Process finished with exit code 1
I have org.apache.maven.surefire:surefire-testng:jar:2.12.4 in repository so I modified plugin with below changes but maven still throws same error.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> <!-- ${argLine} -->
<suiteXmlFiles>
<suiteXmlFile>${project.basedir}/src/test/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<debugForkedProcess>true</debugForkedProcess>
<!-- <skip>true</skip>-->
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-testng</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
</plugin>
Related
I have created a maven project and try to run it with Jenkins.
Below is my Jenkins error:-
I am learning how to run a maven project in Jenkins but Jenkins has given me this error(invalid LOC header (bad signature)) do I need to add the dependency for this also.
but I already did that and still, I am facing this issue.
I have commented on some of the plugins.
There are more error in Jenkins, check that too, please
Executing Maven: -B -f /home/oci/git/Maven_First_Project/com.first_maven/pom.xml clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.code_maven:maven_first >---------------------
[INFO] Building com.maven_first 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # maven_first ---
[INFO] Deleting /home/oci/git/Maven_First_Project/com.first_maven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # maven_first ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # maven_first ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/oci/git/Maven_First_Project/com.first_maven/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] error reading /home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar; invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29] package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16] cannot find symbol
symbol: variable FileUtils
location: class com.all_data_page.Online_Booking
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.437 s
[INFO] Finished at: 2019-10-23T17:54:38+05:30
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven_first: Compilation failure: Compilation failure:
[ERROR] error reading /home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar; invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29] package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16] cannot find symbol
[ERROR] symbol: variable FileUtils
[ERROR] location: class com.all_data_page.Online_Booking
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[JENKINS] Archiving /home/oci/git/Maven_First_Project/com.first_maven/pom.xml to com.code_maven/maven_first/0.0.1-SNAPSHOT/maven_first-0.0.1-SNAPSHOT.pom
/home/oci/git/Maven_First_Project/com.first_maven/pom.xml is not inside /home/oci/.jenkins/workspace/Testing_maven/home/oci/git/Maven_First_Project/com.first_maven/; will archive in a separate pass
ERROR: Failed to parse POMs
java.nio.file.NoSuchFileException: /home/oci/.jenkins/workspace/Testing_maven/home/oci/git/Maven_First_Project/com.first_maven/pom.xml
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:215)
at java.base/java.nio.file.Files.newByteChannel(Files.java:370)
at java.base/java.nio.file.Files.newByteChannel(Files.java:421)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:155)
at hudson.FilePath.read(FilePath.java:1942)
at jenkins.plugins.maveninfo.extractor.properties.PomPropertiesFinder.findProperties(PomPropertiesFinder.java:50)
at jenkins.plugins.maveninfo.extractor.MavenInfoExtractor.extract(MavenInfoExtractor.java:58)
at jenkins.plugins.maveninfo.extractor.MavenInfoEnvironment.tearDown(MavenInfoEnvironment.java:42)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:908)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1838)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
channel stopped
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Finished: FAILURE
This is my Pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.code_maven</groupId>
<artifactId>maven_first</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>com.maven_first</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test-output/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>test-output/testng-failed.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
These are the main errors as below:
[ERROR] error reading
/home/oci/.m2/repository/org/apache-extras/beanshell/bsh/2.0b6/bsh-2.0b6.jar;
invalid LOC header (bad signature)
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[6,29]
package org.apache.commons.io does not exist
[ERROR] /home/oci/git/Maven_First_Project/com.first_maven/src/main/java/com/all_data_page/Online_Booking.java:[34,16]
cannot find symbol
Error 1:
Go the below location
/home/oci/.m2/repository/org/apache-extras/
Delete all folder here, sometimes jar corrupts and need to download again by clean install
Source:
Deploying Maven project throws java.util.zip.ZipException: invalid LOC header (bad signature)
Error 2:
Maven package error: org.apache.commons-lang does not exist (Java)
Error 3:
its may be due to incompatibility between jar version, try to find the dependencies which are not compatible
Jacoco is giving me this error when trying to test my web service (I get it with any maven goal that includes the test phase):
$ mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Web Service 1.0
[INFO] ------------------------------------------------------------------------
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to C:\git\myproject\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\git\myproject\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\git\myproject\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # myproject ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.4.201502262128:report (post-unit-test) # myproject ---
[WARNING] Error initializing: org.codehaus.plexus.velocity.DefaultVelocityComponent#1796b2d4
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:401)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:165)
at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:594)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:241)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:116)
at org.codehaus.plexus.velocity.DefaultVelocityComponent.initialize(DefaultVelocityComponent.java:95)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.initialize(PlexusLifecycleManager.java:303)
at org.eclipse.sisu.plexus.PlexusLifecycleManager.activate(PlexusLifecycleManager.java:207)
at org.eclipse.sisu.bean.BeanScheduler$Pending.activate(BeanScheduler.java:156)
at org.eclipse.sisu.bean.BeanScheduler$Activator.onProvision(BeanScheduler.java:185)
at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:126)
at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:68)
at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:63)
at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
at com.google.inject.internal.InjectorImpl$2$1.call(InjectorImpl.java:1016)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1092)
at com.google.inject.internal.InjectorImpl$2.get(InjectorImpl.java:1012)
at org.eclipse.sisu.inject.Guice4$1.get(Guice4.java:162)
at org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:81)
at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:263)
at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:255)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:517)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:121)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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:498)
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)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.152 s
[INFO] Finished at: 2016-12-06T09:19:16-06:00
[INFO] Final Memory: 24M/266M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report (post-unit-test) on project myproject: Execution post-unit-test of goal org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report failed: A required class was missing while executing org.jacoco:jacoco-maven-plugin:0.7.4.201502262128:report: org/apache/commons/lang/StringUtils
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.jacoco:jacoco-maven-plugin:0.7.4.201502262128
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/t1572/.m2/repository/org/jacoco/jacoco-maven-plugin/0.7.4.201502262128/jacoco-maven-plugin-0.7.4.201502262128.jar
[ERROR] urls[1] = file:/C:/Users/t1572/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[2] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[3] = file:/C:/Users/t1572/.m2/repository/junit/junit/4.8.2/junit-4.8.2.jar
[ERROR] urls[4] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[ERROR] urls[5] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/shared/file-management/1.2.1/file-management-1.2.1.jar
[ERROR] urls[6] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/shared/maven-shared-io/1.1/maven-shared-io-1.1.jar
[ERROR] urls[7] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.2.1/maven-reporting-api-2.2.1.jar
[ERROR] urls[8] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.1/doxia-sink-api-1.1.jar
[ERROR] urls[9] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-logging-api/1.1/doxia-logging-api-1.1.jar
[ERROR] urls[10] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/reporting/maven-reporting-impl/2.1/maven-reporting-impl-2.1.jar
[ERROR] urls[11] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-core/1.1.2/doxia-core-1.1.2.jar
[ERROR] urls[12] = file:/C:/Users/t1572/.m2/repository/xerces/xercesImpl/2.8.1/xercesImpl-2.8.1.jar
[ERROR] urls[13] = file:/C:/Users/t1572/.m2/repository/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
[ERROR] urls[14] = file:/C:/Users/t1572/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar
[ERROR] urls[15] = file:/C:/Users/t1572/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar
[ERROR] urls[16] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-site-renderer/1.1.2/doxia-site-renderer-1.1.2.jar
[ERROR] urls[17] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-decoration-model/1.1.2/doxia-decoration-model-1.1.2.jar
[ERROR] urls[18] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-module-xhtml/1.1.2/doxia-module-xhtml-1.1.2.jar
[ERROR] urls[19] = file:/C:/Users/t1572/.m2/repository/org/apache/maven/doxia/doxia-module-fml/1.1.2/doxia-module-fml-1.1.2.jar
[ERROR] urls[20] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-i18n/1.0-beta-7/plexus-i18n-1.0-beta-7.jar
[ERROR] urls[21] = file:/C:/Users/t1572/.m2/repository/org/codehaus/plexus/plexus-velocity/1.1.7/plexus-velocity-1.1.7.jar
[ERROR] urls[22] = file:/C:/Users/t1572/.m2/repository/org/apache/velocity/velocity/1.5/velocity-1.5.jar
[ERROR] urls[23] = file:/C:/Users/t1572/.m2/repository/commons-collections/commons-collections/3.2/commons-collections-3.2.jar
[ERROR] urls[24] = file:/C:/Users/t1572/.m2/repository/commons-validator/commons-validator/1.2.0/commons-validator-1.2.0.jar
[ERROR] urls[25] = file:/C:/Users/t1572/.m2/repository/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.jar
[ERROR] urls[26] = file:/C:/Users/t1572/.m2/repository/commons-digester/commons-digester/1.6/commons-digester-1.6.jar
[ERROR] urls[27] = file:/C:/Users/t1572/.m2/repository/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar
[ERROR] urls[28] = file:/C:/Users/t1572/.m2/repository/oro/oro/2.0.8/oro-2.0.8.jar
[ERROR] urls[29] = file:/C:/Users/t1572/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[30] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.agent/0.7.4.201502262128/org.jacoco.agent-0.7.4.201502262128-runtime.jar
[ERROR] urls[31] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.core/0.7.4.201502262128/org.jacoco.core-0.7.4.201502262128.jar
[ERROR] urls[32] = file:/C:/Users/t1572/.m2/repository/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.jar
[ERROR] urls[33] = file:/C:/Users/t1572/.m2/repository/org/jacoco/org.jacoco.report/0.7.4.201502262128/org.jacoco.report-0.7.4.201502262128.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
Just to be clear, I am not using StringUtils anywhere in my code, not even in my test code. My project builds and runs fine without it, if tests are skipped.
I've googled maven issues, jacoco issues, surefire issues, and tried all solutions I came across.
Here is what I tried:
Clean build, also deleting the whole target directory manually
Adding several different dependencies containing StringUtils to the pom (including the original commons-lang-2.6.jar and the new commons-lang3 library)
Deleting my .m2/repository/org/apache/maven directory to redownload all repository libraries
Comparing with my other projects that use similar test cases to find any possible difference that might cause this
Using different versions of surefire, failsafe, and surefire-report plugins
Adding <skipTests>true</skipTests> to both surefire and failsafe plugin configurations in the pom (some similar issues I read happened because test cases were being run twice)
Excluding various output directories using <exclude> tag in jacoco plugin configuration
Altering the source and target JDK versions in the maven compiler plugin configuration
Inserting the StringUtils.class directly into the jacoco pom in the appropriate directory matching the missing class name and package
Using different versions of the jacoco plugin
Installing and using a different version of Maven (tried both 3.1.1 and 3.3.9)
Switching to cobertura (I get a very similar error that differs only in the class it says is missing - org/apache/commons/lang/SystemUtils, rather than StringUtils)
I've been pulling my hair out over this for a whole day. I was able to have someone else test it and it worked fine on their system. I then copied their target directory onto my machine and was able to execute Sonar code analysis against the successful build results (jacoco.exec and the checked in code).
My question is, what is messed up on my system that is causing this?
I am running Windows 7 64-bit on a HP EliteDesk. Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myproject.ws</groupId>
<artifactId>myproject</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>Web Service</name>
<url>http://maven.apache.org</url>
<properties>
<jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
</properties>
<distributionManagement>
<repository>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<id>internal-repository</id>
<name>Nexus</name>
<url>http://repo.example.com/content/repositories/snapshots</url>
<layout>default</layout>
</repository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-jdk-http</artifactId>
<version>2.17</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.net.httpserver</groupId>
<artifactId>http</artifactId>
<version>20070405</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<build>
<finalName>webservice</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<forkCount>2</forkCount>
<reuseForks>true</reuseForks>
<argLine>${argLine}</argLine>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.17</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<argLine>${argLine}</argLine>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/static/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${basedir}/target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${basedir}/target/jacoco.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<tomcatLoggingFile>tomcat.log</tomcatLoggingFile>
<serverxml>${project.basedir}/target/tomcat/conf/web.xml</serverxml>
</configuration>
</plugin>
</plugins>
</build>
</project>
My test cases aren't anything special, they basically just send a sample POST request to each of the endpoints and verify that a result comes back.
Here is an example test case:
private CustomResponse executePostRequest()
{
MyPojo data = new MyPojo();
data.setId(0);
data.setRequestType("sometype");
data.setSomeField("value");
data.setSomeOtherField(5);
return target.path(endpoint).request().post(Entity.json(data), CustomResponse.class);
}
#Test
public void testEndpoint()
{
CustomResponse response = executePostRequest();
assertTrue( response.getCode() == 200 );
}
I'll be happy to post any other settings or whatever you might want to know about my system.
UPDATE: I just found out about jHades which is a tool to help you identify conflicting Jar resources when you run into jar-hell scenarios like this. I haven't tried it yet, but I plan to and will update the results here if it produces anything.
go to m2\repository\org\jacoco\jacoco-maven-plugin\0.7.4.201502262128
add this dependency in jacoco-maven-plugin-0.7.4.201502262128.pom:
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
When I run sudo mvn exec:java -D storm.topology=fyp-storm-try.src.jvm.Topology at ~/storm/examples/fyp-storm-try/ directory, I faced an error regarding an exception occurred while executing the Java class, how to solve the problem?
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.838s
[INFO] Finished at: Sun Apr 05 09:09:28 UTC 2015
[INFO] Final Memory: 9M/22M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project fyp-storm-try: An exception occured while executing the Java class. fyp-storm-try.src.jvm.Topology -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Below is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>storm</artifactId>
<groupId>org.apache.storm</groupId>
<version>0.9.4</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.apache.storm</groupId>
<artifactId>fyp-storm-try</artifactId>
<packaging>jar</packaging>
<name>fyp-storm-try</name>
......SKIP SOME PART......
<build>
<sourceDirectory>src/jvm</sourceDirectory>
<testSourceDirectory>test/jvm</testSourceDirectory>
<resources>
<resource>
<directory>${basedir}/multilang</directory>
</resource>
</resources>
<plugins>
......SKIP SOME PART......
This is final part of the pom.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass />
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
However, when I run with the command sudo mvn -e exec:java at ~/storm/examples/fyp-storm-try/
The error below appear:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project fyp-storm-try: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java (default-cli) on project fyp-storm-try: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:java are missing or invalid
......SKIP SOME PART......
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
I am getting the following error while building a .war using mcn clean package with Apache Maven. Can some one give me a way to resolve it? Thanks.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.593s
[INFO] Finished at: Thu Sep 05 22:35:10 GMT+05:30 2013
[INFO] Final Memory: 13M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (default) on project application: Compiler errors :
[ERROR] error at import javax.annotation.PreDestroy;
[ERROR] ^^^^^^^^^^^^^^^
[ERROR] C:\Documents and Settings\User\My Documents\application\application\src\main\java\com\Service\MyService.java:13:0::0 The import javax.annotation cannot be resolved
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Does your pom.xml set the Java Compiler version?
Some (all?) versions of maven-compiler assume the Java 1.4 compiler... which of course causes issues since Annotations were new in Java 1.5.
You can force it to Java 7 by including a plugin block for maven-compiler-version in your project's pom.xml and set its source and target properties... something like this:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
Download JSR305 from here to fix the problem.
Hi I'm trying to use the maven android plugin and robolectric to get tests working. Right now I just have one test class which is under src/test.... I've followed the instructions here to try and get this working: http://pivotal.github.com/robolectric/maven-quick-start.html
UPDATED: I have followed the advice of those who posted to me here and here is my latest Pom.xml and compile output.
Here is my Pom.xml:
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.mozilla.android.sync</groupId>
<artifactId>android-sync</artifactId>
<version>1</version>
<packaging>apk</packaging>
<name>sync</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- try 4.10 once we get this working -->
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<!--<pluginManagement>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<!--
<artifactId>maven-android-plugin</artifactId>
<version>2.8.4</version>-->
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-13</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>10</platform>
</sdk>
<emulator>
<!-- the name of the avd device to use for starting the emulator -->
<avd>android-14</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<!--</pluginManagement>-->
</build>
</project>
Output of mvn clean install:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sync 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # android-sync ---
[INFO] Deleting /Users/jason/dev/work/android-sync/target
[INFO]
[INFO] --- android-maven-plugin:3.0.0-alpha-13:generate-sources (default-generate-sources) # android-sync ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /Users/jason/dev/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/jason/dev/work/android-sync/target/generated-sources/r, -M, /Users/jason/dev/work/android-sync/AndroidManifest.xml, -S, /Users/jason/dev/work/android-sync/res, --auto-add-overlay, -I, /Users/jason/dev/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # android-sync ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/src/main/resources
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/target/generated-sources/extracted-dependencies/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # android-sync ---
[INFO] Compiling 21 source files to /Users/jason/dev/work/android-sync/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
symbol: class RunWith
#RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
symbol : class Test
location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
symbol : method equalTo(java.lang.String)
location: class org.mozilla.android.sync.test.MyActivityTest
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.019s
[INFO] Finished at: Sat Nov 12 13:02:42 PST 2011
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project android-sync: Compilation failure: Compilation failure:
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] #RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
[ERROR] symbol : class Test
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
[ERROR] symbol : method equalTo(java.lang.String)
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I think you might have that problem due to the order of the test dependency in the pom file. Move the junit one to be the last one or at least behind the robolectric one. That should fix it.
Check out the working robolectric sample app for more comparison.
I did make sure that all dependencies were listed before the android dependencies
Actually the order of dependencies does matter, in the link your provided yourself, see the important comments in the sample pom.xml:
<!-- Make sure this is below the android dependencies -->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>X.X.X</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
From my own experiences, I think this library is still in a development stage, their API is not stable and change quite a lot between different version, code working in a old version for example 0.9.4 may not working in 1.0-XX or later. try download/use the latest versrion from there sonatype repository
So I was having the same problems too. For what it's worth, I wasn't using maven or gradle, here's how I fixed this issue.
In your Test class:
Make sure the Roboelectric library is first in the list of dependencies (In IntelliJ, click on your project in the Navigation Pane and hit F4).
import org.junit.runner.RunWith; <- The RunWith annotation is actually part of JUnit.
import org.roboelectric.RoboeletricTestRunner;
I hope this helps!