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

org.glassfish.jersey.containers:jersey-container-jetty-http:3.0.0 Unusable on JDK11+ #4655

Closed
birdflyer-lszo opened this issue Dec 12, 2020 · 24 comments · Fixed by #4709 or #4726
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@birdflyer-lszo
Copy link

birdflyer-lszo commented Dec 12, 2020

I am using the org.glassfish.jersey.containers:jersey-container-jetty-http:3.0.0 dependency to setup my Jetty container. While on version 2.x this worked just fine, version 3.0.0 does no longer seem to provide a JettyHttpContainerFactory class.

In the source repository there are multiple source directories for different JDKs, but the build does not seem to build one for JDK 11 onward. The JAR file published on https://repo1.maven.org/maven2/org/glassfish/jersey/containers/jersey-container-jetty-http/3.0.0/ appears to be the one for JDK8. According to the POM, JDK11+ modules are only built when a specific profile is active.

The repository does not seem to include a JDK11+ build of the jersey-container-jetty-http artifact. Is there a different repository that contains the JDK11 artifacts?

@jansupol
Copy link
Contributor

The goal was to create a multirelease artifact that works for JDK 8 (well Jetty needs JDK 11, so that version just informs that JDK 11 is required) as well as for JDK 11. It looks like JDK 11 classes were not included during the build :(

@jansupol jansupol added the bug Something isn't working label Dec 15, 2020
@senivam
Copy link
Contributor

senivam commented Dec 22, 2020

@birdflyer-lszo the release process of jakartified Jersey includes compilation of modules by different JDKs. Since several modules do not support JDKs prior to 11 we shall provide some stubs for JDK 1.8 which will inform user of in-availability of a particular module for used JDK. And that particular module shall support multi-release jar in order to provide expected functionality for supported JDKs.

Jetty related modules where adjusted in that way, that is why you can see several profiles inside the pom.xml each of them is activated by different JDK.

The order of release is: compile module using higher JDK to generate required functionality for supported JDK, then compile the same module using lower JDK to provide not-supported stub and pick up previously generated functionality from higher JDK. And then bundle all of this into the final JAR and release to central.

I can admit that there was an error inside releasing job which did not properly generate functionality for 11+ JDKs and so only stubs where included into 3.0.0 release. Thus I can say that Jetty is not supported in that release due to that pity error. Profiles in POM files are however correct and there is no need to adjust them.

The issue is already fixed and future releases of Jersey 3.x will be published properly.

I will inform you (in this issue) when next release is available for public usage.

And thank you for finding this out and reporting that. I apologise for that mistake which in fact had caused total unavailability of Jetty for the release of Jersey 3.0.0.

@birdflyer-lszo
Copy link
Author

Thanks for the update. And no worries, mistakes can happen :)

@doriancransac
Copy link

doriancransac commented Jan 26, 2021

Hello,

I'm not sure if I'm correct to be posting in here, but today I went through the same struggles as the original poster (initially trying to follow the documentation which tells users to use the (indeed nowhere-to-be-found) JettyHttpContainerFactory class, so instead of using the Factory I went ahead and created a Jetty Server "by hand" and registered my jersey service using new ServletHolder(new ServletContainer(resourceConfig)) and added that to my context handler.

So I was able to run Jersey 3.0.0 on Jetty 11. However - and since I'm doing a modular (JPMS) project - I had to do a little bit of black magic to get the dependencies to behave (for one thing, jakarta.servlet is still a split package in the jetty / jersey combo context) but eventually got the server going. And finally, I came across a show-stopping serialization issue (for my project at least) at runtime which seems to relate to new reflection & access constraints in modular Java (see stacktrace below).

So I was wondering a few things:

  • is jersey supposed to be supporting JPMS right now?
  • if so, would you like me to open a dedicated issue for this?
  • are you aware of a workaround to get serialization (and in particular accessors) to work in a modular project context (by the way, my module already "opens" everything it's got)? As of right now, the only (very poor) workaround I found is to pass strings only and do my own mapping within service code.... in other words, blah.

Thanks in advance!

[qtp2088371948-19] WARN org.eclipse.jetty.server.HttpChannel - /account/login
jakarta.servlet.ServletException: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:761)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:517)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:226)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1576)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:226)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1355)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:181)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:472)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:179)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1279)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:134)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:154)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.Server.handle(Server.java:567)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:404)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:661)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:396)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:289)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:324)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:106)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:790)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:912)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.createReadHandle(PropertyModel.java:543)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.<init>(PropertyModel.java:167)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.ClassParser.lambda$parseProperties$0(ClassParser.java:70)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1766)
	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.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.ClassParser.parseProperties(ClassParser.java:71)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.MappingContext.lambda$createParseClassModelFunction$1(MappingContext.java:97)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.MappingContext.getOrCreateClassModel(MappingContext.java:81)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.getRootSerializer(Marshaller.java:161)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.serializeRoot(Marshaller.java:142)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:73)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:101)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.JsonBinding.toJson(JsonBinding.java:126)
	at jersey.media.json.binding@3.0.0/org.glassfish.jersey.jsonb.internal.JsonBindingProvider.writeTo(JsonBindingProvider.java:103)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:242)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.server@3.0.0/org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.server@3.0.0/org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:61)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:244)
	at jersey.common@3.0.0/org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
	... 34 more
