I get a java.lang.NoClassDefFoundError: org/apache/http/impl/conn/PoolingHttpClientConnectionManager when trying to build a maven project in eclipse. Where as it builds successfully on command line
I get the above mentioned class through the following dependency defined in the pom
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>
--I tried, deleting the local repo and running the build with -U option but doesnt seem to fix the problem.
--When I look at the java build path in eclipse, it shows certain libraries missing. I found newer versions of these jars in the local repo and added them in the eclipse java build path. But the build still fails for the same error
Note: I have one multimodule project in my eclipse workspace.
--I tried updating the project and verified if eclipse was using teh same settings.xml and local repo that the command line is.
--I am running a clean install
--Cleaning project also doesnt fix it
--I looked at the referrenced libraries and there is a class org/apache/http/impl/conn/PoolingHttpClientConnectionManager present. Dont know why it doesnt find it
If project builds on command line it should build in Eclipse as well. Reasons why it may not be the case include:
settings.xml used by Eclipse is different, so Maven does not have access to same repos. This can be changed in preferences.
Workspace resolution is picking code in dependent projects that have local changes and thus build fails
Eclipse maven configuration is not up-to-date that can be fixed by using Maven->Update project .. option
Try that if it fails please clarify if you have one project in Eclipse or multiple and what errors exactly do you see.
Also note that sometimes maven build from command line will delete target folder and will cause Eclipse to run build in parallel re-using same target folder and resulting in inconsistent state.
Try Adding dependency for HttpCore library, the class exists there too
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.3</version>
So the problem was that I had two versions of http-client library. I excluded one of them from the pom
Related
I am trying to develop with Eclipse 2020.6 and m2e using openJDK-11 on Win10.
The computer is maintained by IT department having jre-8 in its PATH and I dot have the rights to change that.
I have installed JDK11 below my user folder.
Changed eclipse.ini for Eclipse and toolchain.xml for commandline Maven.
I also checked Module Dependencies in Java Build Path: com.sun.tools.jar is no longer there.
Commandline Maven and Eclipse are using JDK11 instead of jre-8, except the eclipse-editor for pom.xml.
It shows Missing artifact com.sun:tools:jar:1.8.0
I checked Dependency Hierarchie with the pom.xml editor and it shows that ant:1.10.8 depends on tools:1.8.0. But this information must be wrong, as the project tests and installs correctly.
I guess, the eclipse-editor for pom.xml somehow does not use the java libaries pointed to by eclipse.ini or toolchain.xml or those configured with the project Build Path.
Eclipse Preferences/Maven/User Settings points to the local repository .m2\repository and to the user settings .m2\settings.xml. I also copied toolchain.xml to .m2, but without solving the problem.
Please note that I do not have any problem running Maven from within Eclipse. It works as expected. My problem is, that errors are flagged within Eclipse where there is none.
Why does the pom.xml editor in Eclipse complains about tools.jar:1.8.0? How can I make m2e not using java from the PATH but using JDK11 installation for my developments in Eclipse?
I am using new Eclipse Oxygen. My project setup includes Maven. One of the Maven dependencies is Guava:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
There are 2 problems I am facing that do not allow me to build the project:
1.
The project was not built since its build path is incomplete. Cannot find the class file for com.google.common.base.Predicate. Fix the build path then try building this project
2.
The type com.google.common.base.Predicate cannot be resolved. It is indirectly referenced from required .class files [...] Java Problem
Here is what I tried to solve it:
I have made clean & build of my project; I have closed and then reopened it; I have removed it from Eclipse and then re-imported and made clean & build.
Nothing seems to help.
Anyone has any ideas? This is super annoying.
The problem was not related to Eclipse, but it was a maven issue.
In order to fix it I had to clear ~/.m2/repository folder and run Maven->Update Project in Eclipse.
Eclipse by default uses embedded Maven. It is possible, that the guava dependency got corrupted in the embedded Maven's .m2 folder. Try to delete it from there.
Also try to change the Maven in Eclipse to use the same Maven as you use in the command line in:
Preferences->Maven->Installations
I am new to eclipse and maven. I have been trying for two days to run the storm starter project and am hitting a number of problems.
I have a couple of questions of which I will explain my attempts below.
How can I import this project in to eclipse so that it runs and retrieves all required dependencies.
How can I start a storm project from scratch in eclipse. When I start a new maven project and add storm dependency, it only adds storm, and not all of its dependencies.
What I have tried:
I have the latest m2eclipse plugin installed. When I choose import existing maven project (I change the m2-pom.xml to pom.xml I dont know why it is named m2-pom) everything looks ok, but when I do maven install, in maven build, i get the error
clojure-maven-plugin:1.3.8:compile(1 errors)
No marketplace entries found to handle clojure-maven-plugin:1.3.8:compile in Eclipse. Please see Help for more information.
I have tried maven 2 and 3, I have tried creating a new java project then adding a maven configuration and running that.
I have got to the point where it looks like all dependencies have been downloaded, but in my project, all backtype types are still underlined in red and it when I hover over them, it does say import..
I also had another attempt when it said "import backtype.storm..." but when I cliked it the dependency still didnt resolve.
The code I am trying to run is:
https://github.com/nathanmarz/storm-starter
Please help
#girlcoder: I had a similar issue while playing with the "storm-starter" project (i.e. backtype types not recognized despite importing them). I used IntelliJ IDEA at that time, but the fix I found may apply to your case as well:
In the pom.xml file (I also renamed m2-pom.xml as pom.xml), go to the section that defines the dependency on Storm and change its scope to "compile":
<dependency>
<groupId>storm</groupId>
<artifactId>storm</artifactId>
<version>0.9.0.1</version>
<!-- keep storm out of the jar-with-dependencies -->
<!--<scope>provided</scope>-->
<scope>compile</scope>
</dependency>
I used the "provided" scope when deploying the topologies to an actual Storm cluster, but I had to change the scope to "compile" to submit a topology to a LocalCluster. I hope this will help you solve the problem.
UPDATE: I am now trying to package storm-starter in Eclipse 4.3. It turned out that the pom.xml file is not compatible with the m2e eclipse plugin. Besides the modification I suggested above, I was able to compile the project only after changing the pom.xml as described here: https://github.com/nathanmarz/storm-starter/issues/23.
Update
The reason I couldn't update properly was I didn't have game's jar file properly installed. That was fixed by first running this on the command line:
mvn install:install-file -DgroupId=com.mygame -DartifactId=mygame-core -Dversion=0.9-beta -Dpackaging=jar -Dfile=/home/klenwell/projects/mygame/playn/mygame/java/target/mygame-java-0.9-beta.jar
Then, in Eclipse, I right-clicked java folder > Maven > Test. This updated all my dependencies including lwjgl.
Otherwise, see thomasbroad's answer.
Original Question
I've consulted the following authorities on this topic and applied their various recommendations:
http://lwjgl.org/installation.php
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Maven
http://www.lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_Eclipse
https://stackoverflow.com/a/11065814/1093087
https://groups.google.com/forum/?fromgroups#!topic/playn/E2t7gNh4ab0
https://groups.google.com/d/msg/playn/3D4JZ1Dbm-E/HmPHofS2fqgJ
Part of the problem is I'm not sure whether I should be following the Maven instructions or the Eclipse instructions. I've tried both and everything in between.
I'm working in Ubuntu 12.04 64-bit on Eclipse using Maven. Everything was working fine until I changed the PlayN version in my POM file from 1.2 to 1.3.1 and introduced the lwjgl dependency.
What I would have expected to have worked:
1) Download lwjgl (latest version 2.8.4) and test per lwjgl.org instructions (this was successful)
2) Update the appropriate POM files
2A) Add lwjgl.version as a property to mygame/pom.xml
<properties>
<playn.version>1.3.1</playn.version>
<lwjgl.version>2.8.4</lwjgl.version>
</properties>
2B) Add lwjgl as a dependency to mygame/mygame-java/pom.xml
<dependency>
<groupId>org.lwjgl.lwjgl</groupId>
<artifactId>lwjgl</artifactId>
<version>${lwjgl.version}</version>
</dependency>
3) Right-click mygame-java project in Eclipse > Run As > Run Configurations > Arguments and add either -Djava.library.path=target/natives or -Djava.library.path=/absolute/path/to/my/lwjgl/lib to VM arguments. (I've tried both variations.)
I can see the dependencies listed under my java project folder in Eclipse. And when I follow the lwjgl.org guide for Eclipse, I can see the jar listed under the java project folder. But I still get the error.
After two hours of hair-wrenching frustration, I hope somebody can either point out my fatal oversight or provide explicit instructions that will help me get back to work. Thanks.
I upgraded my project from 1.2 to 1.3 a while ago. I only updated my pom.xml files to refer to the new version of PlayN . I did not manually install lwjgl and neither did I add the lwjgl dependency as that one is implicitly pulled in by PlayN
Manually apply the diffs found here to your project, to your poms.
The key part being the piece in the java pom that tells Maven to unpack native dependencies. This part was actually added in the previous diff, so you may want to look there as well.
Now your IDE will most likely tell you that your project is not up-to-date with your poms, update your project, this should pull in the lwjgl dependency and set it up correctly.
I believe you should add the -Djava.library.path arguments to the VM Arguments, not to the Program Arguments in your runtime configuration.
The other -using maven- option is described on the Getting Started page, it worth noting, that the default embedded Maven is buggy for development, you should download and use at least Maven 3.0.3 as it is mentioned on the page (but I guess you already do this).
I just started a new project fresh with PlayN 1.4 and encountered this issue again in Eclipse. Resolved it as follows:
Right click mygame-java > Run As > Run Configurations...
Then added the following to VM Arguments under Arguments tab:
-Djava.library.path=target/natives
Then successfully ran as application.
At one point, I also ran the mvn install:install-file... command mentioned in question but I'm not sure whether that was necessary or not.
I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there - I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?
I had the same problem, and this is what worked for me. Using Eclipse Indigo:
Windows->Show View->Other
In the pop-up:
Maven->Maven Repositories
Once the view is displayed, right click on the appropriate repo, and select "Rebuild Index"
Wait a few seconds and done!
I have dependencies installed local on my machine (~/.m2/repository/blah/blah/blah) and m2eclipse is not recognizing them as there.
Do they have good metadata? How did you install them? Because m2eclipse definitely uses your local repository for dependency resolution.
I think m2eclipse is using its own maven instance. Is there any way to force m2eclipse to use the local maven installation in osx?
Yes, m2eclipse uses its own version of Maven by default and you can add an external installation via Window > Preferences > Maven > Installations but this won't change anything to the local repository used by one or the other that you can configure via Window > Preferences > Maven > User Settings as shown below:
alt text http://www.imagebanana.com/img/w5y2vevt/screenshot_008.png
This send us back to the questions above: how did you "install" the problematic dependencies?
You can change the used Maven instance in Windows->Preferences->Maven->Installations. But I'm not sure whether this will help as a comment below that setting says that dependency resolution will still be done with the internal Maven installation.
If I were you, I would try to add that local repository to the list of known repositories. Use Window->Show View->Maven repositories (this is sadly not visible in the preferences).
Check that the jar was installed properly. Maven does not give an error when you provide an incorrect path to the jar when installing to local repository. The jgravatar.jar was not in my ~ directory when I ran the command below.
mvn install:install-file -Dfile=~/jgravatar.jar -DgroupId=jgravatar -DartifactId=jgravatar -Dversion=06292012 -Dpackaging=jar
[INFO] Installing /Users/steve/~/jgravatar.jar to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.jar
[INFO] Installing /var/folders/gz/gjyqtkzj3ys8lpmh_38qvmn00000gq/T/mvninstall2662938607942511865.pom to /Users/steve/.m2/repository/jgravatar/jgravatar/06292012/jgravatar-06292012.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I was getting the exact same issue. I added the JARs to the local repository via the install-file command. I verified they were installed. I rebuilt the index. I went to the directory and inspected the JAR file using 7Zip, but I could not get it to appear in the Maven Dependencies inside of my eclipse project.
For me the solution was pretty silly. When I added the dependency into the pom.xml using the dependencies editor, Maven threw in a packaging stanza into the XML. So the XML entry looked like:
<dependency>
<groupId>slf4j</groupId>
<artifactId>jdk14</artifactId>
<version>1.5.8</version>
<type>JAR</type>
</dependency>
When I removed the last stanza "JAR" and made the entry:
<dependency>
<groupId>slf4j</groupId>
<artifactId>jdk14</artifactId>
<version>1.5.8</version>
</dependency>
it all worked fine.