When moving the Sling CI jobs to a new Java version ( 8 → 11, 11 → 17 ) there are certain failures that reoccur. This page documents them so that they are easier to remediate on follow-ups.

Old version of Oak (< 1.26) pulled in via Sling-Mock-Oak

Symptom: tests fail with errors such as java.lang.RuntimeException: Unable to initialize JCR_OAK resource resolver factory: java/security/acl/Group 

Remediation: update to the latest version of org.apache.sling.testing.sling-mock-oak .

Examples:

The root cause is tracked in OAK-7358 - Getting issue details... STATUS .

Failure executing the ianal-maven-plugin

Symptom: the ianal-maven-plugin execution fails with Unable to make private java.io.File(java.lang.String,java.io.File) accessible: module java.base does not "opens java.io" to unnamed module @6a938034

Remediation: update to the latest version of the parent pom ( at least 46 ). The fix was delivered with SLING-10053 - Getting issue details... STATUS .

Examples:

Test failures when trying to instrument classes with JMock

Symptom: test execution fails when setting up mocks with java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2613a93a

Note that you may need to scroll to the first error to get the right message.

Remediation: update to the latest version of jmock-junit4  and switch from the ClassImposteriser  to the ByteBuddyClassImposteriser .

Examples:

Test failures when trying to instrument classes with Mockito

Symptom: test execution fails when setting up mocks with java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2613a93a .

Note that you may need to scroll to the first error to get the right message.

Remediation: update to the latest version of mockito-core.

Examples:

Pax-Exam test failures

When I upgrade to the latest Mockito-inline (5.2.0) from 3.5.11 then the instrumentation does work but the Pax IT test all time out because it is unable to lookup Sling services:

[INFO] Running org.apache.sling.graphql.core.it.GraphQLScriptEngineIT
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 21.341 s <<< FAILURE! - in org.apache.sling.graphql.core.it.GraphQLScriptEngineIT
[ERROR] org.apache.sling.graphql.core.it.GraphQLScriptEngineIT.testEnginePresent  Time elapsed: 10.114 s  <<< ERROR!
org.ops4j.pax.swissbox.tracker.ServiceLookupException: gave up waiting for service javax.script.ScriptEngineFactory
at org.ops4j.pax.swissbox.tracker.ServiceLookup.getService(ServiceLookup.java:199)

Outdated Felix Framework bundle

When inspecting the output of Pax-Exam tests the following error can be found java.lang.reflect.InaccessibleObjectException: Unable to make field private static final java.lang.Object java.net.URL.streamHandlerLock accessible: module java.base does not "opens java.net" to unnamed module @6205ec9d

Remediation: update to the latest version of org.apache.felix.framework.

Examples:

Outdated Jackrabbit Oak version

When inspecting the output of the Pax-Exam tests the following error can be found: ERROR: Bundle org.apache.sling.resourceresolver [52] EventDispatcher: Error during dispatch. (java.lang.NoClassDefFoundError: java/security/acl/Group)

Remediation: update to the latest version of org.apache.sling.testing.paxexam .

Examples:

Failure with OSGi Converter

Symptom: Test execution leveraging the OSGi converter implementation fails with error messages like org.osgi.util.converter.ConversionException: Cannot convert 1234 to class java.lang.Integer

Remediation: Update to newer version of OSGi converter ( FELIX-6157 - Getting issue details... STATUS ). The converter impl from Felix was migrated to OSGi and should be referenced with coordinates

<dependency>
    <groupId>org.osgi</groupId>
    <artifactId>org.osgi.util.converter</artifactId>
    <version>1.0.9</version>
</dependency>

The newest version is exporting still the original package version therefore referencing the newest 1.0.x version does not affect backwards-compatibility at run time.

Examples:

  • No labels