I had a working project, when i uploaded into Github, but now when I import that into another system, it shows build failure.
The project was uploaded from Win10 and now I am importing it to Mac. It is a very basic project for Maven, and I know there is some very basic mistake that I am missing to figure.
Please find the dependencies here
<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>UI</groupId>
<artifactId>Automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Automation</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>4.13.2</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>6.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>6.9.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<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>
</plugins>
</pluginManagement>
</build>
</project>
After the import it is not recognizing the Hooks class that I am trying to extend to other classes too. And i get Cannot Find Symbol: Class error in the build.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/nehasingh/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Users/nehasingh/eclipse/java-2021-032/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/nehasingh/.p2/pool/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Users/nehasingh/eclipse/java-2021-032/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------------< UI:Automation >----------------------------
[INFO] Building Automation 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Automation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/nehasingh/Downloads/AutomationUI-main/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # Automation ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /Users/nehasingh/Downloads/AutomationUI-main/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[10,29] package UI.Automation.stepdfn does not exist
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[14,31] cannot find symbol
symbol: class Hooks
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[3,29] package UI.Automation.stepdfn does not exist
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[5,32] cannot find symbol
symbol: class Hooks
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[19,49] cannot find symbol
symbol: variable driver
location: class UI.Automation.pageobjects.HomePage
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[32,35] cannot find symbol
symbol: variable driver
location: class UI.Automation.pageobjects.HomePage
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[11,17] cannot find symbol
symbol: variable driver
location: class UI.Automation.pageobjects.loginPage
[INFO] 7 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.837 s
[INFO] Finished at: 2021-04-17T00:03:28-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project Automation: Compilation failure: Compilation failure:
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[10,29] package UI.Automation.stepdfn does not exist
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[14,31] cannot find symbol
[ERROR] symbol: class Hooks
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[3,29] package UI.Automation.stepdfn does not exist
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[5,32] cannot find symbol
[ERROR] symbol: class Hooks
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[19,49] cannot find symbol
[ERROR] symbol: variable driver
[ERROR] location: class UI.Automation.pageobjects.HomePage
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/HomePage.java:[32,35] cannot find symbol
[ERROR] symbol: variable driver
[ERROR] location: class UI.Automation.pageobjects.HomePage
[ERROR] /Users/nehasingh/Downloads/AutomationUI-main/src/main/java/UI/Automation/pageobjects/loginPage.java:[11,17] cannot find symbol
[ERROR] symbol: variable driver
[ERROR] location: class UI.Automation.pageobjects.loginPage
[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
This was working completely fine in Win10 but not working in MacOS.
Versions:
JAVA:16
Maven: 3.8.1
Related
I have this scenarion:
I have a maven project with spring boot where i just have some tipical pojo classes inside this package structure like: com.demo.core
pom structure
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
com/demo/core/Person.java
Then im trying to use that base project as a dependency of other spring boot project which is responsible of database persistence.
here i use spring data, lombok and others.
Second project pom dependencies:
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- local dependencies -->
**
<dependency>
<groupId>com.demo</groupId>
<artifactId>core-baseproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
**
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I run mvn clean install in base project and verify that the jar file is in my local .m2 repository structure.
when i try to run mvn clean install in the second project i got an error saying that the package com.demo.core does not exits therefore did not find classes inside that package.
Error details:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< com.demo:jpa-dataprovider-simple >---------------
[INFO] Building jpa-dataprovider-simple 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # jpa-dataprovider-simple ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # jpa-dataprovider-simple ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple-pos/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[4,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[8,59] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[18,23] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[9,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[10,36] package com.demo.core.gateway does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[14,54] cannot find symbol
symbol: class TerminalConfigGateway
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,36] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,16] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.714 s
[INFO] Finished at: 2020-01-14T18:08:20-05:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project jpa-dataprovider-simple: Compilation failure: Compilation failure:
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/d/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[4,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[8,59] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[18,23] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[9,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[10,36] package com.demo.core.gateway does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[14,54] cannot find symbol
[ERROR] symbol: class TerminalConfigGateway
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,36] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,16] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[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
Have any one a clue how to solve this???
Im using:
Spring Tool Suite 4
Version: 4.5.0.RELEASE
java-8-openjdk-amd64
maven 3.6.0
springboot version 2.1.11
Thanks in advance.
There is something new to me, when i review inside jar file the structure is like this:
Jar structure generated by spring boot
For some reason i changed the maven config in eclipse to use the installed and not the embedbeb one, but now i get this error.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.619 s <<< FAILURE! - in com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplicationTests
[ERROR] contextLoads(com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplicationTests) Time elapsed: 0.015 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/oxypora/pos/core/gateway/TerminalConfigGateway.class] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [com/oxypora/pos/core/gateway/TerminalConfigGateway.class] cannot be opened because it does not exist
I found another solution when you have two or more springboot projects and you want to wire them one as dependency of others.
The solution is not to use spring-boot-maven-plugin, this plugin override the normal package of the jar causing your classes and package structure to move under BOOT-INF/classes.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I solved the problem, springboot project generated a diferent jar structure configured in the metainf file, so that classes are not pleced in the tipical folders.
what i did was to change the core project to a simple maven project with out spring boot complexity, and now the second project (springboot one) compiled without problems.
There was not nescessary to have the base project as a springboot one.
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
This question already has answers here:
Maven project cannot locate dependencies in local repository
(4 answers)
Closed 6 years ago.
It seems very simple so I must have some problem with configuration.
There is a demo project with pom:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
This project build and installs correctly in my .m2
Then I have another project, with pom:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo2</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When trying to access a class from demo, I get:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building demo2 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.6.1:clean (default-clean) # demo2 ---
[INFO] Deleting /home/lukasz/parent/demo2/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # demo2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # demo2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/lukasz/parent/demo2/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.096 s
[INFO] Finished at: 2017-02-19T01:11:21+01:00
[INFO] Final Memory: 21M/203M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo2: Compilation failure: Compilation failure:
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] /home/lukasz/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[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
What am I missing?
EDIT:
Obviously, I did mvn clean install on demo project. Funny thing is I can use with:
javac -cp .m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar <any java file here>
EDIT:
Last part of mvn -X:
[DEBUG] Classpath: [/home/ala/parent/demo2/target/classes
/home/ala/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
/home/ala/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.jar
/home/ala/.m2/repository/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.jar
/home/ala/.m2/repository/org/springframework/spring-context/4.3.6.RELEASE/spring-context-4.3.6.RELEASE.jar
/home/ala/.m2/repository/org/springframework/spring-aop/4.3.6.RELEASE/spring-aop-4.3.6.RELEASE.jar
/home/ala/.m2/repository/org/springframework/spring-beans/4.3.6.RELEASE/spring-beans-4.3.6.RELEASE.jar
/home/ala/.m2/repository/org/springframework/spring-expression/4.3.6.RELEASE/spring-expression-4.3.6.RELEASE.jar
/home/ala/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.1.RELEASE/spring-boot-autoconfigure-1.5.1.RELEASE.jar
/home/ala/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.1.RELEASE/spring-boot-starter-logging-1.5.1.RELEASE.jar
/home/ala/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar
/home/ala/.m2/repository/ch/qos/logback/logback-core/1.1.9/logback-core-1.1.9.jar
/home/ala/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.22/jcl-over-slf4j-1.7.22.jar
/home/ala/.m2/repository/org/slf4j/jul-to-slf4j/1.7.22/jul-to-slf4j-1.7.22.jar
/home/ala/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.22/log4j-over-slf4j-1.7.22.jar
/home/ala/.m2/repository/org/springframework/spring-core/4.3.6.RELEASE/spring-core-4.3.6.RELEASE.jar
/home/ala/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar]
[DEBUG] Output directory: /home/ala/parent/demo2/target/classes
[DEBUG] CompilerReuseStrategy: reuseCreated
[DEBUG] useIncrementalCompilation enabled
[DEBUG] Stale source detected: /home/ala/parent/demo2/src/main/java/com/example/Demo2Application.java
[INFO] Changes detected - recompiling the module!
[DEBUG] Classpath:
[DEBUG] /home/ala/parent/demo2/target/classes
[DEBUG] /home/ala/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/spring-context/4.3.6.RELEASE/spring-context-4.3.6.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/spring-aop/4.3.6.RELEASE/spring-aop-4.3.6.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/spring-beans/4.3.6.RELEASE/spring-beans-4.3.6.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/spring-expression/4.3.6.RELEASE/spring-expression-4.3.6.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.1.RELEASE/spring-boot-autoconfigure-1.5.1.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.1.RELEASE/spring-boot-starter-logging-1.5.1.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar
[DEBUG] /home/ala/.m2/repository/ch/qos/logback/logback-core/1.1.9/logback-core-1.1.9.jar
[DEBUG] /home/ala/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.22/jcl-over-slf4j-1.7.22.jar
[DEBUG] /home/ala/.m2/repository/org/slf4j/jul-to-slf4j/1.7.22/jul-to-slf4j-1.7.22.jar
[DEBUG] /home/ala/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.22/log4j-over-slf4j-1.7.22.jar
[DEBUG] /home/ala/.m2/repository/org/springframework/spring-core/4.3.6.RELEASE/spring-core-4.3.6.RELEASE.jar
[DEBUG] /home/ala/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar
[DEBUG] Source roots:
[DEBUG] /home/ala/parent/demo2/src/main/java
[DEBUG] Command line options:
[DEBUG] -d /home/ala/parent/demo2/target/classes -classpath /home/ala/parent/demo2/target/classes:/home/ala/.m2/repository/com/example/demo/0.0.1-SNAPSHOT/demo-0.0.1-SNAPSHOT.jar:/home/ala/.m2/repository/org/springframework/boot/spring-boot-starter/1.5.1.RELEASE/spring-boot-starter-1.5.1.RELEASE.jar:/home/ala/.m2/repository/org/springframework/boot/spring-boot/1.5.1.RELEASE/spring-boot-1.5.1.RELEASE.jar:/home/ala/.m2/repository/org/springframework/spring-context/4.3.6.RELEASE/spring-context-4.3.6.RELEASE.jar:/home/ala/.m2/repository/org/springframework/spring-aop/4.3.6.RELEASE/spring-aop-4.3.6.RELEASE.jar:/home/ala/.m2/repository/org/springframework/spring-beans/4.3.6.RELEASE/spring-beans-4.3.6.RELEASE.jar:/home/ala/.m2/repository/org/springframework/spring-expression/4.3.6.RELEASE/spring-expression-4.3.6.RELEASE.jar:/home/ala/.m2/repository/org/springframework/boot/spring-boot-autoconfigure/1.5.1.RELEASE/spring-boot-autoconfigure-1.5.1.RELEASE.jar:/home/ala/.m2/repository/org/springframework/boot/spring-boot-starter-logging/1.5.1.RELEASE/spring-boot-starter-logging-1.5.1.RELEASE.jar:/home/ala/.m2/repository/ch/qos/logback/logback-classic/1.1.9/logback-classic-1.1.9.jar:/home/ala/.m2/repository/ch/qos/logback/logback-core/1.1.9/logback-core-1.1.9.jar:/home/ala/.m2/repository/org/slf4j/jcl-over-slf4j/1.7.22/jcl-over-slf4j-1.7.22.jar:/home/ala/.m2/repository/org/slf4j/jul-to-slf4j/1.7.22/jul-to-slf4j-1.7.22.jar:/home/ala/.m2/repository/org/slf4j/log4j-over-slf4j/1.7.22/log4j-over-slf4j-1.7.22.jar:/home/ala/.m2/repository/org/springframework/spring-core/4.3.6.RELEASE/spring-core-4.3.6.RELEASE.jar:/home/ala/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar: -sourcepath /home/ala/parent/demo2/src/main/java: -s /home/ala/parent/demo2/target/generated-sources/annotations -g -nowarn -target 1.8 -source 1.8 -encoding UTF-8
[DEBUG] incrementalBuildHelper#beforeRebuildExecution
[INFO] Compiling 1 source file to /home/ala/parent/demo2/target/classes
[DEBUG] incrementalBuildHelper#afterRebuildExecution
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/ala/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[ERROR] /home/ala/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
symbol: class Aclass
location: class com.example.Demo2Application
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.789 s
[INFO] Finished at: 2017-02-19T07:15:39+01:00
[INFO] Final Memory: 21M/201M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo2: Compilation failure: Compilation failure:
[ERROR] /home/ala/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,17] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] /home/ala/parent/demo2/src/main/java/com/example/Demo2Application.java:[11,32] cannot find symbol
[ERROR] symbol: class Aclass
[ERROR] location: class com.example.Demo2Application
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project demo2: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
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)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
[ERROR]
[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
Here are few suggestions:
Run your broken build with "mvn -X clean install" for debugging. The log should include what repo. URLs Maven is looking for each dependency.
Unzip your jar file to verify classes you want are included or not.
Maven didn't found package com.example in this configuration.
<dependency>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version> </dependency>
So you must install this package as local package by use command: mvn clean install in the first project.
Or you can also install it as 3rd party package by using:
mvn install:install-file -Dfile={your directory}\demo-{version}.jar
-DgroupId=com.example
-DartifactId=demo -Dversion={version} -Dpackaging=jar
After install correctly, it will works.
I have created a very simple project in Eclipse to run a very simple JUnit test. These tests work fine when tests are executed from within Eclipse, but the code does not compile when run via maven command line.
The command I am using to run maven is simply 'maven test'. The following is the maven output:
MacBook-Pro:leonard-reference-test randy$ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building leonard-reference-test 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # leonard-reference-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.3:compile (default-compile) # leonard-reference-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /Users/randy/PSH/workspaces/playground/leonard-reference-test/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[3,17] package org.junit does not exist
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[8,10] cannot find symbol
symbol: class Test
location: class info.leonard.reference.test.ReferenceTestClient
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.043 s
[INFO] Finished at: 2015-12-15T19:10:49-07:00
[INFO] Final Memory: 11M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project leonard-reference-test: Compilation failure: Compilation failure:
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[3,17] package org.junit does not exist
[ERROR] /Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:[8,10] cannot find symbol
[ERROR] symbol: class Test
[ERROR] location: class info.leonard.reference.test.ReferenceTestClient
[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
MacBook-Pro:leonard-reference-test randy$
The pom.xml for this is as follows:
<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>info.leonard.reference</groupId>
<artifactId>leonard-reference-test</artifactId>
<version>0.0.1</version>
<prerequisites>
<maven>3.0</maven>
</prerequisites>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
</plugins>
</build>
</project>
And the only Java file in the project is as follows:
package info.leonard.reference.test;
import org.junit.Test;
public class ReferenceTestClient
{
#Test
public void testOne()
{
System.out.println("simple test");
}
}
That's it... no other files in the project. Maven tests run successfully from within Eclipse, but the code doesn't even compile from within Maven.
A valid pom.xml file, or other modifications to this simple project, is appreciated.
You have your file in src/main/java/ directory but the scope for the JUnit dependency is test. This means maven will not take it into account when compiling non-test code. Please put your file in src/test/java.
Test scope means that junit is only available in src/test/java
move
/Users/randy/PSH/workspaces/playground/leonard-reference-test/src/main/java/info/leonard/reference/test/ReferenceTestClient.java:
over to
/Users/randy/PSH/workspaces/playground/leonard-reference-test/src/test/java/info/leonard/reference/test/ReferenceTestClient.java:
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!