Maven not updating/downloading dependencies - eclipse

I'm using Eclipse EE and Apache Wicket.
I have my dependencies written down at pom.xml.
For some reason, maven is not updating even when I try to clean the project and go under Maven > Update Project.
When I go to check the dependencies the jar is there, but it still give me error when I try to run (ClassNotFoundException).
Why is this happening?
Dependency in question:
<dependency>
<groupId>org.tuckey</groupId>
<artifactId>urlrewritefilter</artifactId>
<version>4.0.3</version>
</dependency>
Also already tried to reinstall maven.

Try running mvn eclipse:eclipse to update ur Eclipse.
Also, refresh after completion of the command run.

You shouldn't mix "mvn eclipse:eclipse" and m2eclipse maven eclipse plugin, it will cause the plugin to not operate correctly. If you have done so, you need to remove your .project/.classpath/.settings files and re-import with "import existing maven projects".

Related

Eclipse can't find a class on my classpath

The project is a maven project.
run as maven install works
mvn install works
I have tried mvn eclipse:eclipse to update project, I can see the jar file in my properties order and export
I have closed and reopened the project
I have deleted and re added the project
I have done a refresh
I have done a maven update project
I have cleaned the project
maven disable maven nature and then configure convert to maven project
It builds just fine from:
The command line:
mvn install
In eclipse run as maven install
It works in intellij idea
For the love of all that is holy...
There was a class of the same name in this project with all lines commented out.
Deleting that source file fixed the problem.

Eclipse maven not adding dependencies

I am new to maven and am experiencing difficulties while trying to mavenise a Java project.
Setting:
IDE: Eclipse Oxygen.2 Release (4.7.2)
Java: 8
m2e: 1.8.2
What I did:
- copy-pasted the entire original java project and renamed it
- right-click in eclipse: Configure > Convert to Maven project
- in java build path, deletion of libraries import from original local lib repo. The build path shows the Maven Dependencies folder, with the only junit library.
- maven install => downloaded things in the user/.m2/repository/, but not all.
What does not work:
When I try to add a dependency right from a file:
,
nothing pops up in the artifact selection windows, even though there is a commons-logging/ folder in m2/repository
When I try to add the dependency manually in the pom.xml:
<dependency>
<groupId>org.kie.modules</groupId>
<artifactId>org-apache-commons-configuration-main</artifactId>
<version>6.5.0.Final</version>
<type>pom</type>
</dependency>
but the package resolution error still appears in the java file, and I get this warning after Maven install
`[WARNING] The POM for org.kie.modules:org-apache-commons-configuration-main:pom:6.5.0.Final is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details`
I did Maven Update project, eclipse project clean, nothing changes.
My goal for now is just that eclipse understands (at least for one library), that it has to take it from maven repository. I still have many other dependencies to solve (intra-project), but that will be the next step.
Thanks for your help.
The cause of the issue is stated in the warning message :
[WARNING] The POM for
org.kie.modules:org-apache-commons-configuration-main:pom:6.5.0.Final
is invalid, transitive dependencies (if any) will not be available,
enable debug logging for more details
It means that the pom.xml downloaded in your local maven repository exists but is not valid.
Delete the folder of the dependency downloaded in your local maven repository and try again.
If you still have the same problem, check that your central repository that provides the dependency provides also correctly the pom.xml for that.
You can do it by browsing the directory of the dependency from a web browser.
For example we can see that the maven central repository provides a valid pom :
http://central.maven.org/maven2/org/kie/modules/org-apache-commons-collections-main/6.5.0.Final/org-apache-commons-collections-main-6.5.0.Final.pom

How to add maven dependencies to an Eclipse Plugin Project?

I try to add Maven dependency for my plugin project, but it doesn't work.
Always get NoClassDefFoundError. Somebody can explain me what should I do?

Run maven:install will copy more jars to WEB-INF/lib than i expect

Eclipse Indigo; m2e 1.1.0; Maven integration for WTP 0.15.3; Maven 3.0.4
My web project has some dependency projects in the same workspace. All projects are installed. When i run maven install, except to see all dependencies in WEB-INF/lib.
When i run maven install plugin or maven war plugin, the WEB-INF/lib will be filled with dependencies, but they are a lot more than i expected, from the "dependency Hierarchy" or "Effective POM" view of the POM file, or from Maven dependencies in classpath view, i can not find the dependencies.
Run Maven->update projects does not help.
So where these dependencies come from or where should i start to debug?
EDIT
Previously my project has a large dependency tree(100+ jars), some of them are not needed, so i decided to remove them. My project depends on a common project, which has some not needed dependencies, i remove them from POM dependencies and run maven install for the whole projects dependency tree, success. then i run maven install on my project, it should not include the jars i removed from the common project, but, unfortunately they are there in WEB-INF/lib.
If you want to know where your dependencies are coming from, run:
mvn dependency:tree
from the command line. This shows how transitive dependencies are pulled in from your declared dependencies.
You can also run:
mvn dependency:analyze
to see if you can remove any unused dependencies to lessen the number of JARs packaged.
Problem solved, I delete the whole project and import from remote, run maven-install, it worked. Still have no idea why it not work before even after i run "maven clean install" on all dependency projects.

m2eclipse error

