4

I am trying to use pax-exam-container-karaf for testing an OSGi bundle. When running the test, the test "hangs" for a few minutes then "dies" with the following exception:

java.lang.RuntimeException: Cannot get the remote bundle context
    at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.getRemoteBundleContext(RemoteBundleContextClientImpl.java:255)
    at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.waitForState(RemoteBundleContextClientImpl.java:211)
    at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.waitForState(KarafTestContainer.java:528)
    at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.startKaraf(KarafTestContainer.java:214)
    at org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer.start(KarafTestContainer.java:164)
    at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.setUp(EagerSingleStagedReactor.java:86)
    at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.beforeClass(EagerSingleStagedReactor.java:136)
    at org.ops4j.pax.exam.spi.reactors.ReactorManager.beforeClass(ReactorManager.java:447)
    at org.ops4j.pax.exam.junit.impl.ProbeRunner.run(ProbeRunner.java:97)
    at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:93)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
    at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
    at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
    at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...
Caused by: java.rmi.NotBoundException: a86ba245-b66b-498e-8752-05679dc9041b
    at sun.rmi.registry.RegistryImpl.lookup(RegistryImpl.java:166)
    at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
    at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:410) 
    at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:268)
    at sun.rmi.transport.Transport$1.run(Transport.java:200)
    at sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$78(TCPTransport.java:683)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$2/1267686416.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:379)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at org.ops4j.pax.exam.rbc.client.intern.RemoteBundleContextClientImpl.getRemoteBundleContext(RemoteBundleContextClientImpl.java:242)
    ... 34 more

I configure Pax-Exam as (with debug == false):

@Configuration
public Option[] config() throws Exception {
    final boolean debug = ConfigurationHelper.getBoolean(
            "org.hibernate.testing.osgi.paxExam.debug",
            Environment.getProperties(),
            DEBUG
    );

    return options(
            when( debug ).useOptions( debugConfiguration( "5005", true ) ),
            karafDistributionConfiguration()
                    .frameworkUrl(
                            maven()
                                    .groupId( "org.apache.karaf" )
                                    .artifactId( "apache-karaf" )
                                    .type( "tar.gz" )
                                    .versionAsInProject()
                    )
                    .unpackDirectory( new File( "target/exam" ) )
                    .useDeployFolder( false ),
            configureConsole()
                    .ignoreLocalConsole()
                    .ignoreRemoteShell(),
            when( debug ).useOptions( keepRuntimeFolder() ),
            logLevel( LogLevelOption.LogLevel.INFO ),
            // avoiding additional boot features; specifically "enterprise"
            editConfigurationFilePut(
                    "etc/org.apache.karaf.features.cfg",
                    "featuresBoot",
                    "standard"
            ),
            features( hibernateKarafFeatureFile(), "hibernate-native", "hibernate-jpa" )
    );
}

I have played with various manifestations of the above configuration, but cannot get anything to work.

The output shows lots of problems resolving artifacts, such as:

Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact org.ops4j.pax.exam:pax-exam-features:xml:4.5.0

(not one I name explicitly ^^), and:

Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.h2database:h2:jar:1.3.170

and:

Caused by: shaded.org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact log4j:log4j:jar:1.2.17

etc.

What is more... I never see these get resolved into the local Maven cache. Does Karaf (as launched by Pax Exam) not locate these maven dependencies remotely? I cannot speak wrt org.ops4j.pax.exam:pax-exam-features:xml:4.5.0, but log4j and h2 jars exist as named in Maven Central.

Any ideas What I might be missing?

Steve Ebersole
  • 9,339
  • 2
  • 48
  • 46

0 Answers0