1 2 Previous Next 15 Replies Latest reply on May 15, 2008 1:01 PM by kukeltje

    How to start a deployed process from a jsp file?

    coolex

      Hello!

      I created a new project in my Eclipse. There I created processes and I created there my WebContent with JSP files. I deployed everything on the jBoss jBPM Server.
      Now I want to start the deployed process from this JSP file.
      To do this I created a method in my jsp like this:

      public void startHelloWorldProcess() {
      
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(new FileInputStream(
       "processes/HelloWorld/processdefinition.xml"));
      
      
       ProcessInstance processInstance =
       new ProcessInstance(processDefinition);
      
       Token token = processInstance.getRootToken();
      
      
       token.signal();
      
       }
      %>

      Unfortunately I get an error that the file does not exist (FileNotFoundException).
      My directory structure looks like this:
      http://farm3.static.flickr.com/2358/2491603347_65c6a37765.jpg?v=0

      Thanks for helping!

      Alex

        • 1. Re: How to start a deployed process from a jsp file?
          kukeltje

          if it says it is not there (where it expects it) it is not there. try to determine where it is realy trying to load it from

          • 2. Re: How to start a deployed process from a jsp file?
            salaboy21

            you should look at the war archive that you are generating...then from there take the real path..

            • 3. Re: How to start a deployed process from a jsp file?
              coolex

              Well, I even copied the xml file in the same directory where I have my jsp file but I get the same error (file not found).
              Is there any other possibility how to start a process from a jsp file?

              • 4. Re: How to start a deployed process from a jsp file?
                salaboy21

                keep trying and looking.. because it is not a jBPM problem.. is a resource problem.. because you can not find a file..

                • 5. Re: How to start a deployed process from a jsp file?
                  coolex

                  So, this is the right way how to start a process from an jsp file?

                  • 6. Re: How to start a deployed process from a jsp file?
                    salaboy21

                    in my opinion you should try to use a MVC approach, so you can start the process in a servlet..

                    • 7. Re: How to start a deployed process from a jsp file?
                      coolex

                      As for beginning I want to avoid MVC. I want to use MVC later. For now I just want to start a simple process that is already deployed on the server. I want to do this from a jsp or servlet file. That's it. But I cannot find any help how to start doing this.

                      • 8. Re: How to start a deployed process from a jsp file?
                        kukeltje

                         

                        So, this is the right way how to start a process from an jsp file?

                        it is one of the ways it can be done

                        • 9. Re: How to start a deployed process from a jsp file?
                          coolex

                          Where can I find hints how to start a process in a different way?
                          Or what are other possibilities how to start it?

                          • 10. Re: How to start a deployed process from a jsp file?
                            coolex

                            OK, I'm trying now to execute the following code:

                            private void startProcessDefinition() {
                             String processDefinitionName = new String("websale");
                             JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
                             JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                             try {
                             GraphSession graphSession = jbpmContext.getGraphSession();
                             ProcessDefinition definition = graphSession.findLatestProcessDefinition(processDefinitionName);
                             ProcessInstance instance = definition.createProcessInstance();
                             instance.signal();
                             jbpmContext.save(instance);
                             } finally {
                             jbpmContext.close();
                             }
                            }

                            "Websale" is the standard jBPM process that is already deployed on the server. Now I just want to start it with the help of this method that is in my jsp file.
                            Now I don't get any errors but also nothing happens I mean that I don't see in the jbpm-console that the process has been started.

                            • 11. Re: How to start a deployed process from a jsp file?
                              kukeltje

                              - via a servlet
                              - via a timer (quartz?)
                              - via a jsf backingbean
                              - via an mdb
                              - via an esb

                              and then all these combination with
                              - load xml from a file
                              - load xml from an inputstream
                              - load xml from a database
                              - via the java api

                              • 12. Re: How to start a deployed process from a jsp file?
                                coolex

                                Ok, thank you so far.
                                Now I created a new JSP file that looks like this:

                                <%@ page import="org.jbpm.*" %>
                                <%@ page import="org.jbpm.graph.def.*" %>
                                <%@ page import="org.jbpm.graph.exe.*" %>
                                <%@ page import="org.jbpm.db.GraphSession" %>
                                
                                <%!
                                private void startProcessDefinition() {
                                 String processDefinitionName = new String("websale");
                                 JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance();
                                 JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
                                 try {
                                 GraphSession graphSession = jbpmContext.getGraphSession();
                                 ProcessDefinition definition = graphSession.findLatestProcessDefinition(processDefinitionName);
                                 ProcessInstance instance = definition.createProcessInstance();
                                 instance.signal();
                                 jbpmContext.save(instance);
                                 } finally {
                                 jbpmContext.close();
                                 }
                                }
                                %>
                                
                                <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
                                 pageEncoding="ISO-8859-1"%>
                                <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                                <html>
                                <head>
                                <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                                <title>Insert title here</title>
                                </head>
                                <body>
                                <% startProcessDefinition();%>
                                </body>
                                </html>

                                But when I execute it I get this error:
                                org.apache.jasper.JasperException: Unable to load class for JSP
                                org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
                                org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
                                org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                                org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                                javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                                org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                                root cause

                                org.apache.jasper.JasperException: Unable to load class for JSP
                                org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:598)
                                org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147)
                                org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:315)
                                org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                                org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                                javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                                org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                                root cause

                                java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
                                java.net.URLClassLoader$1.run(Unknown Source)
                                java.security.AccessController.doPrivileged(Native Method)
                                java.net.URLClassLoader.findClass(Unknown Source)
                                org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:133)
                                org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:65)
                                org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:596)
                                org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:147)
                                org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:315)
                                org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
                                org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
                                javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
                                org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

                                Any idea why this error arise?

                                • 13. Re: How to start a deployed process from a jsp file?
                                  kukeltje

                                  look in the logging of the server there is most likely more info there.

                                  btw, this is very 'old school' in developing webapps... Might I suggest ditching jsp and going for jsf with facelets, much cleaner

                                  • 14. Re: How to start a deployed process from a jsp file?
                                    coolex

                                    Thank you kukeltje for the hint. The reason I did this is that I just want start a processes without creating a perfect code. So, now I'm only concentrating on the process start from this jsp. That's all.
                                    Unfortunately it still not working. I watched the log file of the server. There are almost the same infos like I've already posted in here.
                                    So, please does anybody have an idea how to start the process. Maybe you can post a sample code.

                                    1 2 Previous Next