[ https://issues.apache.org/jira/browse/CXF-7017?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Beryozkin resolved CXF-7017. ----------------------------------- Resolution: Fixed Assignee: Sergey Beryozkin Fix Version/s: 3.0.11 3.1.8 3.2.0 > @BeanParam not working in subresource > ------------------------------------- > > Key: CXF-7017 > URL: https://issues.apache.org/jira/browse/CXF-7017 > Project: CXF > Issue Type: Bug > Components: JAX-RS > Affects Versions: 3.1.6 > Environment: Java 1.8.0_91 > Tomee 7.0.1 > Reporter: Nicos Tegos > Assignee: Sergey Beryozkin > Fix For: 3.2.0, 3.1.8, 3.0.11 > > > Hello, > I tried to inject a BeanParam into a subresource. This doesn't work, > resulting in an exception (Stacktrace can be found at the end). > It works perfectly if I inject a QueryParam into the subresource. > I provided a minimal example with all classes below. To get the exception > just use the relative path: > resource/?searchType=1&maxItems=1 > {code} > package cxfbug.beanparam.app.config; > import javax.enterprise.context.RequestScoped; > import javax.ws.rs.Path; > import javax.ws.rs.Produces; > import javax.ws.rs.QueryParam; > @RequestScoped > @Path("resource") > @Produces("application/json") > public class Resource > { > @Path("/") > public Object getSubresource(@QueryParam("searchType") final int > searchType) > { > if (searchType == 1) > { > return new BeanParamSubresource(); > } > return new QueryParamSubresource(); > } > } > {code} > The subresource using QueryParam only: > {code} > package cxfbug.beanparam.app.config; > import javax.ws.rs.GET; > import javax.ws.rs.QueryParam; > public class QueryParamSubresource > { > @GET > public LimitedListSearchCriteria get(@QueryParam("maxItems") final int > maxItems) > { > final LimitedListSearchCriteria criteria = new > LimitedListSearchCriteria(); > criteria.setMaxItems(maxItems); > return criteria; > } > } > {code} > The subresource using BeanParam: > {code} > package cxfbug.beanparam.app.config; > import javax.ws.rs.BeanParam; > import javax.ws.rs.GET; > public class BeanParamSubresource > { > @GET > public LimitedListSearchCriteria get(@BeanParam final > LimitedListSearchCriteria searchCriteria) > { > return searchCriteria; > } > } > {code} > Class to be used as bean: > {code} > package cxfbug.beanparam.app.config; > import javax.ws.rs.QueryParam; > public class LimitedListSearchCriteria > { > @QueryParam("maxItems") > private int maxItems; > public int getMaxItems() > { > return maxItems; > } > public void setMaxItems(final int maxItems) > { > this.maxItems = maxItems; > } > } > {code} > Exception when using BeanParam: > {noformat} > Aug 19, 2016 9:34:05 PM org.apache.cxf.jaxrs.utils.JAXRSUtils > createBeanParamValue > WARNUNG: Bean parameter info is not available > Aug 19, 2016 9:34:05 PM > org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse > WARNUNG: javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server > Error > at > org.apache.cxf.jaxrs.utils.SpecExceptions.toInternalServerErrorException(SpecExceptions.java:79) > at > org.apache.cxf.jaxrs.utils.ExceptionUtils.toInternalServerErrorException(ExceptionUtils.java:106) > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.createBeanParamValue(JAXRSUtils.java:1052) > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:836) > at > org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:789) > at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:257) > at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99) > at > org.apache.openejb.server.cxf.rs.AutoJAXRSInvoker.invoke(AutoJAXRSInvoker.java:68) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) > at > org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308) > at > org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) > at > org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254) > at > org.apache.openejb.server.cxf.rs.CxfRsHttpListener.doInvoke(CxfRsHttpListener.java:251) > at > org.apache.tomee.webservices.CXFJAXRSFilter.doFilter(CXFJAXRSFilter.java:94) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > at > org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > at org.apache.openejb.server.httpd.EEFilter.doFilter(EEFilter.java:65) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) > at > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) > at org.apache.tomee.catalina.OpenEJBValve.invoke(OpenEJBValve.java:44) > at > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) > at > org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) > at > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) > at > org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) > at > org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) > at > org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) > at > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) > at > org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > at > org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) > at java.lang.Thread.run(Thread.java:745) > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)