12 Replies Latest reply on Mar 25, 2010 1:08 PM by v.lepretre

    New version of process with modification in java class : the change is not taken into account

    v.lepretre

      Hi,

       

      I'm using jBPM 4.3 on JBoss 5.1.0 and Oracle 10g

       

      I've performed the jBPM installation with the following ant tasks :

      ant -Ddatabase=oracle -Djboss.version=5.1.0.GA -Djbpm.home=%JBPM_HOME% -Djboss.home=%JBOSS_HOME% create.jbpm.schema
      ant -Ddatabase=oracle -Djboss.version=5.1.0.GA -Djbpm.home=%JBPM_HOME% -Djboss.home=%JBOSS_HOME% install.jbpm.into.jboss

       

      I've deployed the jBPM examples using ant task :
      ant -Ddatabase=oracle -Djboss.version=5.1.0.GA -Djbpm.home=%JBPM_HOME% -Djboss.home=%JBOSS_HOME% install.examples.into.jboss

       

      I've written an small web application (deployed on the same Jboss server as jBPM) and using the jBPM service (processEngine obtained with the getProcessEngine API) able to start the "Async" process and it works fine.

       

      I modify the Async process just by adding some output in Application.java

       

      public void generatePdf() {
         System.out.println("generatePdf");
      }

      public void calculatePrimes() {
         System.out.println("calculatePrimes");
      }

       

      and then I deploy.

       

      When I start the new version of "Async", i see the correct outputs in the logs.

       

      Now my problem :

       

      I've written a small process "Test2"

       

      <?xml version="1.0" encoding="UTF-8"?>
      <process name="test2" xmlns="http://jbpm.org/4.3/jpdl">

       

          <start name="start"
                 g="32,49,88,30">
               <transition name="toJava1" to="java1" g="-29,-26"/>
          </start>

       

          <java name="java1" class="com.cadwin.jbpm.process.test2.Java1" method="display">
              <transition name="toEnd" to="end"/>
          </java>
         
          <end name="end"  g="185,507,48,48"/>
      </process>

       


      package com.cadwin.jbpm.process.test2;
      public class Java1 {
          public void display() {
              System.out.println("Java1");
          }
      }

       

      I deploy it with the same ant task as for "Async"
      I start it from my web application, and It works fine (correct output in the log)

       

      I modify the java1.java(just adding one more output)

       

      package com.cadwin.jbpm.process.test2;
      public class Java1 {
          public void display() {
              System.out.println("Java1");
              System.out.println("Java1");
          }
      }

       

      I deploy and when I start the new version of "Test2" process I see only one output in the log. (Exactly as if the process continue to use the previous version of java1.java)
      If I add another output in java1.java and deploy again, I continue to see only one output in the log.

       

      Could you help me to fix that problem?

       

      PS :

       

      If I modify the "Test2" process as follow


      <java name="java1" class="com.cadwin.jbpm.process.test2.Java1_1" method="display">
             <transition name="toEnd" to="end"/>
      </java>

       

      and if i copy je java1.java to java1_1.java and I deploy, the new version of process displays the two outputs.

        • 1. Re: New version of process with modification in java class : the change is not taken into account
          swiderski.maciej

          hi,

           

          in general, user code is cached for process definition. But since you deploy it you should get new version of the process definition:

          - first deploy = test2-1

          - second deploy = test2-2

          .

          .

          .

          So when you start new instance of a process test2-2 you should get correct results.

           

          I have not experienced that behavior not even once, but did the same stuff many times. What I could suggest is to give it a try and look through data base and check if there are different classes for different deployments, you could use repositoryService as well to get it out.

           

          And of cource to make sure you are executing correct version of your process definition, I am sure you have done that, just to double check the most obvious.

           

          Cheersm

          Maciej

          • 2. Re: New version of process with modification in java class : the change is not taken into account
            v.lepretre

            Hi Maciej, first thanks for your answer.

             

            I've added in my web application some logs to check I use the good process version.There's no mistake here.

            I've added a "spy" to get the resources files of a deployment (with repositoryService), the files are ok.

             

            When I check in the database (blobs of JBPM_LOB table), the Java1 source is the good one

            public class Java1 {
                 public void display() {
                    System.out.println("Java1");
                     System.out.println("Java1");
                }
            }

             

            but the process continues to display only one output.

             

            Another information, if I remove all deployments (using undeployCascade) and deploy "Test2" again, the process continues to display only one output. It seems to me that the Java1 is cached.

             

            I've written few processes and this problem not occurs on each one.

             

            Thanks for your help.

            • 3. Re: New version of process with modification in java class : the change is not taken into account
              swiderski.maciej

              That sounds like a tricky one

               

              Did you try to run it from console?

              Perhaps you could post some code so I could try to look into it in a spare time.

               

              Cheers,

              Maciej

              • 4. Re: New version of process with modification in java class : the change is not taken into account
                v.lepretre

                Hi Maciej,

                 

                Yes, I've tested the process from my web application and from the console. In each case, the process behaviour is the same.

                 

                I send you a zip with three files (a process definition and two java classes). It's a very simple process, just calling one java class.

                 

                Copy the content in the %JBPM_HOME%\examples\src folder and perform

                 

                ant -Ddatabase=oracle -Djboss.version=5.1.0.GA -Djbpm.home=%JBPM_HOME% -Djboss.home=%JBOSS_HOME% install.examples.into.jboss

                 

                then test the process "Test2".

                 

                I was not able to find exactly when the problem occurs (maybe combination with deployment and undeployment), but if you change and deploy several times the Java1 classe (just add a new System.out) at one moment the process will use the previous version of Java1 classe.

                 

                Thanks for your help

                • 5. Re: New version of process with modification in java class : the change is not taken into account
                  swiderski.maciej

                  Hi,

                   

                  will take a look at your process later today and post back results.

                   

                  Have you tried to use different way of deploying processes? I use ant task jbpm-deploy that deploys everything without running container. There is another post where I uploaded by build.xml file that I am using to deploy. perhaps it is worth trying as well.

                   

                  Cheers,

                  Maciej

                  • 6. Re: New version of process with modification in java class : the change is not taken into account
                    swiderski.maciej

                    Hi Valery,

                     

                    I did try your case and everything works as expected. My test environment is different though.

                    I use Tomcat 6 with Hsqldb and as I mentioned before I do deploy directly to data base without container and the execute processes using BPM console.

                     

                    If you import examples from jBPM distribution to your eclipse, you will find example build.xml that deploys everything directly into db and the you can us it on already running process engine.

                     

                    If you like I can post complete eclipse project with deployment setup (for hsqldb but it is just a matter of changing hibernate connection settings).

                     

                    Cheers,

                    Maciej

                    • 7. Re: New version of process with modification in java class : the change is not taken into account
                      v.lepretre

                      Hi Maciej,

                       

                      Thanks for your time spent on that subject.

                      I'll be very pleased if you could send me your Eclipse project.

                       

                      Today, I'll try to test my processes with Hsqldb instead of Oracle.

                       

                      Few minutes ago, one of my colleagues has seen the same problem as me (he just changes the java code in a class, then deploys,  but the process still use the previous java class - the java source in the database lob is correct).

                       

                      Few questions :

                       

                      What do you mean exactly by : I do deploy directly to data base without container

                      What are the java classes used by jbpm? the classes in the database lobs or the classes contained in the jar copied to userlibs?

                       

                       

                      Thanks again

                       

                      Valéry

                      • 8. Re: New version of process with modification in java class : the change is not taken into account
                        swiderski.maciej

                        What do you mean exactly by : I do deploy directly to data base without container

                        I mean that I deploy my resources directly to data base using ant task, pretty the same as test cases do. So application server is not involved at all. I suspect that this is the case for you. That either classes or class loaders are cached somehow...

                        What are the java classes used by jbpm? the classes in the database lobs or the classes contained in the jar copied to userlibs?

                        I would say that these that are stored in data base but as your case illustrates it is not always true. Since either way class loaders are involved it is probably issue with them. If classes are not available for application server (not placed in userlibs) then the only one is to load them from LOB.

                         

                        Have you tried to stop the server, copy jar to user libs and start server again? Perhaps that would make a difference.

                         

                        Attached eclipse project with your test case that I tried yesterday.

                         

                        Cheers,

                        Maciej

                        • 9. Re: New version of process with modification in java class : the change is not taken into account
                          v.lepretre

                          Hi Maciej,

                           

                          Thanks for the zip. I'll look in it as soon as  possible.

                           

                           

                          I mean that I deploy my resources directly to data base using ant task,  pretty the same as test cases do. So application server is not involved  at all. I suspect that this is the case for you. That either classes or  class loaders are cached somehow...

                          Yes,  I do the same. Direct writing in the database with Ant. I suppose too it's a cache problem.

                           

                          I would say that these that are stored in data base but as your case  illustrates it is not always true. Since either way class loaders are  involved it is probably issue with them. If classes are not available  for application server (not placed in userlibs) then the only one is to  load them from LOB.

                          Does it mean the java code is read from the LOB and compiled before it's use?

                           

                          I've done the following test (still with JBoss 5.1.0 and with Oracle & HSQLDB)

                           

                          I deploy my famous "Test2" process

                          I stop the JBoss server

                          I remove the jar file from userlibs

                          I restart JBoss and run Test2 (the process works)

                          With a query, I set to null (empty) the LOB corresponding to the Java1 class

                          I run Test2, it's Ok

                          I stop and start JBoss

                          I run Test2, it's Ok (Wow)

                          With a query, I set to null (empty) the LOB corresponding to the process definition.

                          I run Test2, and I get a beautiful "org.jbpm.api.JbpmException" (which seems normal)

                           

                          So I think it's a problem related to JBoss (cache), but I don't know where to look to fix that problem. Have you an idea?

                           

                          Thanks again for your time

                           

                          Valéry

                           

                           

                           


                          • 10. Re: New version of process with modification in java class : the change is not taken into account
                            v.lepretre

                            Hi Maciej,

                             

                            I don't undestand one thing :

                             

                            If you use the examples ant task to deploy processes, the database LOB contain the source java code (.java)

                            In the eclipse project that you sent to me, the ".bar" file contains the compiled classes (.class)

                             

                            What is the good way?

                             

                            Best regards,

                             

                            Valéry

                            • 11. Re: New version of process with modification in java class : the change is not taken into account
                              swiderski.maciej

                              Hi,

                               

                              in my opinion LOB should contain class files since I think jBPM will look up for classes not source while executing activities.

                               

                              Cheers,

                              Maciej

                              1 of 1 people found this helpful
                              • 12. Re: New version of process with modification in java class : the change is not taken into account
                                v.lepretre

                                Hi Maciej,

                                 

                                I totally agree with you.

                                Very strange, it works with java sources in LOBs.

                                 

                                Regards,

                                 

                                Valéry