Open jerseyrobot opened 9 years ago
@glassfishrobot Commented Reported by heruan
@glassfishrobot Commented heruan said: Here's the application code:
**Application.java**package org.example;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.message.filtering.SelectableEntityFilteringFeature;
import org.glassfish.jersey.server.ResourceConfig;
@ApplicationPath("/api")
public class Application extends ResourceConfig {
public Application() {
this.packages("org.example.resource");
this.register(SelectableEntityFilteringFeature.class);
this.property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "fields");
}
}
**HostResource.java**package org.example.resource;
import org.example.entity.Host;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/hosts")
public class HostResource {
@PersistenceContext
EntityManager em;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Host> get() {
return em.createNamedQuery("Host.findAll").getResultList();
}
}
**Host.java**package org.example.entity;
import java.util.List;
public class Host {
long id;
String host;
List<Interface> interfaces;
// getters and setters }
**Interface.java**package org.example.entity;
import java.util.List;
public class Interface {
long id;
boolean main;
int type;
String ip;
String dns;
List<Item> items;
// getters and setters }
**Item.java**package org.example.entity;
import java.util.List;
public class Item {
long id;
String name;
String key;
List<Function> functions;
// getters and setters }
**Function.java**package org.example.entity;
import java.util.List;
public class Function {
long id;
String function;
Trigger trigger;
// getters and setters }
**Trigger.java**package org.example.entity;
import java.util.List;
public class Trigger {
long id;
String expression;
String description;
int status;
// getters and setters }
And this is an unfiltered JSON response:
{
"host": "10.26.5.158",
"id": 12345,
"interfaces": [
{
"dns": "",
"id": 2615,
"ip": "10.26.5.158",
"items": [
{
"functions": [
{
"function": "max",
"id": 32002,
"trigger": {
"description": "{HOST.NAME} is unavailable by ICMP",
"expression": "{32002}=0",
"id": 24961,
"status": 0
}
}
],
"id": 67019,
"key": "icmpping",
"name": "ICMP ping"
},
{
"functions": [
{
"function": "min",
"id": 24613,
"trigger": {
"description": "Ping loss is too high on {HOST.NAME}",
"expression": "{24613}>20",
"id": 24962,
"status": 0
}
}
],
"id": 67020,
"key": "icmppingloss",
"name": "ICMP loss"
},
{
"functions": [
{
"function": "avg",
"id": 46426,
"trigger": {
"description": "Response time is too high on {HOST.NAME}",
"expression": "({TRIGGER.VALUE}=0&{46426}>0.5)|({TRIGGER.VALUE}=1&{46426}>0.25)",
"id": 24963,
"status": 0
}
}
],
"id": 67021,
"key": "icmppingsec",
"name": "ICMP response time"
}
],
"main": true,
"type": 2
}
]
}
The exception reported is thrown on the first request with or without the query fields parameter, when the feature is registered; all is well when the feature isn't registered.
@glassfishrobot Commented @AdamLindenthal said: Hi and thanks for creating the issue. I just spent some time trying to reproduce the problem with no success. Would you mind sharing a complete minimalistic ready-to-go app? E.g. maven-buildable and -runnable demo app or test case.
I just tried the selectable entity filtering feature with jackson using the code you provided (with minimal changes - I didn't want to configure the persistence, so I changed the querying the entity manager into returning sample test object right from the resource, but I left the rest of your code intact) and everything worked with the feature off and on, with or without the fields parameter.
it would be very helpful, if you could minimize your usecase into something standalone and share it with us.
Thanks, Adam
@glassfishrobot Commented @mpotociar said: Closing as incomplete - no response from the filer.
@glassfishrobot Commented heruan said: Sorry for the delay, it was not simple to reproduce the problem in a ready-to-go app since I've found the issue arises only when injection occurs in the resource (e.g. the EntityManager with @PersistenceContext, but also injecting a DAO with @Inject where the DAO has on its side an EntityManager injected with @PersistenceContext). I think this is why Adam couldn't reproduce the problem, since he didn't configure persistence.
I'm using MOXy and EclipseLink 2.6.
(Should I open a new bug or this can be reopened? Thank you!)
@glassfishrobot Commented heruan said: Here's the ready-to-go app https://github.com/heruan/jersey-selectable-filtering which breaks when deployed.
@glassfishrobot Commented heruan said: Did anyone besides me successfully replicated this?
@glassfishrobot Commented csolem said: I'm seeing a similar stack trace in my application with Jersey Entity Filtering. It appears on the first request only. Jersey is not configured with the SelectableEntityFilteringFeature, but with the EntityFilteringFeature.
The application is built using spring boot (1.3.0.RELEASE), spring-boot-starter-data-jpa, jackson (not Moxy) and jersey-entity-filtering (2.22.1).
java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class
at org.glassfish.jersey.message.filtering.spi.FilteringHelper._getEntityClass(FilteringHelper.java:140) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.spi.FilteringHelper.getEntityClass(FilteringHelper.java:98) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.spi.AbstractEntityProcessor.process(AbstractEntityProcessor.java:89) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityFilteringProcessor.process(EntityFilteringProcessor.java:76) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspectStandaloneAccessors(EntityInspectorImpl.java:204) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:106) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:91) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:85) ~[jersey-entity-filtering-2.22.1.jar:na]
at org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider.writeTo(FilteringJacksonJaxbJsonProvider.java:130) ~[jersey-media-json-jackson-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:315) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:297) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.internal.Errors.process(Errors.java:267) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) ~[jersey-common-2.22.1.jar:na]
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) ~[jersey-server-2.22.1.jar:na]
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) ~[jersey-container-servlet-core-2.22.1.jar:na]
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) ~[jersey-container-servlet-core-2.22.1.jar:na]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) ~[jersey-container-servlet-core-2.22.1.jar:na]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) ~[jersey-container-servlet-core-2.22.1.jar:na]
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) ~[jersey-container-servlet-core-2.22.1.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.28.jar:8.0.28]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.28.jar:8.0.28]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_66]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_66]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_66]
@glassfishrobot Commented @mpotociar said: Reducing issue priority, which means that we may not be fixing this soon, depending on available resources.
@glassfishrobot Commented mamghari said: Hi,
Please reopen the issue. The SelectableEntityFiltering introduce some issues even when the "select" query param is not specified!
From my point of view, the filtering should be activated only when the "select" query param is specified in the URL. Furthermore, the serialization of collections is not well working when the filtering is activated. I mean I got a lot of JsonMappingExceptionMapper. What I understand is that the filtering is applied when sending the payload to the client, during the serialization. I am using Jersey 2.22.1 + Jackson.
ERROR JsonMappingExceptionMapper:29 [http-bio-8080-exec-3] Malformed Json! com.fasterxml.jackson.databind.JsonMappingException: Can not resolve PropertyFilter with id 'java.util.HashMap'; no FilterProvider configured
The work around I found is http://stackoverflow.com/questions/35437298/jersey-jackson-data-entity-filtering-jsonmappingexception-on-collection But it works only if the root object is a Collection, not when it is included in a Pojo.
The new issue I got today is the following one when executing Cucumber tests:
java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class at org.glassfish.jersey.jetty.JettyHttpContainer.handle(JettyHttpContainer.java:197) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:459) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:281) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:232) at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class at org.glassfish.jersey.message.filtering.spi.FilteringHelper._getEntityClass(FilteringHelper.java:140) at org.glassfish.jersey.message.filtering.spi.FilteringHelper.getEntityClass(FilteringHelper.java:98) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspectEntityProperties(EntityInspectorImpl.java:163) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:103) at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:91) at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:85) at org.glassfish.jersey.jackson.internal.FilteringJacksonJaxbJsonProvider.writeTo(FilteringJacksonJaxbJsonProvider.java:130) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
Thank you very much to help and to fix this issue, Mohamed
@glassfishrobot Commented mamghari said: Hi,
Do you have any news regarding this issue ?
Thank you
@glassfishrobot Commented ftaleman said: Hi,
Getting this for every one of our requests that is serializing a JPA entity from the moment the SelectableEntityFilteringFeature or EntityFilteringFeature is enabled.
On Glassfish 4.1.1
property(SelectableEntityFilteringFeature.QUERY_PARAM_NAME, "select"); register(SelectableEntityFilteringFeature.class);
Stack trace:
Severe: Exception: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class at org.glassfish.jersey.message.filtering.spi.FilteringHelper._getEntityClass(FilteringHelper.java:140) at org.glassfish.jersey.message.filtering.spi.FilteringHelper.getEntityClass(FilteringHelper.java:98) at org.glassfish.jersey.message.filtering.spi.AbstractEntityProcessor.process(AbstractEntityProcessor.java:89) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspectStandaloneAccessors(EntityInspectorImpl.java:204) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:106) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) at org.glassfish.jersey.message.filtering.EntityInspectorImpl.inspect(EntityInspectorImpl.java:110) at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:91) at org.glassfish.jersey.message.filtering.spi.AbstractObjectProvider.getFilteringObject(AbstractObjectProvider.java:85) at org.glassfish.jersey.moxy.json.internal.FilteringMoxyJsonProvider.preWriteTo(FilteringMoxyJsonProvider.java:80) at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:949) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:86) at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162) at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1130) at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:711) at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:444) at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:434) at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:329) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271) at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:267) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317) at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305) at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154) at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:471) at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336) at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167) at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206) at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180) at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235) at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283) at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200) at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132) at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111) at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77) at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536) at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56) at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591) at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571) at java.lang.Thread.run(Thread.java:745)
Is there a way to work around this error?
Thanks in advance!
Best regards Frederik
@glassfishrobot Commented dansiviter said: Filtering is basically not fit for purpose as no Collection types can be serialised. Any update on when a fix will be available? FYI this affects 2.23.1 also including both 2.5.4 and 2.7.5 versions of Jackson.
@glassfishrobot Commented dansiviter said: Here's a test that throws com.fasterxml.jackson.databind.JsonMappingException: Can not resolve PropertyFilter with id 'java.util.Map'; no FilterProvider configured:
public class EntityFilteringTest extends JerseyTest {
private static final GenericType<Map<String, String>> STRING_MAP = new GenericType<Map<String, String>>() { };
@Override
protected Application configure() {
return new ResourceConfig(
Resource.class,
EntityFilteringFeature.class,
JacksonFeature.class)
.property(
ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
}
@Override
protected DeploymentContext configureDeployment() {
SLF4JBridgeHandler.uninstall();
SLF4JBridgeHandler.install();
enable(TestProperties.LOG_TRAFFIC);
enable(TestProperties.DUMP_ENTITY);
set(TestProperties.RECORD_LOG_LEVEL, Level.ALL.intValue());
return super.configureDeployment();
}
@Test
public void get() {
final Map<String, String> response = target().request().get(STRING_MAP);
assertEquals(1, response.size());
assertEquals("World!", response.get("Hello"));
}
// --- Inner Classes ---
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public static class Resource {
@GET
public Map<String, String> get() {
return Collections.singletonMap("Hello", "World!");
}
}
}
I've tried List and Set and primitives and they're OK, it just seems to be Maps and implementations of.
Update: digging further, it appears Collection types do not perform BasicSerializerFactory#findFilterId where Map types do. As FilteringJacksonJaxbJsonProvider[line:112] returns the AnnotatedClass#getName (even though it's not annotated with a filter). I question if this is valid.
@glassfishrobot Commented pjbarry said: Ran into this today. Is there any work around?
@glassfishrobot Commented File: jersey-selectable-filtering-master.zip Attached By: @AdamLindenthal
@glassfishrobot Commented Issue-Links: is duplicated by JERSEY-2932
@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-2933
@RishikeshDarandale Commented Any update on this issue?
I was able reproduce this in Jersey 2.30 and Payara 5.201. Any plans to look at this?
When registering org.glassfish.jersey.message.filtering.SelectableEntityFilteringFeature to select fields to be marshalled in the response, objects with nested List fields (I suppose) throw a ClassCastException.
Environment
Glassfish 4.1
Affected Versions
[2.19]