When adding Arquillian to a Maven build I get the above exception in Eclipse:
Missing artifact sun.jdk:jconsole:jar:jdk
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.extension</groupId>
<artifactId>arquillian-persistence-dbunit</artifactId>
<version>1.0.0.Alpha7</version>
</dependency>
(The message is not the problem, but that Eclipse refuses to compile the project because of it. Maven works, though.)
Naturally the first thing I did was trying to exclude it from the Maven dependencies (wildfly-arquillian-container-managed
is where the dependency tree states the dependency comes from):
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<exclusions>
<exclusion>
<artifactId>jconsole</artifactId>
<groupId>sun.jdk</groupId>
</exclusion>
</exclusions>
</dependency>
There was no change. I tried to start Eclipse with -vm C:\Program Files\Java\jdk1.8.0_60\bin
. And tried to edit the JDK in "Preferences -> Installed JREs" to contain the JAR in the tools directory. But nothing works.
What can I do?
I spent the best part of a day fighting this problem. Simple solution is to manually install the missing jar from your jdk using maven, something like:
c:\workspace\prism>mvn install:install-file -Dfile=C:\java\jdk\lib\jconsole.jar -DgroupId=sun.jdk -DartifactId=jconsole -Dversion=1.8 -Dpackaging=war.
Who knows why eclipse cannot do this ...
The reason of the problem is that the
jconsole.jar
is part of the jdk, thus it is not distributed as an ordinary maven package.Typically, project
pom.xml
s insert thisjconsole.jar
as a system package, i.e. it doesn't even try to download them from the central maven repo. Although it would be possible to distribute it also on this way.The simplest solution of the problem is to use a jdk which contains this
jconsole.jar
.Alternatively, you can download this jar from anywhere, only you have to make it reachable in the compilation classpath.
Or, you can also modify the pom.xml, or install the package manually into your local maven repo, as the other answers state.
Alastair, thanks for solving the problem. The cause lies in the the pom of the transient dependency
org.wildfly:wildfly-cli (8.2.0.Final)
. There you can find the following dependency declaration:Actually, the jar is located in
${java.home}/lib/jconsole.jar
.P.S.: The version is also insufficient. So, I deleted this version from my local maven repository.
I put my dependencies like this and it works fine:
See that the exclusion tag is in the "wildfly-embedded" dependency...
Don't forget to command "mvn install" and click right button at project and "Maven Update", if it doesn't work try delete folder "~/.m2/repository" and download all the dependencies again.
Maybe is more of a workaround than a proper solution, anyway I solved this issue by removing the profile "activebydefault" in the pom. This way, Eclipse won't complain for the "Missing artifact sun.jdk:jconsole:jar:jdk" but the JUnit test won't run in Eclipse - as I use testing only from maven test, and not the Eclipse embedded JUnit runner, it just need to specify which profile ID you want to run against.
I faced this while working in a Windows machine. The project itself worked perfectly fine in my Ubuntu machine. However the project's build failed with exactly that message, induced by a transient
org.wildfly:wildfly-ejb
dependency.I didn't feel the project configuration needed to be changed as it's supposed to just work fine across all environments and thus the Windows environment itself must have been wrong. My first thought was that Eclipse itself is in some way using JRE instead of JDK.
So I checked
java -version
in CMD and it appears to point to a JRE installed somewhere in/Program Files
folder while I've always been manually installing JDKs in/Java
folder. Then I inspected the%PATH%
environment variable in Windows settings. It appears to include a/ProgramData/Oracle/Java/javapath
. That folder contained a few symlinks to the JRE in/Program Files
folder. That was thus actually being used to start Eclipse and run all its tasks. When I removed it (there was already aJDK/bin
further down in%PATH%
setting) and restarted Eclipse and re-executed Maven build, the error went away.No changes needed to pom.xml or Eclipse configuration. Just watch out with what's Windows all installing and updating for you in the background and check your
%PATH%
if it still has JDK in top.