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

Incorrect export of com.fasterxml.jackson.jaxrs.json for JSON provider #120

Closed
triceo opened this issue Nov 13, 2019 · 35 comments
Closed

Incorrect export of com.fasterxml.jackson.jaxrs.json for JSON provider #120

triceo opened this issue Nov 13, 2019 · 35 comments
Milestone

Comments

@triceo
Copy link

triceo commented Nov 13, 2019

When running an app with 2.10.1 using JPMS, I get the following error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: 
/home/triceo/.m2/repository/com/fasterxml/jackson/jaxrs/jackson-jaxrs-json-provider/2.10.1/jackson-jaxrs-json-provider-2.10.1.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Exported package com.fasterxml.jackson.jaxrs.json already declared

I am assuming this has to do with the following module-info.class that my IntelliJ IDEA decompiled for me:

decompiled

(See lines 15 and 16.)

Unfortunately, this makes Jackson 2.10.1 unusable in the context of Java modularity.

@triceo triceo changed the title 2.10.1 "Exported package com.fasterxml.jackson.jaxrs.json already declared" 2.10.1 kills JVM with "Exported package com.fasterxml.jackson.jaxrs.json already declared" Nov 13, 2019
@triceo
Copy link
Author

triceo commented Nov 13, 2019

FYI @cowtowncoder
(#114 was fixed in 2.10.1, so I was able to proceed and find this one.)

@cowtowncoder
Copy link
Member

Would this be fixed by this:

#119

?

@cowtowncoder
Copy link
Member

cowtowncoder commented Nov 14, 2019

And yes, I was right from beginning. I FUCKING HATE Oracle's piece of shit module system.

Was probably bad move to try to support it.

@triceo
Copy link
Author

triceo commented Nov 15, 2019

Is there a nightly build somewhere that I could try?

@cowtowncoder
Copy link
Member

Sonatype OSS repo has some of the snapshots, but looks like Travis settings for this project have not been updated to build them (unlike core projects). I can do manual deploy from home tonight

@triceo
Copy link
Author

triceo commented Nov 15, 2019

@cowtowncoder That would be appreciated - I will test it then.

@paperlib
Copy link

Same error pops up when trying to list dependencies via jdeps:

$ jdeps --list-deps ./jackson-jaxrs-json-provider-2.10.1.jar
Exception in thread "main" java.lang.module.FindException:
  Error reading module: ./jackson-jaxrs-json-provider-2.10.1.jar
Caused by: java.lang.module.InvalidModuleDescriptorException:
  Exported package com.fasterxml.jackson.jaxrs.json already declared

full error dump:

$ jdeps --list-deps ./jackson-jaxrs-json-provider-2.10.1.jar
 Exception in thread "main" java.lang.module.FindException: Error reading module: ./jackson-jaxrs-json-provider-2.10.1.jar
	at java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:349)
	at java.base/jdk.internal.module.ModulePath.scan(ModulePath.java:236)
	at java.base/jdk.internal.module.ModulePath.scanNextEntry(ModulePath.java:189)
	at java.base/jdk.internal.module.ModulePath.findAll(ModulePath.java:165)
	at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:536)
	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:589)
	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:543)
	at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:519)
	at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)
Caused by: java.lang.module.InvalidModuleDescriptorException: Exported package com.fasterxml.jackson.jaxrs.json already declared
	at java.base/jdk.internal.module.ModuleInfo.invalidModuleDescriptor(ModuleInfo.java:1092)
	at java.base/jdk.internal.module.ModuleInfo.read(ModuleInfo.java:134)
	at java.base/jdk.internal.module.ModulePath.readJar(ModulePath.java:651)
	at java.base/jdk.internal.module.ModulePath.readModule(ModulePath.java:330)
	... 8 more

@jflefebvre06
Copy link

Same problem

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.119 s
[INFO] Finished at: 2019-11-20T12:07:51+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project ant-tasks: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Exported package com.fasterxml.jackson.jaxrs.json already declared -> [Help 1]

@robinvanpraet
Copy link

It is causing issues on my side as well. I don't even know how you managed to compile this?!?
Please fix asap

@tomdw
Copy link

tomdw commented Jan 3, 2020

Same problem here, it is not the module system which is to blame. Just an invalid module-info with a duplicate export package. Please fix asap indeed, blocking.

@kupci
Copy link
Member

kupci commented Jan 3, 2020

