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:
- - SLING-11897Getting issue details... STATUS / https://github.com/apache/sling-org-apache-sling-servlets-get/pull/12
The root cause is tracked in - OAK-7358Getting 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-10053Getting issue details... STATUS .
Examples:
Test failures when trying to instrument classes with JMock
module java.base does not "opens java.lang"
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:
- https://github.com/apache/sling-org-apache-sling-engine/pull/37 / - SLING-11903Getting issue details... STATUS
java.lang.IllegalStateException: No code generation strategy available
Symptom: test execution fails when setting up mocks with java.lang.IllegalStateException: No code generation strategy available at org.jmock.imposters.ByteBuddyClassImposteriser.proxyClass(ByteBuddyClassImposteriser.java:169)
Remediation: update to the latest version of jmock-junit4. If you are using Mockito in the same project it may pull in an older version of byte-buddy so dependency needs to be independently specified in the pom.xml.
Examples:
- https://github.com/apache/sling-org-apache-sling-engine/pull/45 / - SLING-12317Getting issue details... STATUS
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:
- https://github.com/apache/sling-org-apache-sling-scripting-core/pull/23 / - SLING-11904Getting issue details... STATUS
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:
- https://github.com/apache/sling-org-apache-sling-graphql-core/pull/38 / - SLING-12027Getting issue details... STATUS
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:
- https://github.com/apache/sling-org-apache-sling-graphql-core/pull/38 / - SLING-12027Getting issue details... STATUS
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-6157Getting 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:
Failures in the maven-invoker-plugin
Sympton: maven-invoker-plugin invocations fail when running groovy scripts: BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' Unsupported class file major version 65
.
Remediation: Update to the latest version of the maven-invoker-plugin, at least 3.6.1 at the time of this writing. That version brings in support for Java 21.
Examples:
- - SLING-12305Getting issue details... STATUS
- https://github.com/apache/sling-slingfeature-maven-plugin/pull/84