I tried to build a job and it returns following error:
> Failed to execute goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli)
> on project addressbook: Execution default-cli of goal
> org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin
> org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its
> dependencies could not be resolved: Could not find artifact
> com.sun:tools:jar:0 at specified path
> /var/lib/jenkins/tools/hudson.model.JDK/myjava/../lib/tools.jar ->
> [Help 1]
Any idea how to resolve it?
I guess the jdk in question was above 8 which is still not supported by Cobertura: https://github.com/mojohaus/cobertura-maven-plugin/issues/30
[ERROR] Failed to execute goal
org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (verification)
on project generex: Execution verification of goal
org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument failed: Plugin
org.codehaus.mojo:cobertura-maven-plugin:2.7 or one of its
dependencies could not be resolved: Could not find artifact
com.sun:tools:jar:0 at specified path
/usr/local/lib/jvm/openjdk11/../lib/tools.jar
I had to switch to https://www.jacoco.org/jacoco/ instead.
Seems like you are missing the tools jar in your JDK/JRE library you can confirm it by searching for the JAR in the lib folder if it's not present then you can add the following in your pom.xml
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
Where ${env.JAVA_HOME} points to the JAVA you set in environment variables if you are using another JRE apart from the one set then specify the path like so /var/lib/jenkins/tools/hudson.model.JDK/myjava/JDK8/lib/lib
Hope it helps :)
Related
I am creating a jenkins job for running my testng code.When the pom.xml is building,all other dependencies are complied properly but the one having https reporsitory is blocked.Due to this i am unable to start chrome driver through webdriver manager too.
maven dependency :
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-email</artifactId>
<version>20.3</version>
<classifier>jdk16</classifier>
</dependency>
the exception is as follows
Failed to collect dependencies at com.aspose:aspose-email:jar:jdk16:20.3: Failed to read artifact descriptor for com.aspose:aspose-email:jar:jdk16:20.3: Could not transfer artifact com.aspose:aspose-email:pom:20.3 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [AsposeJavaAPI (http://repository.aspose.com/repo/, default, releases+snapshots)] -> [Help 1]
P.S : this code works fine in eclipse
i am following the official bazel documentation for migrating from maven to bazel and used rules_jvm_external to defined external dependencies in workspace file and Build file. But I am getting the follwing error.
C:/users/kunal_visoulia/_bazel_kunal_visoulia/3f5dzdsz/external/maven/BUILD:1212:1: in deps attribute of jvm_import rule #maven//:commons_digester_commons_digester: rule '#maven//:xml_apis_xml_apis' does not exist
ERROR: Analysis of target '//:everything' failed; build aborted: Analysis of target '#maven//:commons_digester_commons_digester' failed; build aborted
INFO: Elapsed time: 724.364s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 371 targets configured)
Fetching #remotejdk11_win; Restarting.
i am using private nexus repo and also the official maven repo. Please help
I've successfully reproduced your error and found the following workaround:
Add xml-apis:xml-apis:1.4.01 and junit:junit-dep:4.9 to your
list of artifacts.
Add the version_conflict_policy = "pinned"
attribute to maven_install.
The root cause is https://github.com/bazelbuild/rules_jvm_external/issues/250. The missing dependencies are artifacts that relocated to new GAV coordinates, which the coursier resolver cannot handle yet. The general workaround is to manually add the legacy GAV coordinates into maven_install.
Specifically, xml-apis:xml-apis:2.0.2 relocated to xml-apis:xml-apis:1.0.b2 (but 1.4.0.1 wasn't relocated), and junit:junit-dep:4.9 relocated to junit:junit.
The path to my project is /project/
My build file structure is src/main/package/subpackage/Class.java
My test file structure is src/test/package/subpackage/Test.java
I would like my compiled code to be in bin/main/package/subpackage/Class.class
Compiled test code in bin/test/package/subpackage/Test.class
My pom.xml has the entry
<build>
<sourceDirectory>${project.basedir}/src/main</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test</testSourceDirectory>
<outputDirectory>${project.basedir}/bin/main</outputDirectory>
<testOutputDirectory>${project.basedir}/bin/test</testOutputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
</build>
Running mvn clean install causes the following.
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.6:resources (default-resources) on project Hello-Maven: Error loading property file '/project/': /project (Is a directory) -> [Help 1]
...
[Help 1] https://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Now I've tried the link, but it suggest that it's an issue with the plugins.
However, commenting this block out, and running mvn clean install again returns an almost empty jar file inside /project/target/Hello-Maven-1.0-SNAPSHOT.jar, containing only the pom and the manifest. Additionally, there aren't any plugins, only dependencies: junit and javafx.
EDIT: I realize that plugins specifically for running maven but finding information over why the error happens for "install" is difficult at best.
I have many errors with sonarqube analyse in the Jenkins job with the analyse success
[ERROR] [14:36:44.124] Class not found: org.joda.convert.FromString
[ERROR] [14:36:44.126] Class not found: org.joda.convert.ToString
[ERROR] [14:34:42.441] Class not found: org.apache.commons.logging.Log
[ERROR] [14:34:42.724] Class not found: org.apache.oro.text.perl.Perl5Util
[ERROR] [14:34:31.442] Class not found: io.swagger.annotations.ApiModel
[ERROR] [14:34:31.442] Class not found: io.swagger.annotations.ApiModelProperty
[ERROR] [14:28:37.756] Class not found: org.apache.commons.logging.Log
[ERROR] [14:28:40.030] Class not found: org.apache.oro.text.perl.Perl5Util
SonareQube : 5.1.2
sonarQube jenkins plugin : 2.6
JDK : 1.7
Any help please
thanks
Add the following dependency to your pom
<dependency>
<groupId>org.joda</groupId>
<artifactId>joda-convert</artifactId>
<version>1.8.1</version>
<scope>provided</scope>
</dependency>
This error is displayed when the .class file of the mentioned class is not found. This might results in less accurate and less precise issues raised.
You should check your analysis configuration and more specifically the sonar.java.libraries property to be sure you provide the correct dependency to your project.
The root cause in our case were outdated Sonar plugins. In order to figure out which one it is you need to run a Maven debug build i.e. run it with -X. The
Class not found: org.joda.convert.FromString
Class not found: org.joda.convert.ToString
you'll see if the sonar-jmeter-plugin is not up to date for example.
I build my code and invoke SONAR analysis through Jenkins.
I want to ignore all the folder/files from SONAR code analysis that fall under the 'target' folder of my code. I have already tried the following things:
added '/target/' under the SONAR's Settings > Exclusions, restarted the SONAR server. But i am getting following error
[ERROR] Failed to
execute goal org.codehaus.mojo:sonar-maven-plugin:2.5:sonar
(default-cli) on project : Dangling meta character '*' near index 0
[ERROR] /target/ [ERROR] ^
added '\\*\\*/target/\\*\\*' under the SONAR's Settings > Exclusions, to avoid the previos error.
added 'sonar.exclusions=/target/' in sonar.properties file.
But SONAR is still analyzing the code under the "target" folder and under all its sub-folders.
The right solution is :
sonar.exclusions=target/**
(or just target/** is you set it through the UI)
The pattern should be
-Dsonar.exclusions=**/target/**