Missing artifact "sun.jdk:jconsole:jar:jdk" - eclipse

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 put my dependencies like this and it works fine:
<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>
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.

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:
<dependency>
<groupId>sun.jdk</groupId>
<artifactId>jconsole</artifactId>
<version>jdk</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/jconsole.jar</systemPath>
</dependency>
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 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.

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.xmls insert this jconsole.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.

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 ...

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 was facing the same issue, but none of this was a perfect solution for me. Steps to solve :
Check if you are pointing to the JDK location correctly :
echo $JAVA_HOME
Open pom.xml from IDE (mine is eclipse), select Dependency Hierarchy, and search for jconsole. If you see jconsole, it is because sometimes jconsole would be given as an interdependency and the path given could not be recognized. Excluding that jar will solve the issue.
Dependency Hierarchy
Interdependent jconsole
Exclusing jconsole

i was searched jdk full name.
(cos i was used when startethe 1.8.0_191 but after change laptop. its also changed to 1.8.0_282)
so i was searched at STS.
there is a string(java path) at the .factorypath.
so i change that.
its fixed now.
guys try this way~

Related

How do I update Itext7 to version 7.1.1

This seems like it should be simple but I cannot find anything on how to upgrade to newer versions of itext7. I am using an Eclipse maven project with itext7 version 7.0.4 and would like to update to 7.1.1. However, I can find nothing that tells me how to do that. Neither the Eclipse update menu or the Maven menu has an option to update itext7. Can someone point me to the documentation on how to do an update? TIA.
After answer:
I am not getting the libraries but instead getting conflicts:
I can't seem to post my pom.xml using code tags (I guess the formatter has a problem with XML code because of the <>) but I will include it if someone tells me how. I've uploaded the pom file to DropBox:
pom.xml
(Turning #mkl's and #amedee's comments into an answer)
In your project there is a file pom.xml which contains the Maven project definition. In there is a dependencies section with entries for the iText artifacts (among others). The version is therein. Well, it could also be in a separate dependencies management section or in a parent pom.xml referenced in your file.
As soon as you update the POM file, you can update the Eclipse project configuration in your Eclipse Maven menu. That will, if necessary, automatically download the jar artifacts. If your Eclipse Maven integration is properly configured, that is, and if your computer has proper internet connectivity.
Old versions will remain in your local repository but won't be in the class path anymore.
Also check out our getting started guide. Which contains an example POM snippet.
https://developers.itextpdf.com/itext7/download-and-install-information/Java
If you put your iText version number in POM properties, then you only have to update the value once when you want to upgrade. Like this:
<properties>
<itext.version>7.1.1</itext.version>
</properties>
and then
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
...
</dependencies>

MILO OPC-UA Download with Maven

I tried to use the milo opc-ua Implementation. At first I download the source with Eclipse/Maven to my local working directory.
File -> Import -> "Checkout Maven Projects"
The Download works fine for me. After this, I tried to update the project files.
Right-Click -> Update Maven Project
The "build-tools" work well for me, everything is done without any errors. But when I try this with the other "folders" (client-examples, ...) I get the following error:
Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-checkstyle-plugin:2.17:check (execution: validate, phase: validate).
The following code shows the pom-file of the client-examples:
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<parent>
<groupId>org.eclipse.milo</groupId>
<artifactId>milo-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</parent>
<artifactId>client-examples</artifactId>
<dependencies>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>sdk-client</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.milo</groupId>
<artifactId>server-examples</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
The pom.entries, shown in https://github.com/eclipse/milo, are in the file. I also checked this for the other sources. But whats going wrong?
I'm using eclipse-neon and maven2eclipse.
Thanks for helping,
Andreas
The errors says that the M2Eclipse plugin has no idea how to map the execution of checkstyle into some build step for the IDE. M2Eclipse tries to set up your local IDE project to replicate the behavior of the Maven build.
By default M2Eclipse is missing the support for the checkstyle Maven plugin. Therefore you get this error. There are two ways to handle this:
You can simply make Eclipse ignore those errors
You can install the checkstyle plugin for Eclipse and have checkstyle run the same way the maven build does it, getting all validation information right into your IDE.
In order to install checkstyle do the following:
Locate the location where the error is reported in Eclipse, issue the "Quick fix" command (normally Ctrl-1)
Select "Discover new m2e connectors":
Review the dialog and press "Finish":
Wait and let Eclipse restart
That should be it.

eclipse cannot find the jar available in maven dependencies

I have a pom.xml with the following entry
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
And on maven install the jar is added to the maven repository and is also listed in the maven dependencies library.
But I am not able to import any of the classes from the added jar 'spring-web-3.1.0.RELEASE.jar' for the particular entry, though it shows in the classpath
The error - in eclipse "cannot be resolved to a type"
environment - maven 3.1 and Spring tool suite
Thanks
Solved - found the solution through some other forum
The jar inside the repository was corrupted.
After clearing the .m2 folder in the physical drive and repeating the maven clean install worked.
Thanks for the time #techidiot #jtravaglini.

Building with Lombok's #Slf4j and Eclipse: Cannot find symbol log

I have the lombok plugin in Eclipse and enabled annotation processing in Eclipse under java compiler, but still it is unable to recognize the log statements when I use #Slf4j annotation.
Do we have to make any other settings?
You also have to install Lombok into Eclipse.
See also this answer on how to do that or check if Lombok is installed correctly.
Full Disclosure: I am one of the Project Lombok developers.
I also faced the similar issue on log and #Slf4j on my STS environment. To resolve this, here is what I did on spring tool suite (sts-4.4.0.RELEASE) and lombok-1.18.10.jar (current latest version available in mavenrepository).
If having maven project, ensure lombok dependency added to it. Else you need manually add the jar to your project classpath.
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
Clean build the maven application. This will download lombok jar in your .m2 location by default from maven repository.
The path would be org\projectlombok\lombok\1.18.10\
Now open command prompt and navigate to the lombok path and execute command java -jar lombok-1.18.10.jar
C:\xxx\xxx\org\projectlombok\lombok\1.18.10>java -jar lombok-1.18.10.jar
Opens up lombok dialog box. If see message Can't find IDE
Click Specify location...
Provide the path to your STS root location
My case it is
C:\apps\sts-4.4.0.RELEASE\SpringToolSuite.exe
Install/Update
Install successful
Click Quit Installer
Now in explorer navigate to your STS root path.
C:\apps\sts-4.4.0.RELEASE\
We see lombok.jar placed in the sts root path
Now edit in notepad SpringToolSuite4.ini file
We see following appended at the end
-javaagent:C:\apps\sts-4.4.0.RELEASE\lombok.jar
Start STS using SpringToolSuite4.exe
Clean, rebuild your project.
So like others, i also faced this issue. Below is what I did.
Installed lombok.jar like explained here.
Tried restarting eclipse. (Did not work)
Tried refreshing gradle project. (Did not work)
tried what Hervian suggested in his answer here. (Did not work)
Closed the projects, deleted from workspace and then re-imported. Bam!! Worked.
I got the same error even after Lombok was installed. For me the solution was to add another lombok annotation (i used #Data) to my class after which the eclipse errors went away. Perhaps this force refreshed some cache.
Of course, I simply deleted the #Data annotation afterwards.
this got the fix to me by adding the slf4j dependency, Lombok can identify the slf4j but does not get the download, this is true for java project if you are using spring boot then slf4j comes by default.
here are my dependencies
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<scope>provided</scope>
</dependency>

ClassNotFoundException when I try to deploy to Tomcat / tc Server in Eclipse / STS

I'm new to Eclipse/STS, and I am having deploying to Tomcat / tcServer. My project builds just fine and deploys to Tomcat fine both in Netbeans and directly to Tomcat, but it will not deploy to Tomcat or tc Server in Eclipse. I get a ClassNotFoundException for org.hibernate.HibernateException, which I know is on the included in the pom.
Here's my log output if it helps.
Also in the markers view, I see the following build path problem:
Archive for required library: '~/.m2/repository/org/hibernate/hibernate-core/4.1.1.Final/hibernate-core-4.1.1.Final.pom' in project 'flamespass-web-dev' cannot be read or is not a valid ZIP file
I found a work around:
I noticed that I had hibernate-core:4.1.1.Final in my Dependency Hierarchy twice, so I tried a few things, and specifying the newest version of hibernate-core in my dependencyManagement node fixed my problem.
I am not sure why. I can only assume that the two copies of hibernate-core:4.1.1 were creating some sort of ambiguity that m2eclipse or WTP couldn't understand even though my external Maven/Tomcat could. I would really appreciate any explanation or better fixes anyone may have. Thanks.
...
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
</dependency>
</dependencies>
</dependencyManagement>