Uploaded image for project: 'JBoss BPMS Platform'
  1. JBoss BPMS Platform
  2. RHBPMS-4558

[GSS](6.4.z) NPE when searching nonexistent task using the method UserTaskServicesClient.findTaskById

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 6.4.2
    • 6.4.0
    • Kie-Server
    • CR1
    • Workaround Exists
    • Hide

      use the taskClient.getTaskInstance method

      Show
      use the taskClient.getTaskInstance method
      • Start a Kie server
      • Use the kie server java client API to try to search a task that does not exist by id using the `taskClient.findTaskById` method

    Description

      When using the KieServer Java client and trying to search a task by ID using the method findTaskById from UserTaskServicesClient, we have a NPE in server side, resulting in an unexpected exception on client side. It should throw a 404 instead.

      • sample code
      Unable to find source-code formatter for language: java. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      configuration = KieServicesFactory.newRestConfiguration(URL, USR, PSW);
      // we can choose between XSTREAM, JSON and JAXB - default is JAXB
      configuration.setMarshallingFormat(MarshallingFormat.JAXB);
      // the time that the client can wait for a server response
      configuration.setTimeout(5000);
      client = KieServicesFactory.newKieServicesClient(configuration);
      UserTaskServicesClient taskClient =  client.getServicesClient(UserTaskServicesClient.class);
      
      // try to get a non existing task
      taskClient.findTaskById(123456l);
      

      Exception thrown on server side

      10:59:35,212 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/kie-server].[org.kie.server.remote.rest.common.KieServerApplication]] (http-127.0.0.1:8180-1) JBWEB000236: Servlet.service() for servlet org.kie.server.remote.rest.common.KieServerApplication threw exception: org.jboss.resteasy.spi.UnhandledException: java.lang.NullPointerException
      	at org.jboss.resteasy.core.SynchronousDispatcher.handleApplicationException(SynchronousDispatcher.java:367) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:235) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.handleInvokerException(SynchronousDispatcher.java:211) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:576) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:543) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:128) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar:1.0.2.Final-redhat-2]
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:512) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169) [jboss-as-web-7.5.7.Final-redhat-3.jar:7.5.7.Final-redhat-3]
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:150) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:854) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926) [jbossweb-7.5.15.Final-redhat-1.jar:7.5.15.Final-redhat-1]
      	at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_71]
      Caused by: java.lang.NullPointerException
      	at org.kie.server.services.jbpm.ConvertUtils.convertToTask(ConvertUtils.java:290) [kie-server-services-jbpm-6.5.0.Final-redhat-2.jar:6.5.0.Final-redhat-2]
      	at org.kie.server.services.jbpm.RuntimeDataServiceBase.getTaskById(RuntimeDataServiceBase.java:356) [kie-server-services-jbpm-6.5.0.Final-redhat-2.jar:6.5.0.Final-redhat-2]
      	at org.kie.server.remote.rest.jbpm.RuntimeDataResource.getTaskById(RuntimeDataResource.java:336) [kie-server-rest-jbpm-6.5.0.Final-redhat-2.jar:6.5.0.Final-redhat-2]
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_71]
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_71]
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_71]
      	at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_71]
      	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:168) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:561) [resteasy-jaxrs-2.3.13.Final-redhat-1.jar:]
      	... 20 more
      

      With this exception the client is throwing a 500 meaningless error. But the client should thrown a 404 error, such as(the following exception is thrown by other methods, such as `taskClient.getTaskInstance`):

      Exception in thread "main" org.kie.server.client.KieServicesException: Unexpected HTTP response code when requesting URI 'http://localhost:8180/kie-server/services/rest/server/containers/rewards/tasks/123456'! Error code: 404, message: Could not find task instance with id "123,456"
      	at org.kie.server.client.impl.AbstractKieServicesClientImpl.createExceptionForUnexpectedResponseCode(AbstractKieServicesClientImpl.java:551)
      	at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpGetRequestAndCreateCustomResponse(AbstractKieServicesClientImpl.java:189)
      	at org.kie.server.client.impl.UserTaskServicesClientImpl.getTaskInstance(UserTaskServicesClientImpl.java:759)
      	at reproducer.KieServerClientSample.main(KieServerClientSample.java:42)
      

      Attachments

        Issue Links

          Activity

            People

              swiderski.maciej Maciej Swiderski (Inactive)
              rhn-support-wsiqueir William Siqueira
              Karel Suta Karel Suta
              Karel Suta Karel Suta
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: