Missing Maven dependencies in Eclipse project

0 votes
asked Nov 23, 2010 by hostnik

We have a project set up with maven for resolving dependancies. It usually works fine, but now I am trying to compile and run it on a new PC and I have problem with missing dependencies in Eclipse.

What is funny is that if I run "mvn package" in console or in eclipse, it works fine and even produces war containing all necessary jars. Only Eclipse complains with "The project was not built since its build path is incomplete. Cannot find the class file for org.slf4j.Logger...". If I compare the project with some other computer (where project works fine), I notice that there are quite a few libraries missing under "Maven dependencies" listing in Eclipse. Eventhough they are in the packaged war and they can be found also under repository folder.

So, the jar-s are there just Eclipse won't list them all under "Maven dependencies". What can I do?

Computer is running on Windows 7 with 64bit java & eclipse.

24 Answers

0 votes
answered Nov 24, 2010 by hostnik

Problem solved!

I don't know what exactly solved it, but I did 4 things in Eclipse:

  • Window->Preferences: Maven->Installations: Global settings -> open file and hardcoded localRepository
  • Project->Clean
  • right click on project: Maven->Update dependencies
  • right click on project: Maven->Update project configuration

I guess it was the Update dependencies since right after first two there were no change.

0 votes
answered Jan 2, 2011 by icebox13

I had this issue for dependencies that were created in other projects. Downloaded thirdparty dependencies showed up fine in the build path, but not a library that I had created.

SOLUTION: In the project that is not building correctly, right-click on the project and choose Properties, and then Maven. Uncheck the box labeled "Resolve dependencies from Workspace projects", hit Apply, and then OK. Right-click again on your project and do a Maven->Update Snapshots (or Update Dependencies) and your errors should go away when your project rebuilds (automatically if you have auto-build enabled).

0 votes
answered Jan 27, 2011 by rogueleaderr

I'm also new to Eclipse, and I've been having a similar problem where Eclipse just won't recognize an import statement, even though all signs point to the dependency having been successfully downloaded.

You should check that your dependency file has actually been downloaded by going to the command line and typing

mvn dependency:tree

If you see your package there, then but Eclipse doesn't acknowledge it, the thing that works for me (sometimes) is to go to the terminal, cd into the project folder, and type

mvn eclipse:clean then mvn eclipse:eclipse

Finally refresh project in eclipse

I don't know why this works, and sometimes it doesn't work once, then doing it again does work... so worth a try!

0 votes
answered Jan 9, 2012 by komododave

If you have "nested paths" errors after performing Maven -> Update Project Configuration (or in Juno it's "Update Configuration...") then your build path is misconfigured.

Right-click project -> Build Path -> Configure Build Path

Ensure that only '/src' and directories at that level are included. If you have e.g. '/src' and also '/src/main/resources' present, this is incorrect. The second resource ('/src/main/resources') is "nested" under the first ('/src') which is causing your inability to import resources, since it prevents eclipse from seeing maven dependencies.

0 votes
answered Jan 18, 2012 by welsh

My issue sounds similar so I'll add to the discussion. I had cancelled the import of an existing maven project into Eclipse which resulted in it not being allowed to Update and wouldn't properly finish the Work Space building.

What I had to do to resolve it was select Run As... -> Maven build... and under Goals I entered dependency:go-offline and ran that.

Then I right clicked the project and selected Maven -> Update Project... and updated that specific project.

This finally allowed it to create the source folders and finish the import.

0 votes
answered Jan 18, 2012 by joseph-lust

My Project was just screwed up. Here is how I fixed it for Eclipse Indigo x64 (J2EE 3.7.3):

  1. Deleted my POM file (backedup of course).
  2. Project Context Menu > Maven > Disable Maven Nature.
  3. Deleted the project (but not contents on disk).
  4. Re-imported as Import > General > Existing Project.
  5. Project Context Menu > Configure > Convert to Maven Project....
  6. Accept defaults from Maven wizard.
  7. Overwrite POM with your backedup POM. (Now you have Maven Dependencies folder).
  8. Maven Update/Clean for good measure.

Hope that helps someone. :)

0 votes
answered Jan 22, 2012 by darryl-sibeon

I had a similar problem. I solved it by running the Maven->Update Project Configuration action

0 votes
answered Jan 23, 2012 by danger

It's so amazing that this one problem has so many different causes and possible solutions. I found yet a different solution that worked for me.

Well, it's not so much a solution but a discovery: I can see the Maven Dependencies node in the Package Explorer, which is the default for the Java perspective, but I can not see it in the Java EE perspective, which uses the Project Explorer by default. Both of those explorers look very similar at quick glance, so you may expect to see the Maven Dependencies in both.

As I was trying to figure this out, I hadn't realized that difference, so it wasn't really a problem for me in the end after all.

0 votes
answered Jan 20, 2013 by nandan-bhalwankar

I could solve the error by 1) Right click (your maven project) -> maven -> maven install

After successful installation

2) Right click (your maven project) -> maven -> update project. And the whole error of maven got solved!

0 votes
answered Jan 28, 2013 by mik80

the whole project looked weird in eclipse, maven dependencies folder were missing, it showed some types as unknown, but I was able to build it successfully in maven. What fixed my issue was adding gen folder to source path on project build path.

Probably this is similar to this Android /FBReaderJ/gen already exists but is not a source folder. Convert to a source folder or rename it

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter