Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven resolves dependecy but cannot find package/classes in it

In custom geotools platform compilation (in fact OSGi-based) one of the modules compiles properly when I try to build it separetly. But when I build the whole project - it fails on compile stage with reason that it cannot find certain packages/classes. Howerver the dependincy is resolved fine.

here is the dependency from module's pom.xml:

<dependency>
   <groupId>org.picocontainer</groupId>
   <artifactId>com.springsource.org.picocontainer</artifactId>
   <version>1.2.0</version>
</dependency>

the part of maven's build error:

...\geotools-osgi\modules\extension\xsd\xsd-core\src\main\java\org\geotools\xs\bindings\XSGroupBinding.java:[19,24] package org.picocon tainer does not exist

...\geotools-osgi\modules\extension\xsd\xsd-core\src\main\java\org\geotools\xml\AbstractComplexBinding.java:[20,24] package org.picocon tainer does not exist

...\geotools-osgi\modules\extension\xsd\xsd-core\src\main\java\org\geotools\xml\ComplexBinding.java:[21,24] package org.picocontainer does not exist

if I change the pom.xml dependecy - it fails with some kind of "cannot resolve bundle".

The project is really big and the number of bundles and child/parent poms. So I can't post all of them here. So my question is: what is the possible reason for this kind of trouble? Could it be a dependency conflict between parent/child?

like image 291
Alex Stybaev Avatar asked Apr 12 '12 11:04

Alex Stybaev


3 Answers

I can see two things to try to solve it out.

First, if you go in your local .m2 repo, you will see if there are other versions of the lib (however, sometimes different versions can have a different name, and therefor be stored in a different folder, which does not help)

You can also check what is the ACTUAL dependency used, in your IDE, or in command line (mvn dependency:tree). You might have to exclude some transitive dependency to remain consistent. I use the Eclipse plugin for that.

Finally, when you are sure of the dependency you use, you can open the jar and see if what you expect to be there is present.

like image 197
Samuel EUSTACHI Avatar answered Oct 05 '22 11:10

Samuel EUSTACHI


Well, the actual reason was that the target computer had the restricted access to the internet, so the restricted access to the maven repos. With some black magic it did not fail with some kind of 'cannot download artifact' (maybe because of manual install of some jar files). So we got the server with normal access, set it up as a mirror, configured our maven to use the mirror and that solved the problem. Thanks @Samuel for participating in my problem, but as I can see that it was not possible to determine the problem from the problem description.

like image 36
Alex Stybaev Avatar answered Oct 05 '22 10:10

Alex Stybaev


I also had the same problem. In my case all classes in the module were in test package(it was Selenium project) and dependency was set to compile. I ended up moving some classes to main package.

like image 21
annag Avatar answered Oct 05 '22 10:10

annag