I am developing a web application with Eclipse and I generate the project with a maven archetype.
When I enable maven dependency management, Eclipse mark some errors in the pom file, this error is:
Multiple annotations found at this line:
- Execution default-testResources of goal org.apache.maven.plugins:maven-resources- plugin:2.4.3:testResources failed:
Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
plugin:2.4.3:testResources:default-testResources:process-test-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile
(execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
api-2.0.6.pom
- CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile:
PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not be
resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 ():
ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-plugin-api:jar:2.0.6:
ArtifactResolutionException: Failure to transfer org.apache.maven:maven-plugin-api:pom:2.0.6 from http://repo1.maven.org/
maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or
updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:pom:2.0.6 from/to central (http://
repo1.maven.org/maven2): null to http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-
api-2.0.6.pom
- Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.4.3:resources failed: Plugin
org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could not be resolved: Failed to collect
dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3 () (org.apache.maven.plugins:maven-resources-
plugin:2.4.3:resources:default-resources:process-resources)
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
2.3.2:testCompile (execution: default-testCompile, phase: test-compile)
My pom file is the following:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lala.sarasa</groupId>
<artifactId>msrdecision</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>msrdecision Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>hello</finalName>
</build>
</project>
Any idea?
I had same problem with Eclipse 3.7.2 (Indigo) and maven 3.0.4.
In my case, the problem was caused by missing maven-resources-plugin-2.4.3.jar in {user.home}\.m2\repository\org\apache\maven\plugins\maven-resources-plugin\2.4.3 folder. (no idea why maven didn't update it)
Solution:
1.) add dependency to pom.xml
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
</dependency>
2.) run mvn install from Eclipse or from command line
3.) refresh the project in eclipse (F5)
4.) run Maven > Update Project Configuration... on project (right click)
JAR file is downloaded to local repository and there are no errors in WS.
I also had same problem with Eclipse 3.7.2 (Indigo) and maven 3.0.4.
Eclipse wasn't picking up my maven settings, so this is what I did to fix the problem:
Window - Preferences - Maven - Installations
Add (Maven 3.0.4 instead of using Embedded)
Click Apply & OK
Maven > Update Project Configuration... on project (right click)
Shutdown Eclipse
Run mvn install from the command line.
Open Eclipse
Those steps worked for me, but the problem isn't consistent. I've only had with issue on one computer.
Just go to your user folder, inside it there's a ".m2" folder, open it and delete the folder "repository". Go to eclipse, clean your project, then right click->Maven->Update Project .. and you are ready to go.
I solved this by running mvn -U install from command line and then "Maven->Update Project" from Eclipse
In this particular case, the solution was the right proxy configuration of eclipse (Window -> Preferences -> Network Connection), the company possessed a strict security system. I will leave the question, because there are answers that can help the community. Thank you very much for the answers above.
In my case the problem was solved by Window -> Preferences -> Maven -> User Settings -> Update Settings. I don't know the problem cause at the first place.
This what helped me:
Delete the project from eclipse (but don't delete from disk)
Close eclipse
In your user folder there is .m folder. Delete repository folder underneath it (.m/repository).
Open eclipse
Import project as existing maven project (from disk).
Good luck.
I would add some points that helped me to solve this problem :
When all other missing archetypes have been indeed installed into your local repository, and the only remaining and abnormally sticking error is this (damned ..) one, whereas the maven-filtering-x.jar is present in his directory, the problem could finally only be solved by creating a new work space as was suggested by Dan in his response ( http://mail-archives.apache.org/mod_mbox/incubator-isis-dev/201112.mbox/%3CCALJOYLFfSJ5Xc_z7a7N+S2_kabuVv0ykv7A5afQaJJOb99iCdg#mail.gmail.com%3E ) (thanks).
Having the local repository OK, on the other hand, turned out to be quite costly, as many archetypes would not get loaded, due apparently to timeouts of m2eclipse and very unstable communication speeds in my case.
In many cases only the error file could be found in the folder ex : xxx.jar.lastUpdated, instead of the jar or pom file. I had always to suppress this file to permit a new download.
Also really worthy were :
as already said, using the mvn clean install from the command line, apparently much more patient than m2eclipse, and also efficient and verbose, at least for the time being.
(and also the Update Project of the Maven menu)
downloading using the dependency:get goal
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get -DrepoUrl=url -Dartifact=groupId:artifactId:version1
(from within the project folder) (hint given in another thread, thanks also).
also downloading and installing manually (.jar+.sha1), from in particular, "m2proxy atlassian" .
adding other repositories in the pom.xml itself (the settings.xml mirror configuration did'nt do the job, I don't know yet why). Ex : nexus/content/repositories/releases/ et nexus/content/repositories/releases/, sous repository.jboss.org, ou download.java.net/maven/2 .
To finish, in any case, a lot of time (!..) could have been et could certainly still be spared with a light tool repairing thoroughly the local repository straightaway. I could not yet find it. Actually it should even be normally a mvn command ("--repair-local-repository").
Encountered the same problem.
For my case i was working behind a proxy.
My solution was
Modify the settings.xml file in the .m2 folder to add the proxy configuration.
proxy
true
http
172.23.182.63
4145
In eclipse Click update settings button. Menu: Windows>>Preferences>>Maven>>User Settings
Delete the .m2/repository folder
Refresh my maven project.
After step 4 - eclipse took a few minutes downloading files and project refreshed successfully.
It must be a configuration problem. Your pom is fine.
Here's what I did. New folder, put your pom inside. Then in eclipse: import -> maven -> existing maven project. Dependencies got included in the project.
I did this using eclipse helios. I think the plugin version I am using is 0.12
You should check the maven properties in eclipse.
This error bothered me for two days. I tried all kinds of solutions, nothing worked. Finally I give up and tried a radical approach. and it worked! Here are the steps:
Save a copy of the pom.xml,
deleted all text in pom.xml
Let eclipse do a clean rebuild, of course everything will be broken.
pasted back everything in the original pom.xml
let Eclipse build again
I guess it was "indeterministic" as the following article said.
http://wiki.eclipse.org/M2E_plugin_execution_not_covered
in my case there was a dependency without a version. in eclipse m2e does not force you to enter a version so i left it blank. once i put the version in pom.xml from within eclipse all was fine
I had a similar case for the default groovy compiler plugin
The solution was to install ME2 provided by Springsource according to this answer
Plugin execution not covered by lifecycle configuration maven error
This immediately solved the "Plugin execution not covered by lifecycle configuration" problem in Eclispe Juno.
I had the same problem but with an other cause. The solution was to deactivate Avira Browser Protection (in german Browser-Schutz). I took the solusion from m2e cannot transfer metadata from nexus, but maven command line can. It can be activated again ones maven has the needed plugin.
I am using MacOSX with Eclipse 4.3 (Krepler). What I originally tried was to install Maven via the terminal using Brew. It installed correctly Maven 3.0.4. However when I tried to import any ready maven projects (File > Import > Maven) it would display the following two errors:
No marketplace entries found to handle Execution default-testResources
What I did is go to Help > Eclipse Marketplace and type "Maven" in the search bar and install the first default Maven client for Eclipse. Everything worked for me from this point.
Hope it helps to you too.
The following steps worked for me:
Close Eclipse.
Navigate to user home directory. (For example: "C:\Users\YourUserName.m2")
Delete the "repository" folder.
Re-open Eclipse.
Click on the Maven project that has an issue and go to "Project" --> "Clean".
Right-click on the project and go to "Maven" --> "Update Project...".
Close Eclipse.
Open Eclipse.
Click on the project folder in the "Project Explorer" window (usually on the left).
Hit the "F5" key a few times to Refresh your project.
Done!
These steps worked for me in Eclipse Luna. Please let me know if I can help further.
My issue was that eclipse could not find the mvn.bat file within the installation directory. The solution is to create a mvn.bat file with the following code:
"%~dp0\mvn.cmd" %*
Save that file. Place it inside the [Maven Installation Folder]\bin directory.