Hi,
You need to add some VMOption by yourself, something like
new VMOption("--add-reads=java.xml=java.logging"),
new
VMOption("--add-exports=java.base/org.apache.karaf.specs.locator=java.xml,ALL-UNNAMED"),
new VMOption("--patch-module"),
new
VMOption("java.base=lib/endorsed/org.apache.karaf.specs.locator-"
+ System.getProperty("karaf.version") + ".jar"),
new VMOption("--patch-module"), new
VMOption("java.xml=lib/endorsed/org.apache.karaf.specs.java.xml-"
+ System.getProperty("karaf.version") + ".jar"),
new VMOption("--add-opens"),
new VMOption("java.base/java.security=ALL-UNNAMED"),
new VMOption("--add-opens"),
new VMOption("java.base/java.net=ALL-UNNAMED"),
new VMOption("--add-opens"),
new VMOption("java.base/java.lang=ALL-UNNAMED"),
new VMOption("--add-opens"),
new VMOption("java.base/java.util=ALL-UNNAMED"),
new VMOption("--add-opens"),
new VMOption("java.naming/javax.naming.spi=ALL-UNNAMED"),
new VMOption("--add-opens"),
new VMOption("java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"),
new
VMOption("--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED"),
new
VMOption("--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED"),
new
VMOption("--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED"),
new
VMOption("--add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED"),
new VMOption("-classpath"),
new VMOption("lib/jdk9plus/*" + File.pathSeparator +
"lib/boot/*”)
You can take a look at [1] to get more details about how we do it in Karaf.
[1]https://github.com/apache/karaf/blob/master/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
-------------
Freeman(Yue) Fang
Red Hat, Inc.
> On Jun 1, 2019, at 4:55 PM, Steinar Bang <[email protected]> wrote:
>
> This pax exam test, using the karaf runner, with karaf 4.2.5, runs with
> openjdk-8 but fails with openjdk-11:
> https://github.com/steinarb/scratch/blob/authservice/use-java-11/authservice.tests/src/test/java/no/priv/bang/authservice/tests/AuthserviceIntegrationTest.java#L25
>
> Will pax exam work with openjdk-11? Should switching JDK have worked
> out of the box? Or will the test code or dependencies need to be
> modified?
>
> Here's the error message from the failing build:
> [INFO] --- maven-surefire-plugin:2.20:test (default-test) @ authservice.tests
> ---
> [INFO]
> [INFO] -------------------------------------------------------
> [INFO] T E S T S
> [INFO] -------------------------------------------------------
> [INFO] Running no.priv.bang.authservice.tests.AuthserviceIntegrationTest
> [org.ops4j.pax.exam.spi.DefaultExamSystem] : Pax Exam System (Version:
> 4.13.1) created.
> [org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
> [org.ops4j.pax.exam.junit.impl.ProbeRunner] : creating PaxExam runner for
> class no.priv.bang.authservice.tests.AuthserviceIntegrationTest
> [org.ops4j.pax.exam.spi.PaxExamRuntime] : Found TestContainerFactory:
> org.ops4j.pax.exam.karaf.container.internal.KarafTestContainerFactory
> [org.ops4j.pax.exam.spi.DefaultExamSystem] : creating default probe
> [org.ops4j.pax.exam.spi.reactors.ReactorManager] : No User defined probe hook
> found
> [org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS=
> PaxExam-014331d4-de30-4465-8f96-892a167e3d09 parent=null
> root=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09
> root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09]
> args=[Ljava.lang.Object;@276438c9
> [org.ops4j.pax.exam.spi.DefaultExamReactor] : Staging reactor with probes: 1
> using strategy: org.ops4j.pax.exam.spi.reactors.PerClass@7181ae3f
> [org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
> [org.ops4j.pax.exam.spi.intern.DefaultTestAddress] : NEW ADDRESS=
> PaxExam-e162e3b7-1659-436b-9231-95d124345ca1
> parent=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09
> root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09]
> root=[TestAddress:PaxExam-014331d4-de30-4465-8f96-892a167e3d09
> root:PaxExam-014331d4-de30-4465-8f96-892a167e3d09]
> args=[Ljava.lang.Object;@2d127a61
> [org.ops4j.pax.exam.junit.impl.ProbeRunner] : running test class
> no.priv.bang.authservice.tests.AuthserviceIntegrationTest
> [org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Creating
> RMI registry server on 127.0.0.1:21000
> [org.ops4j.store.intern.TemporaryStore] : Storage Area is /tmp/1559417194161-0
> [org.ops4j.pax.url.mvn.internal.Connection] : Resolving
> [mvn:org.apache.karaf/apache-karaf-minimal/4.2.5/zip]
> [shaded.org.eclipse.aether.internal.impl.DefaultLocalRepositoryProvider] :
> Using manager SimpleLocalRepositoryManager with priority 0.0 for
> /home/sb/.m2/repository Ignored FQCN:
> shaded.org.eclipse.aether.internal.impl.slf4j.Slf4jLoggerFactory$Slf4jLoggerEx
> [org.ops4j.pax.url.mvn.internal.AetherBasedResolver] : Resolved
> (org.apache.karaf:apache-karaf-minimal:zip:4.2.5) as
> /home/sb/.m2/repository/org/apache/karaf/apache-karaf-minimal/4.2.5/apache-karaf-minimal-4.2.5.zip
> [org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Found 0
> options when requesting OverrideJUnitBundlesOption.class
> [shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] :
> Connection manager is shutting down Ignored FQCN:
> shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
> [shaded.org.apache.http.impl.conn.PoolingHttpClientConnectionManager] :
> Connection manager shut down Ignored FQCN:
> shaded.org.apache.commons.logging.impl.SLF4JLocationAwareLog
> [org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Test
> Container started in 2 millis
> [org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Wait for
> test container to finish its initialization [ RelativeTimeout value = 720000 ]
> [org.ops4j.pax.exam.rbc.client.RemoteBundleContextClient] : Waiting for
> remote bundle context.. on 21000 name: 274d833b-3fe3-4120-846b-e093d33a7543
> timout: [ RelativeTimeout value = 720000 ]
> Exception in thread "KarafEmbeddedRunner" java.lang.RuntimeException:
> java.lang.reflect.InvocationTargetException
> at
> org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:96)
> Caused by: java.lang.reflect.InvocationTargetException
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at
> org.ops4j.pax.exam.karaf.container.internal.runner.KarafEmbeddedRunner$1.run(KarafEmbeddedRunner.java:86)
> Caused by: java.lang.NullPointerException
> at
> org.eclipse.osgi.storage.FrameworkExtensionInstaller.addExtensionContent0(FrameworkExtensionInstaller.java:99)
> at
> org.eclipse.osgi.storage.FrameworkExtensionInstaller.addExtensionContent(FrameworkExtensionInstaller.java:79)
> at org.eclipse.osgi.storage.Storage.installExtensions(Storage.java:194)
> at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:92)
> at
> org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:66)
> at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)
> at
> org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)
> at org.apache.karaf.main.Main.launch(Main.java:256)
> ... 5 more
> [org.ops4j.pax.exam.karaf.container.internal.KarafTestContainer] : Shutting
> down the test container (Pax Runner)
> [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed:
> 720.63 s <<< FAILURE! - in
> no.priv.bang.authservice.tests.AuthserviceIntegrationTest
> [ERROR] no.priv.bang.authservice.tests.AuthserviceIntegrationTest Time
> elapsed: 720.629 s <<< ERROR!
> java.lang.RuntimeException: Cannot get the remote bundle context
> Caused by: java.rmi.NotBoundException: 274d833b-3fe3-4120-846b-e093d33a7543
>
> [ERROR] no.priv.bang.authservice.tests.AuthserviceIntegrationTest Time
> elapsed: 720.63 s <<< ERROR!
> java.lang.RuntimeException: Container never came up
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:365)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:272)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:236)
> at
> org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:159)
>
> [INFO]
> [INFO] Results:
> [INFO]
> [ERROR] Errors:
> [ERROR]
> AuthserviceIntegrationTest.no.priv.bang.authservice.tests.AuthserviceIntegrationTest
> » Runtime
> [ERROR]
> JUnit4Provider.invoke:159->executeTestSet:236->executeWithRerun:272->execute:365
> » Runtime
> [INFO]
> [ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
>
> --
> --
> ------------------
> OPS4J - http://www.ops4j.org - [email protected]
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OPS4J" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ops4j/86woi5jaa9.fsf%40dod.no.
> For more options, visit https://groups.google.com/d/optout.
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ops4j/6382C75D-4C00-47B2-846C-6E71681A9E8A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.