@robinvanpraet @tomdw Knowing that nothing annoys cowtowncoder more than people ordering him what to do with his free time, I'm curious if you've considered subscribing for Enterprise Support, which looks like just the sort of thing to address these sorts of issues?

Enterprise support

_Available as part of the Tidelift Subscription.

The maintainers of jackson-jaxrs-providers and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more._

https://tidelift.com/subscription/pkg/maven-com-fasterxml-jackson-jaxrs-jackson-jaxrs-json-provider?utm_source=maven-com-fasterxml-jackson-jaxrs-jackson-jaxrs-json-provider&utm_medium=referral&utm_campaign=enterprise&utm_term=repo

@rolaca11
Copy link

rolaca11 commented Jan 3, 2020

This issue is fixed with the 2.11.0-SNAPSHOT version and 3.0.0-SNAPSHOT version.

It's not ideal to use snapshots, but it seems to work nicely on my end

@cowtowncoder
Copy link
Member

Yes, comments about "Fix this IMMEDIATELY" are annoying and frustrating. I literally do not work for any of you, nor do I take orders from you. I do however work with community members who will try to help; thank you everyone who has contributed in positive way.

As to fix this should be resolved in 2.10.2 as far as I know, and release should be forthcoming within a week or so. If anyone wants to help, verification with a build from 2.10 branch would be good idea, but if and when 2.11 works (as per @rolaca11 ) 2.10.2 should be good too.

@cowtowncoder
Copy link
Member

2.10.2 now released.

@cowtowncoder cowtowncoder added this to the 2.10.2 milestone Jan 5, 2020
@doctorpangloss
Copy link

doctorpangloss commented Jan 5, 2020

I am now seeing the following error:

error: package com.fasterxml.jackson.jaxrs.json is not visible
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
                                  ^
  (package com.fasterxml.jackson.jaxrs.json is declared in module com.fasterxml.jackson.jaxrs.json, which does not export it)

This is resolved with the following compiler option:

--add-exports=com.fasterxml.jackson.jaxrs.json/com.fasterxml.jackson.jaxrs.json=my.module.name
module com.fasterxml.jackson.jaxrs.json {
  requires com.fasterxml.jackson.annotation;
  requires com.fasterxml.jackson.core;
  requires com.fasterxml.jackson.databind;
  requires com.fasterxml.jackson.module.jaxb;
  requires com.fasterxml.jackson.jaxrs.base;
  requires static javax.ws.rs.api;
  requires static java.ws.rs;
  requires static jakarta.ws.rs.api;

  exports com.fasterxml.jackson.jaxrs.json.annotation;

  opens com.fasterxml.jackson.jaxrs.json;

  provides javax.ws.rs.ext.MessageBodyReader with com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
  provides javax.ws.rs.ext.MessageBodyWriter with com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
}

I see that I am supposed to load the instance differently, but some libraries, like Swagger use the JacksonJsonProvider directly.

@rolaca11
Copy link

rolaca11 commented Jan 5, 2020

I had no problems with the new version, built my project without a problem and the Jax-RS application can send and receive JSON information with the Jackson Jax-RS provider. I also use Jackson annotations.

@doctorpangloss I'd suggest you post a question on StackOverflow, maybe even link it here. As far as I'm concerned, the issue is fixed.

@triceo
Copy link
Author

triceo commented Jan 6, 2020

I can confirm that my problem is fixed, and since I'm the original reporter, I'll close this one. If there is another problem uncovered by the fix, please file a new issue for it.

Thanks for the fix!

@triceo triceo closed this as completed Jan 6, 2020
@cowtowncoder
Copy link
Member

@triceo Thank you for confirming this. If there are new issues we'll try to tackle them; everyone's help in verification is appreciated given that I only run and build things on JDK 8 on regular basis.
I do have later jdks installed and occasionally do spot checks; pls Travis build is enabled for jdk 11, but in case of module system it does not give very deep coverage without integration tests by something else that uses module jars.

@robinvanpraet
Copy link

@cowtowncoder I confirm that we have the same issue as @doctorpangloss being that the com.fasterxml.jackson.jaxrs.json package is now not exported at all.
Not only is Swagger using the JacksonJsonProvider directly, Siren4J for example is extending it as well. As you can see here https://github.com/eserating/siren4j/blob/master/src/main/java/com/google/code/siren4j/jackson/MessageBodyWriterJSON.java