Caused by: java.lang.IllegalAccessException: access to public member failed: com.projectvisionaries.federator.model.Account.getPassword[Ljava.lang.Object;@1c543eb4/invokeVirtual, from class org.eclipse.yasson.internal.model.PropertyModel (module org.eclipse.yasson)
	at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:954)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:2977)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:2917)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:3062)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:3055)
	at java.base/java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:2489)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.createReadHandle(PropertyModel.java:541)
	... 74 more
[qtp2088371948-19] WARN org.eclipse.jetty.server.HttpChannelState - unhandled due to prior sendError
jakarta.servlet.ServletException: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:410)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:761)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:517)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:226)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1576)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:226)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1355)
Caused by: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'

	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:181)
	at org.eclipse.jetty.servlet@11.0.0/org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:472)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1549)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:179)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1279)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:134)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:154)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.Server.handle(Server.java:567)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.lambda$handle$0(HttpChannel.java:404)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:661)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:396)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:289)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:324)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io@11.0.0/org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:106)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:790)
	at org.eclipse.jetty.util@11.0.0/org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:912)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.createReadHandle(PropertyModel.java:543)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.<init>(PropertyModel.java:167)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.ClassParser.lambda$parseProperties$0(ClassParser.java:70)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1766)
	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.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.ClassParser.parseProperties(ClassParser.java:71)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.MappingContext.lambda$createParseClassModelFunction$1(MappingContext.java:97)
	at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.MappingContext.getOrCreateClassModel(MappingContext.java:81)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.getRootSerializer(Marshaller.java:161)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.serializeRoot(Marshaller.java:142)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:73)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.Marshaller.marshall(Marshaller.java:101)
Caused by: java.lang.IllegalAccessException: access to public member failed: com.projectvisionaries.federator.model.Account.getPassword[Ljava.lang.Object;@1c543eb4/invokeVirtual, from class org.eclipse.yasson.internal.model.PropertyModel (module org.eclipse.yasson)

	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.JsonBinding.toJson(JsonBinding.java:126)
	at jersey.media.json.binding@3.0.0/org.glassfish.jersey.jsonb.internal.JsonBindingProvider.writeTo(JsonBindingProvider.java:103)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:242)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:227)
Caused by: jakarta.json.bind.JsonbException: Error accessing getter 'getPassword' declared in 'class com.projectvisionaries.federator.model.Account'

	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.server@3.0.0/org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:85)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.server@3.0.0/org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:61)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
	at jersey.common@3.0.0/org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1116)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:635)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:373)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:363)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:258)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at jersey.common@3.0.0/org.glassfish.jersey.internal.Errors.process(Errors.java:244)
	at jersey.common@3.0.0/org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
	... 34 more
Caused by: java.lang.IllegalAccessException: access to public member failed: com.projectvisionaries.federator.model.Account.getPassword[Ljava.lang.Object;@1c543eb4/invokeVirtual, from class org.eclipse.yasson.internal.model.PropertyModel (module org.eclipse.yasson)
	at java.base/java.lang.invoke.MemberName.makeAccessException(MemberName.java:954)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkAccess(MethodHandles.java:2977)
	at java.base/java.lang.invoke.MethodHandles$Lookup.checkMethod(MethodHandles.java:2917)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodCommon(MethodHandles.java:3062)
	at java.base/java.lang.invoke.MethodHandles$Lookup.getDirectMethodNoSecurityManager(MethodHandles.java:3055)
	at java.base/java.lang.invoke.MethodHandles$Lookup.unreflect(MethodHandles.java:2489)
	at org.eclipse.yasson@2.0.1/org.eclipse.yasson.internal.model.PropertyModel.createReadHandle(PropertyModel.java:541)
	... 74 more
Caused by: java.lang.IllegalAccessException: access to public member failed: com.projectvisionaries.federator.model.Account.getPassword[Ljava.lang.Object;@1c543eb4/invokeVirtual, from class org.eclipse.yasson.internal.model.PropertyModel (module org.eclipse.yasson)

And here are my dependencies:


    runtime("org.eclipse.jetty:jetty-server:11.0.0")
    compile("org.eclipse.jetty:jetty-servlet:11.0.0")
    compile("org.glassfish.jersey.core:jersey-server:3.0.0")
    compile("org.glassfish.jersey.containers:jersey-container-jetty-servlet:3.0.0"){
        exclude group: 'jakarta.servlet', module: 'jakarta.servlet-api'
    }
    compile("jakarta.annotation:jakarta.annotation-api:2.0.0")
    runtime("jakarta.xml.bind:jakarta.xml.bind-api:3.0.0")
    compile("jakarta.json:jakarta.json-api:2.0.0")
    compile("jakarta.json.bind:jakarta.json.bind-api:2.0.0")

    runtime("org.glassfish.jersey.containers:jersey-container-jetty-http:3.0.0")
    runtime("org.glassfish.jersey.connectors:jersey-jetty-connector:3.0.0")
    runtime("org.glassfish.jersey.containers:jersey-container-servlet-core:3.0.0")

    runtime("org.glassfish.jersey.inject:jersey-hk2:3.0.0")
    runtime("org.glassfish.jersey.media:jersey-media-json-binding:3.0.0")

@jansupol
Copy link
Contributor

It would be good if you can provide us a reproducer.

However, a couple of googling shows a similar issue when a default method is used. Is Account using a default method? So far, this seems to be a Yasson issue rather than Jersey.

@doriancransac
Copy link

@jansupol
Account is just a POJO with no default method and everything public.
Yeah, I only noticed the yasson package being involved in there after I posted this (sorry), should I post this over at Yasson instead? Reproducer-wise do you just want the code I used to start the server & the service or you want me to try and boil it down to just the yasson call?

@senivam senivam added this to the 3.0.1 milestone Jan 27, 2021
@senivam
Copy link
Contributor

senivam commented Jan 27, 2021

@birdflyer-lszo release 3.0.1 is published to Central, it includes fixes for Jetty connector and containers multirelease jars. So, this issue can be closed as resolved.

@doriancransac if you believe the issue you are reporting is Jersey's bug please open a separate issue.

@senivam senivam closed this as completed Jan 27, 2021
@birdflyer-lszo
Copy link
Author

hmm, I see the class now in the .jar file, however, it is stuffed somewhere into the META-INF directory. I guess that makes it a little hard to import that class. Or do I miss something here?

image

@senivam
Copy link
Contributor

senivam commented Jan 28, 2021

All files which are bundled in META-INF/versions/11 shall be normally accessible when JDK 11+ is used. That is the purpose of multi release jar - it makes possible to provide different functionality for different JDKs in classes with same name. So, when you use JDK 1.8 only not supported exception will be thrown, when you use JDK 11 for the same import you shall be able to run container normally.

@birdflyer-lszo
Copy link
Author

alright, thanks for the info. guess then our build is screwed and somehow does not recognize MRJARs. i will look into this.

@senivam
Copy link
Contributor

senivam commented Jan 28, 2021

Multi-release jar files are supported out of the box since JDK 9, so please check if you indeed run build using JDK 11+ (may be better 11.0.4+ due to some internal JDK errors fixed in and after 11.0.4). And for our inner tests those changes pass just fine, Jetty containers starts when JDK 11 is applied. And for JDK 1.8 Jetty does not work.

@LGuillenOlmos
Copy link

Hello. We are still having the problem that @birdflyer-lszo had. With Java 11, and the classes in META-INF, we are not able to import the JettyHttpContainerFactory class. We are not using maven but gradle, so I don't know if that might be a problem for having different profiles or its just that something is stilling missing in 3.0.1 version....Thank you

@senivam senivam linked a pull request Feb 2, 2021 that will close this issue
@senivam
Copy link
Contributor

senivam commented Feb 2, 2021

@RiceNeramy seems you are right, imported file shall be present in the main target as well. So, PR #4709 shall fix that, however this will be publicly available after the next release (3.0.2 may be). Meanwhile you can use the fix after it's merged from SNAPSHOT repository or build it for your needs separately.

@birdflyer-lszo, this actually applies to you as well.

Thanks for your patience :)

@LGuillenOlmos
Copy link

@senivam Thank you very much for you quick response. Ok , good, we will use the fix then. Cheers!

@darmbrust
Copy link

Any ETA on 3.0.2? I've been chasing my tail on this bug after updating dependencies for hours... before I realized that this was a multi-version jar issue.

For me, it doesn't work properly in eclipse, when writing my test code, nor does it work properly when trying to use testng to run a jersey + jetty test case. Its going down the code path of telling me I'm on Java8.....

@darmbrust
Copy link

darmbrust commented Feb 11, 2021

Will the proposed fix in the referenced bug fix the fact that this class is missing from the jar file?

https://github.com/eclipse-ee4j/jersey/blob/3.x/test-framework/providers/jetty/src/main/java11/org/glassfish/jersey/test/jetty/JettyTestContainerFactory.java

Without this class, this bug needs to stay open....

@darmbrust
Copy link

For anyone else running across this issue,

jakarta.ws.rs.ProcessingException: Jetty container is not supported on JDK version less than 11.

I was able to work around it with 3.0.1 by "fixing" the jersey-container-jetty-http jar file, by pulling the JDK 11 classes out of the buried multi-jar location, and overwriting the JDK 8 classes in the normal places in the jar file. Without this fix, Eclipse is very confused about the state of this multi-jar file - I don't know multi-jar well enough to know what is wrong with it.

The second required fix to make anything with maven / testng work is to provide the missing JettyTestContainerFactory.java - I just dropped a copy of it into my project locally.

This whole multi-version jar mess seems like an awful lot of work / bugs just to tell someone that java 8 isn't supported... pretty sure developers would figure that out anyway...

@adriansuarez
Copy link

I'm not sure what the resolution was here, but the annoying issues with Eclipse not using the META-INF/versions/17 classes are still present, 3 years later. The useful classes are still buried within META-INF/versions/17, and the default ones are still the useless implementations that do nothing except raise an exception when any method is invoked on them. This marginally useful thing is even less useful now that fewer people are still using Java 8, yet the useless and problematic classes remain.

Can we please just delete the useless classes and replace them with the useful classes, so that people can actually use the Jetty container within Eclipse without resorting to patching the JAR in ~/.m2/repo, or whatever the workaround is?

The other issue that I ran into is that repackaging Jersey and the Jetty container into my own uber-jar requires me to make my own JAR into a multi-release JAR, even though I am compiling at Java 17. Without setting Multi-Release: true in the JAR manifest, I get the extremely confusing error message "jakarta.ws.rs.ProcessingException: Jetty container is not supported on JDK version less than 17" even though I am using Java 17.

@senivam
Copy link
Contributor

senivam commented Apr 22, 2024

@adriansuarez and which version of Jersey do you use?

@adriansuarez
Copy link

@senivam I'm running into this on 3.1.6, but I suspect any version that packages the Jetty container as a multi-jar would cause this. Basically what I'm experiencing is exactly what @darmbrust reported in 2021, but with the latest 3.x.

I was able to workaround this by bumping the Jersey version to 4.0.0-M1, but I do not want to use a non-GA/milestone release.

@senivam
Copy link
Contributor

senivam commented Apr 22, 2024

@adriansuarez the reason why we still keep multi-release jars is because there is a requirement to support a lover JDK than what is used to run Jetty 12. As you are saying, 4.0.0-M1 does not have it because it is already JDK 17 minimum. However the 3.1.x must support JDK 11, that is why multi-rlease jars are still in place. I'll take a look, why it does not work even with JDK 17. BTW, just for complete image, are you using JDK from OpenJDK, Oracle, Temurin, Azul or anything else? Thank you for reporting that.

@adriansuarez
Copy link

adriansuarez commented Apr 22, 2024

@senivam I added the following print statements:

    public static JettyHttpContainer createContainer(ResourceConfig config) {
        var container = ContainerFactory.createContainer(JettyHttpContainer.class, config);
        System.getProperties().forEach((k, v) -> System.err.println(k + "=" + v));
        System.err.println(container.getClass().getCanonicalName());
        System.err.println(container.getClass().getResource(""));
        return container;
    }

Which display the following:

java.specification.version=17
sun.management.compiler=HotSpot 64-Bit Tiered Compilers
java.runtime.version=17.0.8+7
java.vm.vendor=Eclipse Adoptium
sun.arch.data.model=64
os.version=14.3.1
java.runtime.name=OpenJDK Runtime Environment
file.encoding=UTF-8
java.vendor.url=https://adoptium.net/
java.vm.name=OpenJDK 64-Bit Server VM
java.vm.specification.version=17
os.name=Mac OS X
java.vendor.version=Temurin-17.0.8+7
...
java.vendor.url.bug=https://github.com/adoptium/adoptium-support/issues
jdk.debug=release
java.version=17.0.8
os.arch=x86_64
user.language=en
java.specification.vendor=Oracle Corporation
java.vm.specification.name=Java Virtual Machine Specification
java.version.date=2023-07-18
...
java.vm.info=mixed mode, sharing
java.vm.specification.vendor=Oracle Corporation
java.specification.name=Java Platform API Specification
java.vendor=Eclipse Adoptium
java.vm.version=17.0.8+7
java.class.version=61.0
org.glassfish.jersey.jetty.JettyHttpContainer
jar:file:/Users/asz6/.m2/repository/org/glassfish/jersey/containers/jersey-container-jetty-http/3.1.6/jersey-container-jetty-http-3.1.6.jar!/META-INF/versions/17/org/glassfish/jersey/jetty/

It seems like the correct version of JettyHttpContainer is actually being used, but I am seeing bizarre runtime errors (the server just responds with "500 Server Error". I'll add more logging to see what the server is complaining about.

I do not see these issues with 4.0.0-M1, and I also do not have these issues when running the repackaged uber-jar after adding Multi-Release: true to the manifest.

@senivam To answer your question, Temurin-17.0.8+7.

@adriansuarez
Copy link

This is the stacktrace of the exception that generates the 500 response:

java.lang.NoClassDefFoundError: org/eclipse/jetty/security/AuthenticationState
	at org.glassfish.jersey.jetty.JettyHttpContainer.getSecurityContext(JettyHttpContainer.java:212)
	at org.glassfish.jersey.jetty.JettyHttpContainer.handle(JettyHttpContainer.java:153)
	at org.eclipse.jetty.server.Server.handle(Server.java:179)
	at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:619)
	at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:411)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:979)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1209)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1164)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.security.AuthenticationState
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
	... 12 more

@adriansuarez
Copy link

adriansuarez commented Apr 22, 2024

@senivam Okay, I think I understand what the issue is. The org.eclipse.jetty:jetty-server was not being loaded within Eclipse. Eclipse also does not navigate to the correct source files and shows the "JDK 8 is not supported" versions of JettyHttpContainer, etc.

I did find the class org/eclipse/jetty/security/AuthenticationState in my uber-jar, so that explains why Jetty works when running the JAR but not in Eclipse.

The solution was to explicitly add org.eclipse.jetty:jetty-server as a dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
7 participants