6 Replies Latest reply on Apr 23, 2014 12:35 PM by leonvdm2

    JBPM6 REST API Http Status 500

    leonvdm2

      I would like to use the JBPM6 REST API to get details of current processes. More specifically I am trying to get a list of all the tasks for each process that belongs to a user so that I can display the status of each task.

       

      I am using the url: http://localhost:8080//jbpm-console/rest/runtime/deploymentId/history/instance

      I get this exception:

       

      org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

              org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)

              com.sun.proxy.$Proxy183.getRequestHeaders(Unknown Source)

              org.kie.services.remote.rest.ResourceBase.getVariant(ResourceBase.java:118)

              org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:66)

              org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:25)

              sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

              sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

              sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

              java.lang.reflect.Method.invoke(Method.java:606)

              org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:44)

              org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

              org.kie.services.remote.rest.exception.DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.toResponse(DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.java)

              org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:324)

              org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:229)

              org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:123)

              org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

              org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

              javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

              org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

              org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)

              org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

              org.jbpm.designer.web.filter.impl.PluggableFilter.doFilter(PluggableFilter.java:70)

              org.uberfire.security.server.UberFireSecurityFilter.doFilter(UberFireSecurityFilter.java:266

       

      Currently testing it with SoapUI5.

        • 1. Re: JBPM6 REST API Http Status 500
          marco.rietveld

          Hi Leon,

           

          Which version/build are you using?

           

          This rings a vague bell, but I'm pretty sure that I fixed it.

          • 2. Re: JBPM6 REST API Http Status 500
            leonvdm2

            Hi Marco

             

            Appreciate your response.

             

            We are using 6.0.1FINAL.

             

            Best regards

             

            Leon

            • 3. Re: JBPM6 REST API Http Status 500
              marco.rietveld

              This seems to be the same problem as what's described here:

              https://issues.jboss.org/browse/RESTEASY-396

               

              Which appliation server are you running this on? (AS 7.1.1? EAP 6.1.1?)

              • 4. Re: JBPM6 REST API Http Status 500
                leonvdm2

                Hey Marco

                 

                AS 7.1.1.

                 

                It's the current demo install.

                 

                I just want to create a http client(org.apache) that can access the REST service for JBPM6.

                 

                Below is the code that ii am using.

                 

                Do I need to set another property in the header of my post perhaps?

                 

                public void getNodesForProcess() {

                  HttpClient httpClient = new DefaultHttpClient();

                  UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userId, password);

                  BasicScheme scheme = new BasicScheme();

                 

                  String deploymentId = "net.mtnbs.hosting.provisioning:Provisioning:1.0";

                  URL deploymentUrl = null;

                  try {

                       deploymentUrl = new URL("http://localhost:8080/jbpm-console");

                  } catch (MalformedURLException e) {

                  // TODO Auto-generated catch block

                  e.printStackTrace();

                  }

                 

                  String getProcessesRestCall = null;

                  try {

                       getProcessesRestCall = new URL(deploymentUrl, deploymentUrl.getPath() + "/rest/runtime/" + deploymentId + "/history/instance").toExternalForm();

                  } catch (MalformedURLException e) {

                  // TODO Auto-generated catch block

                  e.printStackTrace();

                  }

                 

                  try {

                  HttpPost httpPost = new HttpPost(getProcessesRestCall);

                  Header authorizationHeader = scheme.authenticate(credentials, httpPost);

                  httpPost.addHeader(authorizationHeader);

                  HttpResponse response = httpClient.execute(httpPost);

                  if (response != null) {

                       logger.info("Task Response status line: " + response.getStatusLine());

                  if (response.getStatusLine() != null) {

                       logger.info("Task Response status code: " + response.getStatusLine().getStatusCode());

                  }

                 

                  HttpEntity entity = response.getEntity();

                  String output = EntityUtils.toString(entity);

                  logger.info(output);

                // if (entity != null) {

                // createProcessInstancesResponse(output);

                // }

                  }

                  } catch (ClientProtocolException ex) {

                  ex.printStackTrace();

                  } catch (AuthenticationException ex) {

                  ex.printStackTrace();

                  } catch (Exception ex) {

                  ex.printStackTrace();

                  } finally {

                  }

                  }

                • 5. Re: Re: JBPM6 REST API Http Status 500
                  marco.rietveld

                  Hi Leon,

                   

                  Hmm.. I just took a fifth (seventh?) look at the stack trace and realized that the exception is being thrown on authentication. It's an edge case I hadn't thought about..

                   

                  In short, the exception is being thrown because your authentication is failing, as far as I can tell (although, I guess that was pretty obvious to you. :/ sorry).

                   

                  With regards to creating an (apache) based client, take a look this code here might help you (the org.kie.services.client.api.command.RemoteConfiguration.createPreemptiveAuthHttpClient(..) method). It's what I use underwater to take care of authentication and is apache based. Could you try to copy/paste/modify that code and see if it works for you?

                  • 6. Re: Re: JBPM6 REST API Http Status 500
                    leonvdm2

                    Thanks very much. On leave at the moment.

                     

                    Will let you know when I'm back at work.

                     

                    Thanks again

                     

                    Sent from my iPhone