Skip to content

java.lang.reflect.InaccessibleObjectException Unable to make protected [...] when using mongojack in a web context #210

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

Closed
doriancransac opened this issue Jan 30, 2021 · 2 comments

Comments

@doriancransac
Copy link

Hello,

When using mongojack and jackson in a "standalone" context in my modular project, everything works fine. However, when incorporating my DAO layer into a jetty 11 / jersey 3.0.0 context, I run into the following exception while executing a simple countDocument(Bson), as mongojack tries to serialize the filter (from what I can tell). I'm suspecting the issue has to do with the fact that jersey uses jackson to deserialize my service's input object first.

Any idea what's wrong here and/or what could be done to fix this?

Here is the full stacktrace:

jakarta.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	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.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: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:254)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:236)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:438)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263)
	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)
	... 29 more
Caused by: java.lang.ExceptionInInitializerError
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtilsImpl.serializeFilter(DocumentSerializationUtilsImpl.java:423)
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtils.serializeFilter(DocumentSerializationUtils.java:87)
	at mongojack@4.0.2/org.mongojack.JacksonMongoCollection.manageFilterBson(JacksonMongoCollection.java:474)
	at mongojack@4.0.2/org.mongojack.MongoCollectionDecorator.countDocuments(MongoCollectionDecorator.java:194)
	at com.projectvisionaries.federator/com.projectvisionaries.federator.AccountServices.create(AccountServices.java:93)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
	... 38 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected com.fasterxml.jackson.databind.deser.DefaultDeserializationContext com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationConfig) accessible: module com.fasterxml.jackson.databind does not "opens com.fasterxml.jackson.databind" to module mongojack
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.findMethod(JacksonAccessor.java:121)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.<clinit>(JacksonAccessor.java:107)
	... 56 more
[qtp2044482328-21] DEBUG org.eclipse.jetty.server.HttpChannelState - thrownException s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=true i=true al=0
jakarta.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	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)
Caused by: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError

	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.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: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:254)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:236)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:438)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263)
Caused by: java.lang.ExceptionInInitializerError

	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)
	... 29 more
Caused by: java.lang.ExceptionInInitializerError
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtilsImpl.serializeFilter(DocumentSerializationUtilsImpl.java:423)
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtils.serializeFilter(DocumentSerializationUtils.java:87)
	at mongojack@4.0.2/org.mongojack.JacksonMongoCollection.manageFilterBson(JacksonMongoCollection.java:474)
	at mongojack@4.0.2/org.mongojack.MongoCollectionDecorator.countDocuments(MongoCollectionDecorator.java:194)
	at com.projectvisionaries.federator/com.projectvisionaries.federator.AccountServices.create(AccountServices.java:93)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected com.fasterxml.jackson.databind.deser.DefaultDeserializationContext com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationConfig) accessible: module com.fasterxml.jackson.databind does not "opens com.fasterxml.jackson.databind" to module mongojack

	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
	... 38 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected com.fasterxml.jackson.databind.deser.DefaultDeserializationContext com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationConfig) accessible: module com.fasterxml.jackson.databind does not "opens com.fasterxml.jackson.databind" to module mongojack
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.findMethod(JacksonAccessor.java:121)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.<clinit>(JacksonAccessor.java:107)
	... 56 more
[qtp2044482328-21] WARN org.eclipse.jetty.server.HttpChannelState - unhandled due to prior sendError
jakarta.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	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)
Caused by: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError

	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.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: org.glassfish.jersey.server.ContainerException: java.lang.ExceptionInInitializerError
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.rethrow(ResponseWriter.java:254)
	at jersey.container.servlet.core@3.0.0/org.glassfish.jersey.servlet.internal.ResponseWriter.failure(ResponseWriter.java:236)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:438)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:263)
Caused by: java.lang.ExceptionInInitializerError

	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)
	... 29 more
Caused by: java.lang.ExceptionInInitializerError
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtilsImpl.serializeFilter(DocumentSerializationUtilsImpl.java:423)
	at mongojack@4.0.2/org.mongojack.internal.util.DocumentSerializationUtils.serializeFilter(DocumentSerializationUtils.java:87)
	at mongojack@4.0.2/org.mongojack.JacksonMongoCollection.manageFilterBson(JacksonMongoCollection.java:474)
	at mongojack@4.0.2/org.mongojack.MongoCollectionDecorator.countDocuments(MongoCollectionDecorator.java:194)
	at com.projectvisionaries.federator/com.projectvisionaries.federator.AccountServices.create(AccountServices.java:93)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected com.fasterxml.jackson.databind.deser.DefaultDeserializationContext com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationConfig) accessible: module com.fasterxml.jackson.databind does not "opens com.fasterxml.jackson.databind" to module mongojack

	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391)
	at jersey.server@3.0.0/org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80)
	at jersey.server@3.0.0/org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
	... 38 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected com.fasterxml.jackson.databind.deser.DefaultDeserializationContext com.fasterxml.jackson.databind.ObjectMapper.createDeserializationContext(com.fasterxml.jackson.core.JsonParser,com.fasterxml.jackson.databind.DeserializationConfig) accessible: module com.fasterxml.jackson.databind does not "opens com.fasterxml.jackson.databind" to module mongojack
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:349)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:289)
	at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
	at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.findMethod(JacksonAccessor.java:121)
	at mongojack@4.0.2/org.mongojack.internal.util.JacksonAccessor.<clinit>(JacksonAccessor.java:107)
	... 56 more
[qtp2044482328-21] DEBUG org.eclipse.jetty.server.HttpChannelState - unhandle HttpChannelState@41b4317f{s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=true i=true al=0}
[qtp2044482328-21] DEBUG org.eclipse.jetty.server.HttpChannelState - nextAction(false) SEND_ERROR HttpChannelState@41b4317f{s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=false al=0}
[qtp2044482328-21] DEBUG org.eclipse.jetty.server.HttpChannel - action SEND_ERROR HttpChannelOverHttp@4179979e{s=HttpChannelState@41b4317f{s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=false al=0},r=1,c=false/false,a=HANDLING,uri=http://localhost:30001/account/create,age=178}
[qtp2044482328-21] DEBUG org.eclipse.jetty.server.HttpInput - consumeAll HttpInput@105426675 cs=HttpChannelState@41b4317f{s=HANDLING rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=false al=0} cp=org.eclipse.jetty.server.BlockingContentProducer@597fd0d8 eof=false
java.io.IOException: Unconsumed content
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpInput.consumeAll(HttpInput.java:133)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.ensureConsumeAllOrNotPersistent(HttpChannel.java:592)
	at org.eclipse.jetty.server@11.0.0/org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:439)
	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.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)

And the service code producing the issue, i.e long name = accounts.countDocuments(nameFilter); in :

  @POST
   @Path("create")
   @Produces(MediaType.APPLICATION_JSON)
   @Consumes(MediaType.APPLICATION_JSON)
   public Response create(Account account) {
       try{ integrityCheck(account); }catch (RuntimeException e){ return processError(e);}
       Bson nameFilter = Filters.eq("name", account.getName());
       long name = accounts.countDocuments(nameFilter);
       if(name == 0) {
           accounts.insertOne(account);
           account.setPassword("<redacted>");
           return processSuccess(account);
       }else{
           return processError("Name already taken.");
       }
   }
@doriancransac
Copy link
Author

After noticing the call to method.setAccessible(true); in JacksonAccessor.java and reading this I think I was just able to work around the problem by adding the following JVM flags:

--add-opens com.fasterxml.jackson.databind/com.fasterxml.jackson.databind.ser.std=mongojack
--add-opens com.fasterxml.jackson.databind/com.fasterxml.jackson.databind=mongojack

Not sure if that's intended behavior though, I'll let you be the judge

rlodge added a commit that referenced this issue Feb 3, 2021
rlodge added a commit that referenced this issue Feb 3, 2021
(cherry picked from commit ae3d0f6)
@rlodge
Copy link
Contributor

rlodge commented Feb 3, 2021

I think getting rid of the reflective access would probably be a good idea. I added some code to work around this if you want to test. I deployed a 4.0.3-SNAPSHOT and a 4.2.0-SNAPSHOT (using the new 4.2 driver) to the Sonatype OSS Snapshot repository.

@rlodge rlodge closed this as completed Apr 5, 2021
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

2 participants