I am using apache-karaf-2.4.3, shipping our maven repository locally, and
shipping features definition to this local maven repository in order to
determine what features are to be installed upon karaf startup. We are
running into an intermittent issue issue in v2.4.3 (not seen before with
v2.3.0) with maven artifact resolution upon startup where my the local
repository is not being used.

The error seen in karaf.log is: 
INFO: locking 
2016-01-12 02:32:46,303 | WARN  | Event Dispatcher | AetherBasedResolver        
     
| /mvn.internal.AetherBasedResolver  583 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 |  | Error resolving
artifactcom.ca.im:data-mgmt.provision:xml:features:2.7.0-RELEASE-137:Could
not find artifact
com.ca.im:data-mgmt.provision:xml:features:2.7.0-RELEASE-137 in central
(http://repo1.maven.org/maven2/) 
shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not
find artifact com.ca.im:data-mgmt.provision:xml:features:2.7.0-RELEASE-137
in central (http://repo1.maven.org/maven2/)
    at
shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
 
    at
shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
/

This should not even be going out to *repo1.maven.org/maven2*. 
 Maven repository configuration specifies the location of  local and default
repos in org.ops4.pax.url.mvn.cfg file as follows:

org.ops4j.pax.url.mvn.localRepository=*../.maven_repository*@id=local-repository
 
.. 
... 
org.ops4j.pax.url.mvn.defaultRepositories=*file:../.maven_repository@snapshots*@id=defaut-repository,file:${karaf.home}/${karaf.default.repository}@snapshots@id=karaf.${karaf.default.repository}

I have tried the following to prevent this behavior with out success:
1) disabling the aether resolver based on the comments in the file, 
2) specifying repositories (in addition to defaultRepository)
None of these have worked. 

In debugging and adding trace statements to the pax-url-aether code, it is
evident that 
 - there is a race condition between karaf startup features resolution and
maven repository initialization.
 - If the featuresRepositories are resolved before the maven repository is
fully initialized, it can cause the fallback maven profile to be used (even
if you have useFallback=false) by the AetherBasedResolver to resolve the
specified features.xml. 
 - This will result in an attempt to resolve the artifact from
repo1.maven.org, even though artifact is present in the local maven
repository.

Here is what *org.apache.karaf.features.cfg* looks like:
featuresRepositories =
mvn:org.apache.karaf.assemblies.features/standard/2.4.3/xml/features,mvn:org.apache.karaf.assemblies.features/spring/2.4.3/xml/features,mvn:org.apache.karaf.assemblies.features/enterprise/2.4.3/xml/features,*mvn:com.ca.im/data-mgmt.provision/2.7.0-RELEASE-141/xml/features*
 
Note that if I replaced my custom com.ca.im.. feature with a reference to
the exact file like
file:///opt/blah/path/to/com.ca.im/features/xml/features.xml
, then that resolved the issue for my custom feature, but given enough karaf
initializations, I still saw similar  issues resolving the karaf system
libraries.

Questions:
- Has anyone seen this error before? 
- Or has this been fixed in a newer version of karaf?  



--
View this message in context: 
http://karaf.922171.n3.nabble.com/maven-using-repo1-maven-org-on-karaf-startup-tp4044942.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply via email to