The workaround does work (but that's just a workaround), so the new release does help us out. Thanks!

@doctorpangloss did you create another issue for this?

@cowtowncoder
Copy link
Member

@GedMarc just to make sure does this make sense? I can see that double export was now fully removed (perhaps due to merging fail) but wanted to make sure adding it makes sense since you are most familiar with testing for Module metadata.

@GedMarc
Copy link
Contributor

GedMarc commented Jan 7, 2020

@cowtowncoder Correct -
The base and jax-rs modules both had them.

With 2.10.2 out, I do need to update the JDK 11 Compat test libraries again to point to these instead of the standalone singles I used.

JAX-RS is included in the JDK 11 Compat 11 Test Suite, I do still however need to do the travis build for the JLink confirmation then that nut can be put to rest for all those modules.

@cowtowncoder
Copy link
Member

@GedMarc @robinvanpraet Ok looking at src/moditect/module-info.java again, I think the thing that confuses me is this: there is actually opens declaration:

module com.fasterxml.jackson.jaxrs.json {
    exports com.fasterxml.jackson.jaxrs.json.annotation;

    // 13-Nov-2019: [jaxrs-providers#119]: CXF, RESTEasy, OpenAPI require reflective access
    opens com.fasterxml.jackson.jaxrs.json;

    requires com.fasterxml.jackson.annotation;
    requires com.fasterxml.jackson.core;
    requires com.fasterxml.jackson.databind;
    requires com.fasterxml.jackson.module.jaxb;
....

which, being a more extensive access, would seem like implying "exports" as well.
But I guess not? So I just want to have a confirmation given that none of tools I use (maven build, IDE) complain about declarations even via dependencies, probably since they tend to run with more open (default?) access.

@GedMarc
Copy link
Contributor

GedMarc commented Jan 9, 2020

@cowtowncoder

The opens clause is cause the consumers perform reflection on that package :)

Wellll!!! - The JDK 11 test is passing because in JDK 11, opens clause does indeed also mean exports.
JDK 12 and up, this is not the case, it needs to be exported as well

You don't wanna know what I went through to figure this one out.

@cowtowncoder
Copy link
Member

Oh well. No wonder googling for the answer did not really bring up definite answers.... :)

But at least this helps further explain why it is possible for some users to have issues, others not, even with same or similar usage. I will add the export too, then.

@cowtowncoder cowtowncoder changed the title 2.10.1 kills JVM with "Exported package com.fasterxml.jackson.jaxrs.json already declared" Incorrect export of com.fasterxml.jackson.jaxrs.json for JSON provider Jan 9, 2020
@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 9, 2020

Note: changed title a bit as I will use this issue number for fix inclusion in 2.10.3.
Thank you everyone for your help here.

... and should you find any other problems in other provides (quite possible, json one has gotten most attention), please report them, ideally as new issues.

@cowtowncoder cowtowncoder removed this from the 2.10.2 milestone Jan 9, 2020
@cowtowncoder cowtowncoder added this to the 2.10.3 milestone Jan 9, 2020
cowtowncoder added a commit that referenced this issue Jan 9, 2020
@robinvanpraet
Copy link

@cowtowncoder thanks for the fix. Do you have an idea when you could release version 2.10.3? It would help me out a lot.

@cowtowncoder
Copy link
Member

Unfortunately I just released 2.10.2 so it will be few months off.

One possibility would be micro-patch just for JAX-RS tho (2.10.2.1), wherein I only need to publish this repo?

@GedMarc
Copy link
Contributor

GedMarc commented Jan 11, 2020

@cowtowncoder
Copy link
Member

@GedMarc as far as I can see, these 2 are identical to what 2.11 branch has, so that should be good.

@tomdw
Copy link

tomdw commented Jan 11, 2020

@cowtowncoder A 2.10.2.1 release with this fix would also be great. And if it is a possibility, please prefer to release jackson as a whole to avoid needing to manage multiple version numbers for jackson libs.

@cowtowncoder
Copy link
Member

Full release takes half a day so I do not have time to spend on that at this point.
But micro patch is doable. That's what those are for, and I can match that with jackson-bom that does provide full version set (even if there is but one difference).

@robinvanpraet
Copy link

@cowtowncoder any idea when this micro patch would be available? Thanks

@cowtowncoder
Copy link
Member

I can release it tonight.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 29, 2020

JAX-RS 2.10.2.1 released, on its way to Maven Central; matching jackson-bom has version -2.10.2.20200129-.

@cowtowncoder
Copy link
Member

Update: looks like bom mentioned above is no good (accidentally defines dep versions as 2.10.3-SNAPSHOT): will push one with version 2.10.2.20200130.

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

No branches or pull requests

10 participants