Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Could not find artifact com.sun:tools:jar:0 #67

Open
ValeKnappich opened this issue Dec 22, 2022 · 1 comment
Open

Could not find artifact com.sun:tools:jar:0 #67

ValeKnappich opened this issue Dec 22, 2022 · 1 comment

Comments

@ValeKnappich
Copy link

ValeKnappich commented Dec 22, 2022

Hi I'm trying to get cobertura to work, but somehow I cannot seem to figure it out.
I added the most basic config from the docs to the pom.xml. All mvn commands run fine but when running cobertura commands I always get an error saying that a dependency couldnt be resolved:

$ mvn clean cobertura:cobertura

\[ERROR\] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli) on project openfasttrace-parent: 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 /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> \[Help 1\] 

To make sure its not a peculiarity of my system, I reproduced the error in a Colab Notebook And yes, I did install JDK and not JRE! Compilation and all works absolutely fine. Tried both apt and binary installation. Occurs with every repository I tried. Appreciate any help!

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>
    <groupId>org.itsallcode.openfasttrace</groupId>
    <version>0.0.0</version>
    <artifactId>openfasttrace-root</artifactId>
    <name>OpenFastTrace Root Project</name>
    <packaging>pom</packaging>
    <modules>
        <module>parent</module>
        <module>api</module>
        <module>core</module>
        <module>product</module>
        <module>exporter/common</module>
        <module>exporter/markdown</module>
        <module>exporter/specobject</module>
        <module>importer/markdown</module>
        <module>importer/specobject</module>
        <module>importer/tag</module>
        <module>importer/zip</module>
        <module>reporter/plaintext</module>
        <module>reporter/html</module>
        <module>reporter/aspec</module>
        <module>testutil</module>
    </modules>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.7</version>
            </plugin>
        </plugins>
    </reporting>
</project>

Steps to reproduce:

# Install JDK
apt install default-jdk

# Install Maven
wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
tar xvfz apache-maven-3.8.6-bin.tar.gz

# Clone Repo
git clone https://github.com/itsallcode/openfasttrace.git

# Add Cobertura to pom.xml
printf '\n<project xmlns="http://maven.apache.org/POM/4.0.0"\n    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\n    <modelVersion>4.0.0</modelVersion>\n    <groupId>org.itsallcode.openfasttrace</groupId>\n    <version>0.0.0</version>\n    <artifactId>openfasttrace-root</artifactId>\n    <name>OpenFastTrace Root Project</name>\n    <packaging>pom</packaging>\n    <modules>\n        <module>parent</module>\n        <module>api</module>\n        <module>core</module>\n        <module>product</module>\n        <module>exporter/common</module>\n        <module>exporter/markdown</module>\n        <module>exporter/specobject</module>\n        <module>importer/markdown</module>\n        <module>importer/specobject</module>\n        <module>importer/tag</module>\n        <module>importer/zip</module>\n        <module>reporter/plaintext</module>\n        <module>reporter/html</module>\n        <module>reporter/aspec</module>\n        <module>testutil</module>\n    </modules>\n    <reporting>\n        <plugins>\n            <plugin>\n                <groupId>org.codehaus.mojo</groupId>\n                <artifactId>cobertura-maven-plugin</artifactId>\n                <version>2.7</version>\n            </plugin>\n        </plugins>\n    </reporting>\n</project>\n' > openfasttrace/pom.xml

# Attempt instrumentation
cd openfasttrace
../apache-maven-3.6.3/bin/mvn clean cobertura:cobertura


[ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.7:instrument (default-cli) on project openfasttrace-parent: 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 /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [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/PluginResolutionException
@zbynek
Copy link

zbynek commented Feb 12, 2024

Looks like this plugin is not compatible with recent versions of Java, since Java 9 removed tools.jar.

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

No branches or pull requests

2 participants