Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to invoke method 'activate' for class org.apache.sling.xss.impl.XSSAPIImpl #60

Closed
royteeuwen opened this issue Jun 5, 2024 · 1 comment · Fixed by #66
Closed

Comments

@royteeuwen
Copy link

When upgrading to the latest dependencies, I get following exception. Did this occur for you and did you do anything to fix it? I upgraded all other maven dependencies to the latest versions, but it doesn't seem to fix the problem:

java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.xss.impl.XSSAPIImpl

	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:366)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.lambda$invokeLifecycleMethod$0(OsgiServiceUtil.java:264)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.findAndInvokeNearestMethod(OsgiServiceUtil.java:150)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeLifecycleMethod(OsgiServiceUtil.java:182)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateDeactivate(OsgiServiceUtil.java:98)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.activateInjectServices(OsgiServiceUtil.java:489)
	at org.apache.sling.testing.mock.osgi.MockOsgi.registerInjectActivateService(MockOsgi.java:268)
	at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:191)
	at org.apache.sling.testing.mock.osgi.context.OsgiContextImpl.registerInjectActivateService(OsgiContextImpl.java:179)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.registerDefaultServices(SlingContextImpl.java:250)
	at io.wcm.testing.mock.aem.context.AemContextImpl.registerDefaultServices(AemContextImpl.java:74)
	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.setUp(SlingContextImpl.java:195)
	at io.wcm.testing.mock.aem.context.AemContextImpl.setUp(AemContextImpl.java:108)
	at io.wcm.testing.mock.aem.junit5.AemContext.setUpContext(AemContext.java:100)
	at io.wcm.testing.mock.aem.junit5.AemContextExtension.setAemContextInStore(AemContextExtension.java:73)
	at io.wcm.testing.mock.aem.junit5.AemContextExtension.postProcessTestInstance(AemContextExtension.java:63)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
	at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
	at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
	at java.base/java.util.Optional.orElseGet(Optional.java:369)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    jakarta/json/spi/JsonProvider$Holder.<clinit>()V @7: putstatic
  Reason:
    Type 'org/apache/johnzon/core/JsonProviderImpl' (current frame, stack[0]) is not assignable to 'jakarta/json/spi/JsonProvider'
  Current Frame:
    bci: @7
    flags: { }
    locals: { }
    stack: { 'org/apache/johnzon/core/JsonProviderImpl' }
  Bytecode:
    0000000: bb00 0359 b700 04b3 0001 b1            

	at jakarta.json.spi.JsonProvider.provider(JsonProvider.java:64)
	at jakarta.json.Json.createReaderFactory(Json.java:218)
	at org.apache.sling.xss.impl.XSSAPIImpl.activate(XSSAPIImpl.java:82)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.sling.testing.mock.osgi.OsgiServiceUtil.invokeMethod(OsgiServiceUtil.java:357)
	... 27 more
@stefanseifert
Copy link
Member

stefanseifert commented Jun 6, 2024

this looks like a mismatch of johnzon version and the ongoing switch from javax.json to jakarta.json. also this switch is done for most/lot of sling modules, that's not the case for some of the adobe modules, esp. the adobe core components. within OSGi this is not a problem as each bundle consumes the correct version, but inside the testing classpath this can get to a conflict.

in #52 i tried to switch everything to jakarta.json for the testing classpath, but it did not work with adobe core components, so i reverted that in #53.

please make sure that all versions of these dependencies in your test classpath use the versions as defined in the aem-cloud-dependencies POM you are using, and not overwritten with a different version:

  • org.apache.johnzon:johnzon-core
  • org.apache.geronimo.specs:geronimo-json_1.1_spec

it does work when code relies on jakarta.json because since some releases sling-mock comes with dependencies akarta.json:jakarta.json-api and org.glassfish:jakarta.json to support those modules that rely on jakarta.json. but it does not work for modules actually relying on the johnzon API, because the johnzon API stays the same between 1.x and 2.x version, but switches the json implementation internally.`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants