Discussion:
Add additional local maven repository - how?
Graham Leggett
2013-03-23 23:34:50 UTC
Permalink
Hi all,

I have been struggling with karaf v2.3.1 trying to make it recognise a free standing maven repository called /usr/share/java/foo-pipeline containing a set of osgi bundles.

I have modified org.ops4j.pax.url.mvn.cfg as follows:

org.ops4j.pax.url.mvn.defaultRepositories=file:/usr/share/karaf/${karaf.default.repository}@***@id=karaf.${karaf.default.repository}, \
file:/usr/share/java/foo-***@snapshots@id=foo

I have modified org.apache.karaf.features.cfg to add the feature on startup, and karaf starts up correctly without error:

featuresRepositories=mvn:org.apache.karaf.assemblies.features/standard/2.3.1/xml/features,mvn:org.apache.karaf.assemblies.features/enterprise/2.3.1/xml/features,mvn:org.apache.cxf.karaf/apache-cxf/2.6.3/xml/features,mvn:com.foo/foo-pipeline-features/3.0.0-SNAPSHOT/xml/features,mvn:com.foo/foo-pipeline/3.0.0-SNAPSHOT/xml
featuresBoot=config,ssh,management,kar,war,web console,foo-pipeline

When I attempt "features:list" from the console, I don't see the feature listed, and I'm stuck at this point.

Can anyone describe the correct way to do this?

Regards,
Graham
--
Jean-Baptiste Onofré
2013-03-24 14:15:54 UTC
Permalink
sebersole
2015-05-28 19:11:39 UTC
Permalink
I am having trouble with this via Pax Exam.

I have an artifact that is currently not available in Maven Central. So I
specify the appropriate repository in Pax Exam @Configuration method, using:

return options(
repositories(
repository(
"http://repository.jboss.org/nexus/content/groups/public/" )...
)
);

However, I keep getting errors that the artifact cannot be resolved:

shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not
find artifact org.jboss.logging:jboss-logging:jar:3.3.0.Final in central
(http://repo1.maven.org/maven2/)

Is this just a bad error message? Or is Karaf really only looking in Maven
Central even though I (thought I) told it to look in JBoss Nexus as well?

As you can see, the artifact is there...

https://repository.jboss.org/nexus/content/groups/public/org/jboss/logging/jboss-logging/3.3.0.Final/



--
View this message in context: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040638.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Achim Nierbeck
2015-05-28 19:33:57 UTC
Permalink
Hi Steve,

is it a Karaf Pax-Exam test, or a "pure" OSGi test.
Cause both differ in resolving artifacts. The repository option you used
only works for "pure" OSGi tests.
If you have a Karaf-Container test, you'll need to alter the
org.ops4j.pax.url.mvn.cfg file within your test:

editConfigurationFileExtend("org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.repositories", "
http://repository.jboss.org/nexus/content/groups/public/")

regards, Achim
Post by sebersole
I am having trouble with this via Pax Exam.
I have an artifact that is currently not available in Maven Central. So I
return options(
repositories(
repository(
"http://repository.jboss.org/nexus/content/groups/public/" )...
)
);
shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not
find artifact org.jboss.logging:jboss-logging:jar:3.3.0.Final in central
(http://repo1.maven.org/maven2/)
Is this just a bad error message? Or is Karaf really only looking in Maven
Central even though I (thought I) told it to look in JBoss Nexus as well?
As you can see, the artifact is there...
https://repository.jboss.org/nexus/content/groups/public/org/jboss/logging/jboss-logging/3.3.0.Final/
--
http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040638.html
Sent from the Karaf - User mailing list archive at Nabble.com.
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master
sebersole
2015-05-28 20:26:56 UTC
Permalink
Boy, that's an unfortunate leakage. Anyway, thanks (again) Achim! :)



--
View this message in context: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040640.html
Sent from the Karaf - User mailing list archive at Nabble.com.
sebersole
2015-05-28 20:29:40 UTC
Permalink
That did not fix the problem though. Same error.



--
View this message in context: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040641.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Achim Nierbeck
2015-05-28 20:41:02 UTC
Permalink
Ok, in that case, check what the test-configuration actually did to this
file :-)

check the unpack directory, in that you should find a complete Karaf.
In there within the etc folder is the altered configuration file of yours.
The header of this file should also say something like "Modified by paxexm"
Make sure that your repository is correctly configured.

So it should look similar to this:
org.ops4j.pax.url.mvn.repositories =
http://repo1.maven.org/***@id=central,
http://repository.jboss.org/nexus/content/groups/***@id=jboss

regards, Achim
Post by sebersole
That did not fix the problem though. Same error.
--
http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040641.html
Sent from the Karaf - User mailing list archive at Nabble.com.
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master
sebersole
2015-05-28 21:08:59 UTC
Permalink
Achim,

That file was seemingly not touched. The file has no mention of "modified
by paxexam" and the setting has no mention of my repo:

org.ops4j.pax.url.mvn.repositories= \
http://repo1.maven.org/***@id=central, \

http://repository.springsource.com/maven/bundles/***@id=spring.ebr.release,
\

http://repository.springsource.com/maven/bundles/***@id=spring.ebr.external,
\
http://zodiac.springsource.com/maven/bundles/***@id=gemini, \

http://repository.apache.org/content/groups/snapshots-***@id=***@snapshots@noreleases,
\

https://oss.sonatype.org/content/repositories/***@id=***@snapshots@noreleases,
\

https://oss.sonatype.org/content/repositories/ops4j-***@id=***@snapshots@noreleases

Here is my @Configuration method:

return options(
when( debug ).useOptions( debugConfiguration( "5005", true ) ),
karafDistributionConfiguration()
.frameworkUrl( paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.distroUrl" ) )
.karafVersion( paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.version" ) )
.name( "Apache Karaf" )
.unpackDirectory(
new File(
paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.unpackDir"
)
)
)
.useDeployFolder( false ),
editConfigurationFileExtend(
"org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.repositories",
"https://repository.jboss.org/nexus/content/groups/public/"
),
configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
// when( debug ).useOptions( keepRuntimeFolder() ),
keepRuntimeFolder(),
logLevel( LogLevelOption.LogLevel.INFO ),
features( featureXmlUrl( paxExamEnvironment ), "hibernate-native",
"hibernate-jpa" ),
features( testingFeatureXmlUrl(), "hibernate-osgi-testing" )
);
}

P.S. `paxExamEnvironment` is a Properties I load from a prop file I create
in Gradle in order to be able to test within my IDE as well as from Gradle.
Those values are all accurate.



--
View this message in context: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040643.html
Sent from the Karaf - User mailing list archive at Nabble.com.
Achim Nierbeck
2015-05-28 21:15:32 UTC
Permalink
Could you move the editConfiguration... part right before the
configureConsole() part.
I think at that point it's not working.

Take the baseTest Class from the Pax-Web project as a sample.
This part is configured in a later step. [1]

regards, Achim

[1] -
https://github.com/ops4j/org.ops4j.pax.web/blob/master/pax-web-itest/pax-web-itest-karaf/src/test/java/org/ops4j/pax/web/itest/karaf/KarafBaseTest.java#L95
Post by sebersole
Achim,
That file was seemingly not touched. The file has no mention of "modified
org.ops4j.pax.url.mvn.repositories= \
,
\
,
\
,
\
,
\
return options(
when( debug ).useOptions(
debugConfiguration( "5005", true ) ),
karafDistributionConfiguration()
.frameworkUrl(
paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.distroUrl" ) )
.karafVersion(
paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.version" ) )
.name( "Apache Karaf" )
.unpackDirectory(
new File(
paxExamEnvironment.getProperty(
"org.ops4j.pax.exam.container.karaf.unpackDir"
)
)
)
.useDeployFolder( false ),
editConfigurationFileExtend(
"org.ops4j.pax.url.mvn.cfg",
"org.ops4j.pax.url.mvn.repositories",
"
https://repository.jboss.org/nexus/content/groups/public/"
),
configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
// when( debug ).useOptions(
keepRuntimeFolder() ),
keepRuntimeFolder(),
logLevel( LogLevelOption.LogLevel.INFO ),
features( featureXmlUrl(
paxExamEnvironment ), "hibernate-native",
"hibernate-jpa" ),
features( testingFeatureXmlUrl(),
"hibernate-osgi-testing" )
);
}
P.S. `paxExamEnvironment` is a Properties I load from a prop file I create
in Gradle in order to be able to test within my IDE as well as from Gradle.
Those values are all accurate.
--
http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4040643.html
Sent from the Karaf - User mailing list archive at Nabble.com.
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master
Stuart McCulloch
2015-05-28 21:20:22 UTC
Permalink
Post by Achim Nierbeck
editConfigurationFileExtend(
"org.ops4j.pax.url.mvn.cfg",

shouldn't that be "etc/org.ops4j.pax.url.mvn.cfg" ?
Achim Nierbeck
2015-05-28 21:24:26 UTC
Permalink
There you go, couldn't even read my own tests :D
it's supposed to be etc/...

thanks for spotting

regards, Achim

P.S. might be to late for today already ... so I should better go to bed ;)
Post by Achim Nierbeck
Post by Achim Nierbeck
editConfigurationFileExtend(
"org.ops4j.pax.url.mvn.cfg",
shouldn't that be "etc/org.ops4j.pax.url.mvn.cfg" ?
--
Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master
s***@gmail.com
2016-01-14 02:13:42 UTC
Permalink
I am running into a similar issue with karaf 2.4.3 where my localrepositories
are not being used, even though they are specified as local and default
repos in org.ops4.pax.url.mvn.cfg file:
org.ops4j.pax.url.mvn.localRepository=../***@id=local-repository
..
...
org.ops4j.pax.url.mvn.defaultRepositories=file:../***@snapshots@id=defaut-repository,file:${karaf.home}/${karaf.default.repository}@***@id=karaf.${karaf.default.repository}

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)


I have tried disabling the aether resolver based on the comments in the
file, and initially that looked like it worked. But, when i set up a script
to restart karaf and look for the error and tested overnight, I could
reproduce the problem with karaf-2.4.3 greater than 50 % of the time.

I enabled some DEBUG / TRACE logging by adding the following line to
etc/org.ops4j.pax.logging.cfg:
log4j.logger.org.ops4j.pax.url.mvn.internal.config.MavenConfigurationImpl=TRACE

Whenever the problem is reproduced, the following TRACE statements confirm
that the default repositories are being used to resolve the feature:
/2016-01-12 19:16:57,682 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 233 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories [[]]
2016-01-12 19:16:57,684 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 318 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories
[[http://repo1.maven.org/maven2/,releases=true,snapshots=false]]
2016-01-12 19:16:57,889 | 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 transfer artifact
com.ca.im:data-mgmt.provision:xml:features:2.7.0-RELEASE-137 from/to central
(http://repo1.maven.org/maven2/): Connection pool shut down
shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not
transfer artifact
com.ca.im:data-mgmt.provision:xml:features:2.7.0-RELEASE-137 from/to central
(http://repo1.maven.org/maven2/): Connection pool shut down
at
shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
at
shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
...
...
2016-01-12 19:16:57,947 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 233 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories
[[file:../.maven_repository/,releases=true,snapshots=true,
file:/opt/IMDataCollector/apache-karaf-2.4.3/system/,releases=true,snapshots=true]]
2016-01-12 19:16:57,948 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 318 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories [[]]/

And when this works correctly, we never attempt to resolve any feature with
repo1.maven.org.

*2016-01-12 19:13:15,693 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 233 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories
[[file:../.maven_repository/,releases=true,snapshots=true,
file:/opt/IMDataCollector/apache-karaf-2.4.3/system/,releases=true,snapshots=true]]
2016-01-12 19:13:15,694 | TRACE | Event Dispatcher | MavenConfigurationImpl
| al.config.MavenConfigurationImpl 318 | 3 -
org.ops4j.pax.logging.pax-logging-api - 1.8.3 | | Using repositories [[]]*

I have even tried specifying my local folder in the repositories section,
but even that did not work.
org.ops4j.pax.url.mvn.repositories=file:../***@snapshots@id=defaut-repository

It seems to me like once the maven repositories are updated, the
featuresBoot list should be re-processed to avoid such race conditions.
Is this a known issue in karaf? Is the maven.org repo default coming from
karaf or from pax.url.mvn ? How can I get past this race condition ?





--
View this message in context: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-tp4028299p4044822.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Loading...