1 2 Previous Next 20 Replies Latest reply on May 3, 2011 9:06 AM by dhamaris

    IdentityService implementation

    herbst

      Hi,

      I'm trying to integrate jBPM in an existing projekt. This Projekt allredy has an user-management which should be used. So I tried to implement the IdentitySession with the methods from interface and change the jbpm.cfg.xml like shown on http://docs.jboss.com/jbpm/v4/devguide/html_single/#customizingtheidentitycomponent

       

      Ok, implementation done, jbpm.cfg.xml done.

      Now starting the processEngine tells me that it seams like it still uses the original IdentitySession from org.jbpm.pvm.internal.svc.IdentityServiceImpl.

      I tried to remove my own class an leave the entry in the cfg, so i could see if the config is parsed correctly (yes it is).

       

      So what am I doing wrong ?

       

      Hope someone knows/thanks for all reply

      Sebastian Herbst

        • 1. Re: IdentityService implementation
          rebody

          Hi Sebastian,

           

            Did you delete jbpm.identity.cfg.xml from jbpm.cfg.xml?

           

            If you could show us the final version of your configuration,  it will help us to get more details to help you.

          • 2. Re: IdentityService implementation
            herbst

            So her is my jbpm.cfg.xml

             

            <?xml version="1.0" encoding="UTF-8"?>
            
            <jbpm-configuration>
            
              <import resource="jbpm.default.cfg.xml" />
              <import resource="jbpm.tx.hibernate.cfg.xml" />
              <import resource="jbpm.jpdl.cfg.xml" />
              <import resource="jbpm.bpmn.cfg.xml" />
            
              <transaction-context>
                <object class="jBPM.JBPMIdentitySession" />
              </transaction-context>
            
              <import resource="jbpm.businesscalendar.cfg.xml" />
              <import resource="jbpm.console.cfg.xml" />
              <import resource="jbpm.jobexecutor.cfg.xml" />
            
            </jbpm-configuration>
            

             

            I'm not sure if I'm mixing it up, but in order to get my own user-management running, is it necessary to implement the IdentitySession , the IdentityService, or both or something else ?

            • 3. Re: IdentityService implementation
              mwohlf

              The IdentityService wraps the IdentitySession with transaction/command semantics, your custom IdentitySession should run fine within the jBPM4 IdentityService, the implementation of IdentityService looks up the IdentitySession implementation and should find your class unless somewhere is a hardcoded reference to the original jBPM4 class, can you be more specific where you get the wrong IdentitySession?

              • 4. Re: IdentityService implementation
                swiderski.maciej

                Sebastian, please find attached complete test for custom IdentitySession. Of course it is not a real case for IdentitySession use case but just to illustrate what needs to be done to make it to work.

                It uses in memory identity store to be able to execute test.

                 

                While running any method invokation of CustomIdentitySession will print line - just to visualize that jBPM runtime uses it.

                 

                HTH

                Maciej

                • 5. Re: IdentityService implementation
                  herbst

                  Hello,

                  thanks to all of your for the help.

                  Maybe I'm in the wrong component for that what I'm trying to do. My goal is to use the task-node from jpdl with the candidate-users - tag ( see example)

                   

                  <task candidate-users="admin,blub" g="388,100,92,52" name="task4">
                        <transition g="-45,-20" name="toEnd1" to="end1"/>
                  </task>
                  

                   

                  to check if the current user is allowed to assign to this task. So my question is which interfaces do i have to implement ?

                  Thanks to Maciej I managed to set up a working IdentitySession, but when I'm running a task with tag mentioned above it crashes with an error

                  (java.lang.ClassNotFoundException: de.odysseus.el.util.SimpleResolver)

                   

                  So as long I'm using nodes wihtout that tag everything works fine. In every node i do the following 2 steps:

                   

                  taskService.takeTask(task.getId(), "admin")
                  taskService.completeTask(task.getId(), transitionName);
                  
                  • 6. Re: IdentityService implementation
                    swiderski.maciej

                    Seems like your test is missing juel libraries on the class path.

                     

                    Btw, I tested my sample case with candidate-users as well and it works as expected. Originally it was candidate-groups.

                    • 7. Re: IdentityService implementation
                      herbst

                      Hi,

                      I've tried to see when this error happens exactly. It allways appears, when the processdefinition node contains candidate-user/group. As long this tag is missing findPersonalTasks(..), takeTask or completeTask work fine. When it comes to a node containing ths tags it crashes with the following error. I don't see why this is happening. (I don't want to use the juel libary because it conflicts with some other of my libaries)

                       

                      Java:

                       taskService.takeTask(task.getId(), "admin");//user.getName());
                       System.out.println("admin : " + taskService.findPersonalTasks("admin").toString());
                       System.out.println(taskService.getOutcomes(task.getId()).toString() + " <-- " + transitionName);
                       taskService.completeTask(task.getId(), transitionName);     //here it crashes(nextState(TaskJbpmProcess.java:121)
                      

                       

                      Error:

                      javax.servlet.ServletException: Servlet execution threw an exception
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
                          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
                          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
                          at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          at web.SessionInfoFilter.doFilter(SessionInfoFilter.java:159)
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
                          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
                          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
                          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
                          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
                          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
                          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
                          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
                          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
                          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
                          at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
                          at java.lang.Thread.run(Unknown Source)
                      Caused by: java.lang.NoClassDefFoundError: de/odysseus/el/util/SimpleResolver
                          at org.jbpm.pvm.internal.script.JuelScriptEngineFactory.getScriptEngine(JuelScriptEngineFactory.java:185)
                          at javax.script.ScriptEngineManager.getEngineByName(Unknown Source)
                          at org.jbpm.pvm.internal.script.ScriptManager.evaluate(ScriptManager.java:111)
                          at org.jbpm.pvm.internal.script.ScriptManager.evaluateExpression(ScriptManager.java:90)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.resolveAssignmentExpression(ExecutionImpl.java:772)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.initializeAssignments(ExecutionImpl.java:735)
                          at org.jbpm.jpdl.internal.activity.TaskActivity.execute(TaskActivity.java:95)
                          at org.jbpm.jpdl.internal.activity.TaskActivity.execute(TaskActivity.java:58)
                          at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:656)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:616)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:417)
                          at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:403)
                          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                          at java.lang.reflect.Method.invoke(Unknown Source)
                          at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:157)
                          at org.jbpm.pvm.internal.model.ExecutionImpl$$EnhancerByCGLIB$$b8b5633c.signal(<generated>)
                          at org.jbpm.pvm.internal.task.TaskImpl.complete(TaskImpl.java:194)
                          at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:65)
                          at org.jbpm.pvm.internal.cmd.CompleteTaskCmd.execute(CompleteTaskCmd.java:32)
                          at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
                          at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
                          at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
                          at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
                          at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
                          at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
                          at org.jbpm.pvm.internal.svc.TaskServiceImpl.completeTask(TaskServiceImpl.java:96)
                          at jBPM.TaskJbpmProcess.nextState(TaskJbpmProcess.java:121)
                          at jBPM.TaskJbpmProcess.processAction(TaskJbpmProcess.java:79)
                          at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
                          at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:746)
                          at javax.faces.component.UICommand.broadcast(UICommand.java:368)
                          at org.ajax4jsf.component.AjaxActionComponent.broadcast(AjaxActionComponent.java:55)
                          at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)
                          at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:304)
                          at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)
                          at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:474)
                          at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
                          at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
                          at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
                          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
                          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
                          ... 20 more
                      
                      • 8. Re: IdentityService implementation
                        swiderski.maciej

                        Sebastian Herbst wrote:

                         

                        Hi,

                        I've tried to see when this error happens exactly. It allways appears, when the processdefinition node contains candidate-user/group. As long this tag is missing findPersonalTasks(..), takeTask or completeTask work fine. When it comes to a node containing ths tags it crashes with the following error. I don't see why this is happening. (I don't want to use the juel libary because it conflicts with some other of my libaries)

                        It happens because assignment (assignee, candidate-groups, candidate-users) can be given as expression that must be evaluated on runtime.

                         

                        Since you don't/can't use juel in your system I would recommend you create your own implementation of ScriptEngine that will do the evaluation for you instead of the default one based on juel. You need to specify what language shall be used for evaluation and you can do that with another attribute for task activity:

                        - assignee-lang

                        - candidate-users-lang

                        - candidate-groups-lang

                         

                        Another way could be to used other that are already defined:

                        - bsh

                        - groovy

                         

                        HTH

                        • 9. Re: IdentityService implementation
                          herbst

                          I've found a way just to use the juel-imp so that the error is now gone. Now I'm trying to assign a user to a task with:

                           

                          TaskService().takeTask(task.getId(), "admin");
                          

                           

                          Node:

                           

                          <task candidate-users="blub" g="264,324,92,52" name="task5">
                                <transition g="-46,-20" name="toTask1" to="task1"/>
                                <transition g="-45,-20" name="toEnd1" to="end1"/>
                          </task>
                          

                          So why is it possible to assign this node to "admin" ?

                          Should this not result in an error or something to determine that it didn't work ?

                          • 10. Re: IdentityService implementation
                            mwohlf

                            it seems like neither the

                            TaskService().takeTask([...]);

                            nor the

                            TaskService().assignTask([...]);

                            methods check if the assigned user is in the candidate list,

                            moreover you can even assign a user that doesn't exist:

                            TaskService().takeTask(task.getId(), "rumpelstiltskin");

                            and jBPM4 won't complain

                            • 11. Re: IdentityService implementation
                              swiderski.maciej

                              Michael, complete true. In fact both rely on the same code.

                               

                              Will file jira issue and provide fix for it within few days.

                               

                              If it comes to checking if the user exists, there are already few jira issues related to that. One of the explanation why it was not implemented yet was to wait until JBossIDM IdentitySession will be finished.

                              I was about to provide a fix for that that will check with currently available IdentitySession if user exists before assigning.

                               

                              If you think that is of a big value for you please put a vote on them. One of the issues:

                              https://jira.jboss.org/browse/JBPM-2698

                              • 12. Re: IdentityService implementation
                                walterjs

                                Hi Maciej,

                                 

                                I'm not so sure this is a good idea. It might be perfectly valid to assign a task to a user that is not in the candidate group. For example, all the users in the candidate group are unavailable and the process owner reassigns the task to a temp. It is easy enough to query the candidate group and limit the assignment to them only if that is the desired functionality for your application/process.

                                 

                                Cheers

                                Walter

                                • 13. Re: IdentityService implementation
                                  swiderski.maciej

                                  Hi Walter,

                                   

                                  I agree if it comes to assignment but not really to taking the task. It could be/is kind of a gap in the api, anyone could "steel" any task by just using the jBPM API.

                                   

                                  I forgot to mention I was planning to do configurable, meaning that you can turn on/off such validation the same if it comes to validation if user exists or not.

                                   

                                  Let me know what do you think.

                                   

                                  Cheers,

                                  Maciej

                                  • 14. Re: IdentityService implementation
                                    mwohlf

                                    I agree with Walter, I think the API should be as simple as possible and verfiying that the user exists or the user is in the candidate group should be the application/caller's responsibility not the API's.

                                    If you throw an exception for any kind of "wrong" assignment of a task the application layer has to implement some kind of additional logic to catch this exception, it is probably the same amount of code you need to check beforehand if the assignment is valid...

                                    But this are just my 2c...

                                    1 2 Previous Next