如何在karaf paxexam配置中提供存储库URL

时间:2016-02-05 18:59:30

标签: osgi apache-karaf karaf pax-exam pax-runner

以下代码尝试从此位置安装功能中定义的工件 http://repository.apache.org/content/groups/snapshots-group/ 有没有办法给另一个存储库位置下载和安装。

   @Configuration
        public static Option[] configuration() throws Exception {

            return new Option[] {
                KarafDistributionOption.debugConfiguration("8889", true),
                karafDistributionConfiguration().frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
                            .type("zip").version("4.0.3"))
                    .unpackDirectory(new File("target/paxexam/unpack/"))
                    .useDeployFolder(false),
                    configureConsole().ignoreLocalConsole(),
                    logLevel(LogLevel.INFO),
                    keepRuntimeFolder(),provision(
                            mavenBundle()
                            .groupId("test")
                            .artifactId("DBHandler").version("0.0.1-SNAPSHOT").classifier("features").start())

            };
            }

当执行上述代码时,我收到以下错误

shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact test:DBHandler:jar:features:0.0.1-SNAPSHOT in apache (http://repository.apache.org/content/groups/snapshots-group/)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:573)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:528)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:506)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:481)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.apache.karaf.features.internal.download.impl.MavenDownloadTask.download(MavenDownloadTask.java:34)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[9:org.apache.karaf.features.core:4.0.3]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact test:DBHandler:jar:features:0.0.1-SNAPSHOT in apache (http://repository.apache.org/content/groups/snapshots-group/)
    at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)[4:org.ops4j.pax.url.mvn:2.4.3]
    ... 16 more
2016-02-06 00:23:52,754 | WARN  | pool-10-thread-3 | AetherBasedResolver              | 5 - org.ops4j.pax.logging.pax-logging-api - 1.8.4 | Error resolving artifacttest:DBHandler:jar:features:0.0.1-SNAPSHOT:Could not find artifact test:DBHandler:jar:features:0.0.1-SNAPSHOT in apache (http://repository.apache.org/content/groups/snapshots-group/)
shaded.org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact test:DBHandler:jar:features:0.0.1-SNAPSHOT in apache (http://repository.apache.org/content/groups/snapshots-group/)
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:223)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:294)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:573)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:528)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:506)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.ops4j.pax.url.mvn.internal.AetherBasedResolver.resolve(AetherBasedResolver.java:481)[4:org.ops4j.pax.url.mvn:2.4.3]
    at org.apache.karaf.features.internal.download.impl.MavenDownloadTask.download(MavenDownloadTask.java:34)[9:org.apache.karaf.features.core:4.0.3]
    at org.apache.karaf.features.internal.download.impl.AbstractRetryableDownloadTask.run(AbstractRetryableDownloadTask.java:58)[9:org.apache.karaf.features.core:4.0.3]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_79]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_79]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_79]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_79]
    at java.lang.Thread.run(Thread.java:745)[:1.7.0_79]
Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact test:DBHandler:jar:features:0.0.1-SNAPSHOT in apache (http://repository.apache.org/content/groups/snapshots-group/)
    at shaded.org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector$DirectExecutor.execute(BasicRepositoryConnector.java:581)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.connector.basic.BasicRepositoryConnector.get(BasicRepositoryConnector.java:249)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.performDownloads(DefaultArtifactResolver.java:520)[4:org.ops4j.pax.url.mvn:2.4.3]
    at shaded.org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:421)[4:org.ops4j.pax.url.mvn:2.4.3]
    ... 16 more

1 个答案:

答案 0 :(得分:2)

您可以动态修补文件etc/org.ops4j.pax.url.mvn.cfg以添加您的存储库:

editConfigurationFilePut("etc/org.ops4j.pax.url.mvn.cfg",
  "org.ops4j.pax.url.mvn.repositories",
  "http://repo1.maven.org/maven2@id=central, ...")

也有一个存储库选项,但我从未使用它