2

I've been trying to add a custom .jar (ftp://ftp.ncbi.nlm.nih.gov/pub/eutils/soap/v2.0/java/axis2_1.5.2_jdk_6.0.12/eutils_axis2.jar) to a project that doesn't have a central corporate maven repository and that instead will have the custom JARs checked into SCM in the project directory tree. I was following this post to make it happen: Maven: add a dependency to a jar by relative path (awesome post btw).

What I did was:

  1. Add local repository to pom.xml
  2. install the file into the local repository
  3. Add dependency to pom.xml

Based on what I see in m2eclipse, the library has been successfully recognized by Maven and added to the dependency list (or it'd be called ? : ? or something similar)

The problem is that Eclipse still doesn't see the referenced lib, so this still fails:

import gov.nih.nlm.ncbi.www.soap.eutils.*;

Pardon my maven newbiness, but what are changes / next steps I need to make to get to:

  1. Have Eclipse see the library so that autocomplete works (and the import can be resolved)
  2. Be able to compile the project
  3. Be able to execute the jar produced by mvn package?

Thanks!

Community
  • 1
  • 1
Alexandr Kurilin
  • 7,188
  • 6
  • 43
  • 72

1 Answers1

3

If you see the JAR under "Maven Dependencies" in your project, Eclipse should be able to see and use it. If it's not there, then m2eclipse wasn't able to resolve the dependency properly.

If it is missing, m2eclipse was unable to download the dependency from your local repository for some reason. Check the Maven 2 Console for errors and the Problem View.

Lastly, the JAR itself might be corrupt. Maven doesn't check for that, it simply adds the file to the classpath. If Eclipse can't open the JAR, you can also get the errors you mentioned.

Aaron Digulla
  • 297,790
  • 101
  • 558
  • 777
  • 1
    In addition - refresh the project and clear it. Maybe, m2eclipse needs a small kick to recognize, the the `pom` has been changed and the project has to be reconfigured... – Andreas Dolk Apr 18 '11 at 07:24
  • It seems like running mvn eclipse:clean and mvn eclipse:eclipse did the trick and the import was resolved successfully. It actually appears that Eclipse can't seem to find a library that I downloaded through m2eclipse. When I try to construct the EUtilsServiceStub() class (in that library above) it complains about: The constructor EUtilsServiceStub() refers to the missing type AxisFault. AxisFault is actually part of org.apache.axis2 which I added to my list of dependencies through mvn, but it's not in "Referenced Libraries". Do you folks know how I can get it in there? – Alexandr Kurilin Apr 18 '11 at 07:36
  • Make sure you have the latest version of m2eclipse installed. Note: When you create a project with `mvn eclipse:eclipse`, m2eclipse is disabled for the project. To force m2eclipse to refresh, you can use the update command in the "Maven" context menu or you can edit the `pom.xml` (add a space, delete it, save). – Aaron Digulla Apr 18 '11 at 21:11