Closed RVanhuysseXenit closed 3 years ago
Alternative solution: use Jackson instead of org.json ?
Apart from this being fixed, I'd advise to make use of the @ResponseBody
and @RequestBody
functionality instead of the JsonWriterResolution
.
Is this component inside or outside the OSGi container?
If it is inside, can't we ship a correct version of org.json
, which will automatically be wired up by OSGi if the headers on your jar are correct?
Based on the source code, I assume that the type of the constructor argument for JSONWriter
has been changed from Writer
to Appendable
:
https://github.com/stleary/JSON-java/blob/20201115/src/main/java/org/json/JSONWriter.java#L98
Futhermore, Writer implements Appendable
.
Hence in theory this should still work?
As we have seen previously in alfred-telemetry (https://github.com/xenit-eu/alfred-telemetry/issues/20), constructors are not handled the same as other methods.
The exact constructor signature to call is set at compile-time. It expects a method with those exact types to exist and it will not perform any fallback to a constructor with a compatible signature.
What still works in practice is compiling against the different version of org.json.JSONWriter
without doing any source-level changes. However, the generated bytecode is not compatible and not interchangable between those two versions.
Right, that rings a bell (https://github.com/xenit-eu/alfred-telemetry/issues/20#issuecomment-791538978).
Thanks @vierbergenlars !
So another possible solution would be to change just https://github.com/xenit-eu/dynamic-extensions-for-alfresco/blob/06ca1b79a78347e71a19bdf5b22a82f10fe332c2/webscripts/build.gradle#L6 to use a version specific enforcedPlatform
.
I'm submitting a ... (check one with "x")
Expected Behavior
The
JsonWriterResolution
& extending classes resolve successfully and create json responses.Current Behavior
JsonWriterResolution
fails to instantiate its internalorg.json.JSONWriter
with ajava.lang.NoSuchMethodError
on the JSONWriter constructor:The used constructor is no longer available in the currently available version of the library.
Possible Solution
JsonWriterResolution
org.json:json
(previously 20090211, currently 20201115)Steps to Reproduce (for bugs)
See also first commit on branch DEVEM-486
Context
Issue was discovered when porting Care4alf to alfresco 7.
Your Environment