缺少神器" sun.jdk:jconsole:jar:jdk"

时间:2015-10-20 12:04:30

标签: eclipse maven wildfly jboss-arquillian

将Arquillian添加到Maven构建时,我在Eclipse中得到了上述异常:

  

缺少神器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>

(消息不是问题,但Eclipse拒绝编译项目因为它。但Maven工作。)

当然,我做的第一件事就是尝试将其从Maven依赖项中排除(wildfly-arquillian-container-managed是依赖树声明依赖性来自的地方):

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-managed</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jconsole</artifactId>
                <groupId>sun.jdk</groupId>
            </exclusion>
        </exclusions>
    </dependency> 

没有变化。我尝试用-vm C:\Program Files\Java\jdk1.8.0_60\bin启动Eclipse。并尝试在&#34;首选项 - &gt;中编辑JDK。已安装的JRE&#34;在工具目录中包含JAR。但没有任何作用。

我该怎么办?

7 个答案:

答案 0 :(得分:9)

我把我的依赖项放在这里并且工作正常:

<dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-arquillian-container-embedded</artifactId>
        <version>8.1.0.CR1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.15</version>
        <scope>test</scope>
    </dependency>
    <!-- Arquillian -->

    <dependency>
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-embedded</artifactId>
        <version>8.1.0.CR1</version>
        <exclusions>
            <exclusion>
                <groupId>sun.jdk</groupId>
                <artifactId>jconsole</artifactId>
            </exclusion>
        </exclusions>
        <scope>test</scope>
    </dependency>

请注意,排除标记位于“wildfly-embedded”依赖项中......

不要忘记命令“mvn install”并单击项目中的右键和“Maven Update”,如果它不起作用,请尝试删除文件夹“〜/ .m2 / repository”并再次下载所有依赖项。 / p>

答案 1 :(得分:5)

阿拉斯泰尔,谢谢你解决了这个问题。原因在于瞬态依赖的基因org.wildfly:wildfly-cli (8.2.0.Final)。在那里你可以找到以下依赖声明:

<dependency>
            <groupId>sun.jdk</groupId>
            <artifactId>jconsole</artifactId>
            <version>jdk</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/jconsole.jar</systemPath>
</dependency>

实际上,jar位于${java.home}/lib/jconsole.jar

P.S。:版本也不够。所以,我从我当地的maven存储库中删除了这个版本。

答案 2 :(得分:2)

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.

Missing artifact sun.jdk:jconsole:jar:jdk

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 a JDK/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.

答案 3 :(得分:2)

问题的原因是jconsole.jar是jdk的一部分,因此它不是作为普通的maven包发布的。

通常,项目pom.xml将此jconsole.jar作为系统包插入,即它甚至不会尝试从中央maven仓库下载它们。虽然也可以通过这种方式分发它。

问题的最简单解决方案是使用包含此jconsole.jar的jdk。

或者,你可以从任何地方下载这个jar,只需要在编译类路径中使它可以访问。

或者,您也可以修改pom.xml,或者手动将软件包安装到本地maven存储库中,因为其他答案都是正确的。

答案 4 :(得分:1)

我花了一天的时间来解决这个问题。简单的解决方案是使用maven从你的jdk手动安装丢失的jar,如:

c:\ workspace \ prism&gt; mvn install:install-file -Dfile = C:\ java \ jdk \ lib \ jconsole.jar -DgroupId = sun.jdk -DartifactId = jconsole -Dversion = 1.8 -Dpackaging = war。

谁知道为什么eclipse无法做到这一点...

答案 5 :(得分:0)

我也面临着同样的问题,但这都不是我的完美解决方案。解决步骤:

  1. 检查您是否正确指向JDK位置: echo $JAVA_HOME
  2. 从IDE中打开pom.xml(我的月食是eclipse),选择Dependency Hierarchy,然后搜索jconsole。如果您看到jconsole,那是因为有时jconsole会被视为相互依赖关系而给定的路径无法被识别。排除该jar将解决问题。

Dependency Hierarchy

Interdependent jconsole

Exclusing jconsole

答案 6 :(得分:0)

我被搜索为jdk全名。 (启动1.8.0_191时使用了cos我,但更改笔记本电脑后使用。我也更改为1.8.0_282) 所以我在STS被搜索了。

.factorypath处有一个字符串(java路径)。

所以我改变了。

现在已修复。

人们尝试这种方式〜