11 Replies Latest reply on Dec 27, 2010 6:43 AM by shambhu.sinha

    How to deploy bar files ?

    newbeewan

      Hi,

       

      I'm currently developping a application to integrate JBPM in some portlets.

       

      I want to create some feature to permit deployement in the portlet.

       

      As the bar file format seem to be the ad hoc format, I'm looking for example to deploy it directly !

       

      I have integrated JBPM 4.3 in spring, and I would use that to deploy some business process.

       

      Is there an article or examples for that ?

       

      Thanks a lot

        • 1. Re: How to deploy bar files ?
          swiderski.maciej

          Hi,

           

          you could use following code to deploy it directly assuming that process engine is already configured:

           

              NewDeployment deployment = repositoryService.createDeployment();
              deployment.setName(processFile.getName());
              deployment.setTimestamp(System.currentTimeMillis());
              if (processFile.getName().endsWith(".xml")) {
          
                deployment.addResourceFromFile(processFile);
              } else if (processFile.getName().endsWith("ar")) {
                  FileInputStream fileInputStream = new FileInputStream(processFile);
                  ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
                  deployment.addResourcesFromZipInputStream(zipInputStream);
          
              } 
          

          Where processFile is File instance representing your process.

           

          HTH

          Maciej

          • 2. Re: How to deploy bar files ?
            bestage

            I have successfully deployed the .bar like described above.

            It deployed all my custom classes needed to serialize/deserialize my BLOB values.


            Somehow jbpm still throws "class not found" exception, although I am using jbpm 4.2 where the problem has been fixed (JBPM-2200 in JIRA).

            Also the user guide suggests that this is the right way to make custom user classes available -> by adding .class files to .bar.

             

            Has anyone experienced the same problem?

            • 3. Re: How to deploy bar files ?
              newbeewan

              Hi,

               

              I think that you are expected to load also classes in that way.

               

              AFAIK, the purpose of bar files is to deploy processes only and your must add jar contaning your classes in your classpath or using a classloader to load it !

               

              Regards

              • 4. Re: How to deploy bar files ?
                bestage

                no, the user guide states you should add your custom .class files to BAR, so they are deployed together with the process definition.

                 

                http://docs.jboss.org/jbpm/v4/userguide/html_single/#deployingbusinessarchives

                 

                The point is, I need my custom classes not because I am using those in my process definition, but because I am saving some serializable variables which need to be deserialized. This deserialization is not possible in another application (admin tool in my case), I am getting "class not found" error.

                I presume this functionality is simply not supported and I have to include the .jar with my custom classes to my classpath.

                But this is not so nice, because I also deployed those.class files to jbpm database. Do you get my point?

                • 5. Re: How to deploy bar files ?
                  swiderski.maciej

                  Hi,

                   

                  classes that are included in bar archive are supported by jBPM runtime. Once they are loaded t the database they will be available.

                   

                  Please not that classes must be included on the root of your archive, for instance:

                  /META-INF

                  /com/company/MyClass.class

                   

                  HTH

                  Maciej

                  • 6. Re: How to deploy bar files ?
                    bestage

                    Hi Maciej,

                     

                    thanks for your reply. What you wrote was the same thing I expected.

                     

                    My process.bar looks like this:

                     

                    process.jpdl.xml

                    process.png

                    com/company/EntityClass1.class

                    com/company/EntityClass2.class
                    META-INF/    <= empty manifest file....

                    ...

                     

                     

                    Now the follorwing happens:

                     

                    • Application A persists serialiazable Entity of EntityClass1.
                    • Application B (admin tool) wants to load all variables and show them. It cannot deserialize my variable Entity as it cannot find the class EntityClass1.

                     

                    Now I have seen the class named DeploymentClassLoader which installs  the Deplyment class loader to ThreadLocal. But that doesn't seem to happen when you are working with variables. I guess this feature is used only with Activities, at least in jbpm 4.3.

                     

                    Regards,

                    • 7. Re: How to deploy bar files ?
                      swiderski.maciej

                      Does it work for Application A to load the variables?

                      • 8. Re: How to deploy bar files ?
                        bestage

                        sure, because the classes are in the classpath of Project A.

                        If I put my process.bar as a jar on classpath of Project B it works too.

                        But I wanted to avoid this. Because like this for every new process I would have to re-deploy my admin tool application.

                         

                        Also: have a look at this JIRA issue. It refers to JBPM 3.x but describes the same problem.

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

                         

                        I am almost convinced now that jBPM 4.3 doesn't support class loading for user classes deployed within a BAR file.

                        • 9. Re: How to deploy bar files ?
                          swiderski.maciej

                          could you please upload your process that illustrates that?

                           

                          I would like to give it a try and play around with it for a while. It is very interesting issue that needs to be verified.

                           

                          In general user code is working fine when it is deployed to data base (I use it all the time) but as you wrote perhaps it works only for activities but not for variables.

                           

                          Cheers,

                          Maciej

                          • 10. Re: How to deploy bar files ?
                            shambhu.sinha

                            Hi,

                             

                            Did you find any solution to this problem? Actually I am also adding client classes in .bar to call EJB that is configured in Process Definition. But it seems jBPM does not load classes for deployment using *.bar file. If I put these classes in classpath where jBPM is deployed then it’s working fine.

                             

                            Please reply me if I need to do some workaround or any reference to follow correct process of deployment.

                             

                            Thanks in advance.

                             

                            Regards,

                            Shambhu

                            • 11. Re: How to deploy bar files ?
                              shambhu.sinha

                              Hi,

                               

                              This is related with my above post and would like to say that deploying PD as bar file works fine in JBoss 5.1.0 but it does not work in glassfish v3.

                              Can anyone please let me know that if there is anything I need to do here to fix this issue.

                               

                              Thanks,

                              Shambhu