8 Replies Latest reply on Dec 16, 2008 4:54 AM by Kyriakos Tsourapas

    posting data to an external web application

    Kamlesh Kumar Newbie

      Hi,

      I have to post some data to an external web page from the ActionHandler java class. So please tell me the way to do that by giving me small code snippet.

      Can i get the HttpServletRequest and HttpServletResponse objects in my ActionHandler class?

        • 1. Re: posting data to an external web application
          Kamlesh Kumar Newbie

          I have visited the blog http://weblogs.java.net/blog/edgars/archive/2007/08/understanding_j_1.html

          Here i found the way. But i am getting one exception while implementing that,

          My Servlet code is:

          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          // TODO Auto-generated method stub
          jbpmConfiguration= JbpmConfiguration.getInstance();
          JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
          try {

          GraphSession graphSession = jbpmContext.getGraphSession();

          ProcessDefinition processDefinition = graphSession.findLatestProcessDefinition("simplenodes");

          ProcessInstance processInstance =
          new ProcessInstance(processDefinition);
          //Added for XML Post
          processInstance.getContextInstance().setVariable("request", request);
          processInstance.getContextInstance().setVariable("response", response);
          //End of addition
          Token token = processInstance.getRootToken();

          // Let's start the process execution
          token.signal();

          //jbpmContext.save(processInstance);
          }
          finally
          {
          jbpmContext.close();
          }
          }

          But i am getting the following exception:

          message

          description The server encountered an internal error () that prevented it from fulfilling this request.

          exception

          javax.servlet.ServletException: Servlet execution threw an exception
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

          root cause

          java.lang.NoClassDefFoundError
          org.jbpm.context.exe.matcher.JcrNodeMatcher.class$(JcrNodeMatcher.java:33)
          org.jbpm.context.exe.matcher.JcrNodeMatcher.matches(JcrNodeMatcher.java:33)
          org.jbpm.context.exe.JbpmType.matches(JbpmType.java:53)
          org.jbpm.context.exe.VariableInstance.createVariableInstance(VariableInstance.java:86)
          org.jbpm.context.exe.VariableInstance.create(VariableInstance.java:65)
          org.jbpm.context.exe.VariableContainer.setVariableLocally(VariableContainer.java:173)
          org.jbpm.context.exe.VariableContainer.setVariable(VariableContainer.java:45)
          org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:212)
          org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:202)
          org.psl.IBMSaas.jbpm.CallWorkflowServlet.doGet(CallWorkflowServlet.java:48)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

          root cause

          java.lang.ClassNotFoundException: javax.jcr.Node
          org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
          org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
          java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
          java.lang.Class.forName0(Native Method)
          java.lang.Class.forName(Class.java:164)
          org.jbpm.context.exe.matcher.JcrNodeMatcher.class$(JcrNodeMatcher.java:33)
          org.jbpm.context.exe.matcher.JcrNodeMatcher.matches(JcrNodeMatcher.java:33)
          org.jbpm.context.exe.JbpmType.matches(JbpmType.java:53)
          org.jbpm.context.exe.VariableInstance.createVariableInstance(VariableInstance.java:86)
          org.jbpm.context.exe.VariableInstance.create(VariableInstance.java:65)
          org.jbpm.context.exe.VariableContainer.setVariableLocally(VariableContainer.java:173)
          org.jbpm.context.exe.VariableContainer.setVariable(VariableContainer.java:45)
          org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:212)
          org.jbpm.context.exe.ContextInstance.setVariable(ContextInstance.java:202)
          org.psl.IBMSaas.jbpm.CallWorkflowServlet.doGet(CallWorkflowServlet.java:48)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
          org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

          ****************
          So now please tell me what mistake i am doing. The exception comes at the line where i am setting the variables to the process instance....

          • 2. Re: posting data to an external web application
            Ronald van Kuijk Master

            classfiles missing.... the jcr ones (the exception clearly states this)

            • 3. Re: posting data to an external web application
              tixier cyrille Newbie

              i got the same problem

              i understand the class is missing, but why do we need jcr classes ?

              i previously work with jbpm processes without this jar

              • 5. Re: posting data to an external web application
                Ronald van Kuijk Master

                ??? jcr is not used in jBPM anymore.... What are you trying to do and with what version

                • 6. Re: posting data to an external web application
                  Kyriakos Tsourapas Newbie

                  I am using JBPM 3.1 and trying to load a HashMap which contains a custom class inside.

                  Do I have to upgrade JBPM ?
                  Is there a way to do this with the version I am working ?
                  We currently have several live deployments and it is not easy to upgrade to a new version right now.

                  Thanks

                  • 7. Re: posting data to an external web application
                    Ronald van Kuijk Master

                    First, it is a completely different issue then the topic. Use new topics for this from now on.

                    3.1 should have the jcr lib's in it. Where are you trying to load the hashmap from? From a jBPM processvariable?

                    • 8. Re: posting data to an external web application
                      Kyriakos Tsourapas Newbie

                      Hi,

                      If the libs were there, I wouldn't get the ClassNotFound Exception. I also looked with WinRar find in all of JBoss's jars and they are nowhere.

                      Actually, I was trying to put a class of mine inside a HashMap and put the HashMap inside the flow parameters.

                      Anyway, the problem was solved by having my class implement the Serializable interface.