Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3656

Wadl generation problem with @FormParam cause IllegalStateException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.1
    • 2.4.2, 2.5
    • JAX-RS
    • None

    Description

      When we are migrate to 2.4.1 from 2.3.1 we have an exception with wadl generation
      java.lang.IllegalStateException
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.getRequestBodyParam(WadlGenerator.java:606)
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.handleRepresentation(WadlGenerator.java:574)
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.handleFormRepresentation(WadlGenerator.java:618)
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.handleOperation(WadlGenerator.java:359)
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.handleResource(WadlGenerator.java:285)
      at org.apache.cxf.jaxrs.model.wadl.WadlGenerator.handleRequest(WadlGenerator.java:216)
      at org.apache.cxf.jaxrs.impl.RequestPreprocessor.handleMetadataRequest(RequestPreprocessor.java:201)
      at org.apache.cxf.jaxrs.impl.RequestPreprocessor.checkMetadataRequest(RequestPreprocessor.java:186)
      at org.apache.cxf.jaxrs.impl.RequestPreprocessor.preprocess(RequestPreprocessor.java:82)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:112)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:88)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
      at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:118)
      at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:208)
      at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
      at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:205)
      at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:113)
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:184)
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:112)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
      at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:163)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:343)
      at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      at com.utest.service.security.FlexSecurityContextPersistenceFilter.doFilter(FlexSecurityContextPersistenceFilter.java:85)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      at org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:109)
      at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:355)
      at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:149)
      at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
      at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
      at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
      at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
      at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:436)
      at org.apache.coyote.ajp.AjpProtocol$AjpConnectionHandler.process(AjpProtocol.java:384)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:619)

      Investigation shown that exception cause for next method:
      @POST
      @Path("/

      {id}

      /replyInfo")
      @Consumes(

      { MediaType.APPLICATION_FORM_URLENCODED }

      )
      public ResourceIdentity processReplyRequestedInfo( @PathParam("id") final Integer id, @FormParam("comments") final String comments)

      when change method signature to:
      public ResourceIdentity processReplyRequestedInfo( @FormParam("comments") final String comments, @PathParam("id") final Integer id )
      resolves issue.

      Analysis of source code for class org.apache.cxf.jaxrs.model.wadl.WadlGenerator.java provide conclusion why it happen.

      Chain of calls:
      private boolean handleOperation(StringBuilder sb, Set<Class<?>> jaxbTypes,
      ElementQNameResolver qnameResolver,
      Map<Class<?>, QName> clsMap,
      OperationResourceInfo ori,
      OperationResourceInfo nextOp,
      boolean resourceTagOpened,
      int index) {
      ....
      if (isFormRequest(ori)) {
      358: handleFormRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, getFormClass(ori));

      859: private Class<?> getFormClass(OperationResourceInfo ori) {
      if (ori.getParameters().get(0).getType() == ParameterType.FORM)

      { <-- here it could be a problem. Code checks only first parameter. return null; }

      else

      { return MultivaluedMap.class; }

      }

      in case of first parameter is @PathParam the formClass returned value MultivaluedMap.class and exception thrown.
      in

      private void handleFormRepresentation(StringBuilder sb, Set<Class<?>> jaxbTypes,
      ElementQNameResolver qnameResolver,
      Map<Class<?>, QName> clsMap, OperationResourceInfo ori,
      Class<?> type) {
      617: if (type != null) {
      handleRepresentation(sb, jaxbTypes, qnameResolver, clsMap, ori, type, true);

      .....
      if (inbound) {
      573: int index = getRequestBodyParam(ori).getIndex();

      599:private Parameter getRequestBodyParam(OperationResourceInfo ori) {
      for (Parameter p : ori.getParameters()) {
      if (p.getType() == ParameterType.REQUEST_BODY)

      { <-- there is no body type request return p; }

      }
      throw new IllegalStateException();
      }

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            bgennadiy Gennadiy Bukhmatov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: