13 Replies Latest reply on Oct 8, 2013 5:34 PM by bwallis42

    Structure of a kjar?

    bwallis42

      Is there any documentation on the structure of a kjar for jbpm6?

       

      What can I put in it and where does it go. I have bpmn files, rules files, java classes (for workitem handlers) and forms (ftl). I have no idea how I put these together into a kjar so it can be loaded into jbpm.

       

      thanks

        • 1. Re: Structure of a kjar?
          bwallis42

          I found https://github.com/droolsjbpm/drools/tree/master/drools-maven-plugin-example which is an example project that builds a kjar.  Based on that I now have a project that builds my kjar with similar contents. Now trying to get it to load to see if I got it right.

           

          I would still like to see some documentation on the structure of the kjar though. Documentation in general for 6.0.0 is sorely missed. Even a lot of the interfaces have no documentation in them (org.kie.api.runtime.manager.RuntimeEngine, org.jbpm.kie.services.api.DeploymentService, etc.) which is making porting from JBPM5 to JBPM6 very difficult particularly in the face of all the changes to the interface with the introduction of Kie.

           

          Don't get me wrong, from what I have learned with trial and error, the new interface looks great. It is just very hard and frustrating to learn how to use it.

           

          thanks.

          • 2. Re: Structure of a kjar?
            salaboy21

            The good thing about kjars is that the structure is just the same as a standard maven project structure. The only addition is the kmodule.xml file inside the main/resources/META-INF directory which allows drools and jbpm to scan that jar when its present in the class path. The kmodule.xml file allows you to configure different sessions and kbases for that kjar, but if the kmodule.xml file is empty a single session will be created picking up all the resources (rules, processes, etc) from the main/resources/ directory. This is the expected behavior in all maven projects.

             

            Hope this helps

            • 3. Re: Structure of a kjar?
              bwallis42

              Thanks,

               

              Can I put WorkItemHandler implementations (classes) in the kjar for the workitem nodes that the workflow requires? If so, what classloader is used, is it isolated to guard against class path issues?

              • 4. Re: Structure of a kjar?
                salaboy21

                The recommended way for workItemHandlers implementations is to place them in a separate jar inside WEB-INF/lib.. so a common classpath can be used.

                WorkItemHandlers are considered technical artefacts which should be decoupled from the release cycle of more business oriented artifacts like processes and rules.

                • 5. Re: Structure of a kjar?
                  bwallis42

                  Mauricio Salatino wrote:

                   

                  The recommended way for workItemHandlers implementations is to place them in a separate jar inside WEB-INF/lib.. so a common classpath can be used.

                  WorkItemHandlers are considered technical artefacts which should be decoupled from the release cycle of more business oriented artifacts like processes and rules.

                  Perhaps, but I don't think the workitem handler implementations should be coupled to the release of the application supporting the workflow. I don't have a WEB-INF as this isn't a web application (at least not the part running the workflow) so I assume you also mean the ear "lib" directory or as classes included within an ejb jar file.

                   

                  So I gather the answer is no, I can't put the classes in the kjar file.

                  • 6. Re: Structure of a kjar?
                    salaboy21

                    If you have an EAR you can place the workItemhandler implementation in the ear "lib" directory as you mention. I though that you were asking about console war, because the original question as about forms which are related with the kie-wb or jbpm console projects.

                    You can add the class to the kjar if you want. In that case the class loader that will be used will be the one that builds the ksession inside a kieContainer.

                    1 of 1 people found this helpful
                    • 7. Re: Structure of a kjar?
                      bwallis42

                      Is there a schema for the kmodule file? Hopefully with comments?

                      • 8. Re: Structure of a kjar?
                        salaboy21

                        Yes there is one, look at this example: https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test/resources/META-INF/kmodule.xml

                        here is the

                        Contributions are always welcome! (for the comments )

                        • 10. Re: Structure of a kjar?
                          bwallis42

                          Thanks for that, it helps to at least know what is allowed in the file even if I have to divine the meanings :-)

                          • 11. Re: Re: Structure of a kjar?
                            bwallis42

                            You can add the class to the kjar if you want. In that case the class loader that will be used will be the one that builds the ksession inside a kieContainer.

                            I tried a class in the kjar file

                             

                            % jar tfv target/kjar-1.0.jar
                                 0 Mon Oct 07 15:41:54 EST 2013 META-INF/
                               132 Mon Oct 07 15:41:52 EST 2013 M@ETA-INF/MANIFEST.MF@
                                 0 Mon Oct 07 15:41:50 EST 2013 au/
                                 0 Mon Oct 07 15:41:50 EST 2013 au/com/
                                 0 Mon Oct 07 15:41:50 EST 2013 au/com/infomedix/
                                 0 Mon Oct 07 15:41:50 EST 2013 au/com/infomedix/simpleflow/
                                 0 Mon Oct 07 15:41:50 EST 2013 au/com/infomedix/simpleflow/workitem/
                                 0 Mon Oct 07 15:41:48 EST 2013 icons/
                                 0 Mon Oct 07 15:41:48 EST 2013 Simple/
                              1720 Mon Oct 07 15:41:50 EST 2013 au/com/infomedix/simpleflow/workitem/TestWorkItem.class
                               317 Mon Oct 07 15:41:48 EST 2013 icons/Message.png
                                33 Mon Oct 07 15:41:48 EST 2013 META-INF/drools.rulebase.conf
                               278 Mon Oct 07 15:41:48 EST 2013 META-INF/kjar.wid
                               646 Mon Oct 07 15:41:48 EST 2013 META-INF/kmodule.xml
                               366 Mon Oct 07 15:41:48 EST 2013 pom.xml
                              4185 Mon Oct 07 15:41:50 EST 2013 Simple/simple.bpmn
                            

                             

                            with appropriate references in the kmodule.xml file. It doesn't work (ClassNotFound exception). If I copy the same class file to my war file (where everything is bundled) under WEB-INF/classes then it works as expected and I can use it in my workflow.

                             

                            I would really like to know if and how this can work. Most of our task specific classes would live in the main application (as you suggest) but sometimes a new or updated workitem would be required and having this available from within the deployed kjar that requires it would make this easy and nicely self contained. No application changes or updates and no restarts.

                            • 12. Re: Re: Structure of a kjar?
                              salaboy21

                              Hmm.. that could be because of the lack of beans.xml file inside the META-INF directory.. that will cause the jar to be excluded on the CDI parsing of classes.

                              Notice that you will solve just one problem, but will open the door to a whole of new ones. For example, if you allow to add those classes into your kjar you can end up with several definitions of the same class (and with different versions) in the same classloader. This is a problem related with java itself and not with jBPM in particular.

                              That's another reason why we recommend to place your workitem handler implementations in the WEB-INF/lib directory (or the one that applies to your deployment option).

                              • 13. Re: Structure of a kjar?
                                bwallis42

                                I'm well aware of class path issues being a long time jboss user :-)

                                 

                                It would be something that would have to be carefully managed and I agree that most of the workitems should probably be deployed with the application. I just need the option to sometimes add one at runtime without a restart/upgrade.

                                 

                                The class path issues could possibly be mitigated using a child class loader per workflow engine but I expect that could be a major change to the internals.