9 Replies Latest reply on Jul 19, 2006 5:45 AM by viegas

    jbpmContext null pointer

    viegas

      Hello, Im trying to create a webapp to run with JBPM, so far I just have a login that verifies a user and then tries to set the actorId of the jbpmContext to that same user. I have a servlet that executes the following code

      String userName = req.getParameter("userName");
      JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
      jbpmContext.setActorId(userName);
      context.getRequestDispatcher("/mainPage.jsp").forward(req, resp);
      


      the problem I have is that whenever the execution gets to: "jbpmContext.setActorId" trows a exception nullPointerException, I guess its the jbpmContext but I dont know why.

        • 1. Re: jbpmContext null pointer
          newbie007

          Hi,

          May be userName from request is coming null?

          Check the html source of login page to see if that is the name of the
          dropdown (user list drop down) or look at the browser address bar to see
          if that is parameter passed to server.

          Hope that helps.

          Thanks.

          • 2. Re: jbpmContext null pointer
            newbie007

            Where is "context" defined? I hope it is not another JBPMContext type
            variable defined as null.

            String userName = req.getParameter("userName");
            JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
            jbpmContext.setActorId(userName);
            context.getRequestDispatcher("/mainPage.jsp").forward(req, resp);

            • 3. Re: jbpmContext null pointer
              viegas

               

              "newbie007" wrote:
              Where is "context" defined? I hope it is not another JBPMContext type
              variable defined as null.

              String userName = req.getParameter("userName");
              JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
              jbpmContext.setActorId(userName);
              context.getRequestDispatcher("/mainPage.jsp").forward(req, resp);


              Hello, thanks for the reply, first the "username" is not null, I have verified that.
              About the context, I am not defining it, I thougt that it would get the context of the server. How can I define it?

              thanks.

              • 4. Re: jbpmContext null pointer
                kukeltje

                use JbpmConfiguration.

                • 5. Re: jbpmContext null pointer
                  hosierdm

                  More specifically, you should basically always do something like this:

                  JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
                  try
                  {
                   // do some stuff using the context
                  }
                  finally
                  {
                   jbpmContext.close();
                  }
                  


                  • 6. Re: jbpmContext null pointer
                    kukeltje

                    but do the JbpmConfiguration.getInstance() as little as possible, since it is SLOW. The jBPM webapp does it once!

                    creating the context can be done lots of times, since it is FAST.

                    • 7. Re: jbpmContext null pointer
                      hosierdm

                      Right, I was just trying to simplify the example...sorry. :)

                      • 8. Re: jbpmContext null pointer
                        kukeltje

                        No problem... I'm just preventing a 'jBPM is slow' situation ;-)

                        We've had a guy test jBPM once via the (at that time) realy slow webapp. Wrong, wrong, wrong... but straightening that out was lots of work... proving the core was fast...

                        • 9. Re: jbpmContext null pointer
                          viegas

                          thanks a lot, the command "JbpmConfiguration.getInstance().createJbpmContext();" as solved the problem, but how do I create the context.
                          and by the wat, whats the function of the context?? Im a newbie...

                          THANKS