You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Konrad Windszus (JIRA)" <ji...@apache.org> on 2018/10/31 09:05:00 UTC

[jira] [Commented] (SLING-8061) sling-mocks: Make compatible when Johnzon is managed to version 1.1

    [ https://issues.apache.org/jira/browse/SLING-8061?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16669785#comment-16669785 ] 

Konrad Windszus commented on SLING-8061:
----------------------------------------

This is not that easy to solve, because referencing JSON-P 1.1 is not technically correct (because in fact Johnzon-Core 1.0 only implements JSON-P 1.0). Maybe the better solution is to upgrade Johnzon-Core to 1.1 along as well. As long as only JSON-P 1.0 API is directly used, also managing from version 1.1 to 1.0 would work.
[~sseifert@pro-vision.de] WDYT?

> sling-mocks: Make compatible when Johnzon is managed to version 1.1
> -------------------------------------------------------------------
>
>                 Key: SLING-8061
>                 URL: https://issues.apache.org/jira/browse/SLING-8061
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing Sling Mock 2.3.4
>            Reporter: Konrad Windszus
>            Priority: Major
>             Fix For: Testing Sling Mock 2.3.6
>
>
> Whenever sling-mock is used where {{johnzon-core}} is managed from 1.0.0 to 1.1.0 the following exception is thrown when executing tests which leverage {{SlingContext.load().json(...)}}
> {code}
> [ERROR] testXYZ(my.package)  Time elapsed: 0.018 s  <<< ERROR!
> java.lang.NoClassDefFoundError: Could not initialize class org.apache.johnzon.core.JsonProviderImpl
> 	at sun.reflect.GeneratedConstructorAccessor33.newInstance(Unknown Source)
> 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
> 	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> 	at java.lang.Class.newInstance(Class.java:442)
> 	at javax.json.spi.JsonProvider.doLoadProvider(JsonProvider.java:103)
> 	at javax.json.spi.JsonProvider.provider(JsonProvider.java:64)
> 	at javax.json.Json.createReaderFactory(Json.java:76)
> 	at org.apache.sling.jcr.contentparser.impl.JsonContentParser.<init>(JsonContentParser.java:74)
> 	at org.apache.sling.jcr.contentparser.ContentParserFactory.create(ContentParserFactory.java:54)
> 	at org.apache.sling.testing.mock.sling.loader.ContentLoader.<init>(ContentLoader.java:119)
> 	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:336)
> 	at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:326)
> 	at ...
> {code}
> The reason is that Johnzon 1.1 implements JSON-P 1.1 and therefore references interfaces from the newer spec (e.g. in https://github.com/apache/johnzon/blob/b2d205738c65fb53e768fca445fa611515417c19/johnzon-core/src/main/java/org/apache/johnzon/core/JsonProviderImpl.java#L38), which are not contained in JSON-P 1.0. Unfortunately the version of JSON-P cannot be overwritten by {{DependencyManagement}} as the GAV differs between JSON-P 1.0 ({{org.apache.geronimo.specs:geronimo-json_1.0_spec}}) and JSON-P 1.1 ({{org.apache.geronimo.specs:geronimo-json_1.1_spec}}).
> An easy fix for this is to load the dependencies for both JSON-P 1.1 instead from within sling-mocks, that way it is compatible with both Johnzon-Core 1.0 and 1.1. (JSON-P 1.1 should be backwards-compatible, so works with both Johnzon-Core 1.0 and 1.1).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)