8 Replies Latest reply on May 10, 2009 3:25 AM by Bogumil Zieba

    java.lang.NoClassDefFoundError: javax/transaction/Synchroniz

    M. S. Newbie

      Hello,

      I'm trying to run an example from the jBPM jPDL 3.2 User Guide. I have changed the database example a little bit so that the jUnit assertions are just some System.out.println and the program is starting by an public static void main.

      Nice so far. But the main problem is to get all the necessary libraries to run this simple class. I have added a lot of jars now, but there is still an exception occurring.

      The following exception occurs when i try to deploy the process definition with the following code:

       JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
       try {
       jbpmContext.deployProcessDefinition(processDefinition);
       } finally {
       jbpmContext.close();
       }
      


      The exception:
      Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/Synchronization
       at org.hibernate.impl.SessionImpl.<init>(SessionImpl.java:213)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:473)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:497)
       at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:505)
       at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:97)
       at org.jbpm.persistence.db.DbPersistenceService.getGraphSession(DbPersistenceService.java:234)
       at org.jbpm.JbpmContext.getGraphSession(JbpmContext.java:539)
       at org.jbpm.JbpmContext.deployProcessDefinition(JbpmContext.java:173)
       at scr.own.ProcessWork.deploy(ProcessWork.java:91)
       at scr.own.ProcessWork.testProcess(ProcessWork.java:71)
       at scr.own.ProcessWork.main(ProcessWork.java:37)
      


      It would be great if someone can tell me what to do!! Or is there somebody who just can tell me what libs I need to run this tutorial example?

      thanks in advance
      lou

        • 1. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
          David Roberts Apprentice

          I had the same problem when first trying out my "test" class. I used all the libraries that the deployment chapter in the JBPM documentation said you should use. I havent quite yet figured out exactly what library it needs, but I sorted it out for now by using all the files in the lib dir, from the jbpm-jpdl-suite-3.2.1 download. It worked fine after that, and I will let you know what lib it is when I have time to find out exactly which one it needs. In the mean time, here is my list of libraries:

          activation.jar
          antlr-2.7.6.jar
          asm.jar
          bsh.jar
          cglib.jar
          commons-collections.jar
          commons-logging.jar
          dom4j.jar
          hibernate.cfg.xml
          hibernate3.jar
          hsqldb.jar
          jboss-backport-concurrent.jar
          jboss-j2ee.jar
          jboss-retro-1.1.0-rt.jar
          jbpm-identity.jar
          jbpm-jpdl.jar
          jbpm.cfg.xml
          jcr-1.0.jar
          junit.jar
          mail.jar
          mysql-connector-java-5.0.3-bin.jar
          servlet-api.jar
          


          • 2. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
            M. S. Newbie

            Thanks for this first help.

            The NoClassDefFoundError is gone and the class seems to run some seconds longer. But another exception occurs - as usual. :-/

            The exception:


            Table not found in statement [select top ? processdef0_.ID_ as ID1_4_, processdef0_.NAME_ as NAME3_4_, processdef0_.DESCRIPTION_ as DESCRIPT4_4_, processdef0_.VERSION_ as VERSION5_4_, processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN6_4_, processdef0_.STARTSTATE_ as STARTSTATE7_4_ from JBPM_PROCESSDEFINITION processdef0_ where processdef0_.NAME_=? order by processdef0_.VERSION_ desc]

            org.hibernate.exception.SQLGrammarException: could not execute query
            at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
            at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
            at org.hibernate.loader.Loader.doList(Loader.java:2223)
            (...)

            Seems like there is a problem with the database, but I don't know where. I thought i read that the tables would be created automatically. Is that right?
            Can someone help me with this issue.

            BTW:
            I'm of course using the config files hibernate.cfg.xml and jbpm.cfg.xml from the /config folder of the jbpm-jpdl-3.2.1 download. I think that should be all right.

            thanks again
            lou

            • 3. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
              David Roberts Apprentice

              As far as I know, the database tables are not created automatically, and you can use the scripts in the jbpm-jpdl-3.2.1/db directory to create the tables you need. That depends on your database of course. But if you are using the default hsqldb, and not your own (eg MySQL), then I'm not sure if the tables are created automatically or not. You should look around the Wiki, that generally explains what you need to do. Try the Getting Started guide. Or maybe someone else can help you with this problem. Good luck!

              • 4. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
                M. S. Newbie

                Hmm, right.

                The database tables are not created autmatically. At least not until you write an additional property to the hibernate.cfg.xml file. I have found a smal section about this in the User Guide.

                7.6.2. The jBPM DB schema:
                http://docs.jboss.com/jbpm/v3/userguide/persistence.html#thejbpmdbschema"

                So far so good.
                I have added this property and ran the class again. The deployment seems to work. There is no exception at this point any longer. But now - I got another exception (Of course!) and I don't know what to do. It allways occurses when I try to close a JBPMContext in the following way: jbpmContext.close();

                The exception:


                problem closing service 'persistence'
                org.jbpm.JbpmException: no jbpm tx service configured
                at org.jbpm.persistence.db.DbPersistenceService.isRollbackOnly(DbPersistenceService.java:390)
                at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:212)
                at org.jbpm.svc.Services.close(Services.java:222)
                at org.jbpm.JbpmContext.close(JbpmContext.java:139)

                Seems like there is something wrong with that 'tx service'. I have investigated a long time, but still have no idea what this tx service is about. I found a class called org.jbpm.tx.TxService but there is no real description about this class or even the hole package.

                Maybe there is someone out there who can tell me how to fix this problem and what this "tx service" is about. I really would like to know! :)

                thank!
                lou

                • 5. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
                  M. S. Newbie

                  It works!!

                  I finally changed the tutorial code the following way.
                  The problem was how the JbpmConfiguration was created. In the tutorial there was parsed an hard coded xml string to generate the configuration:

                  jbpmConfiguration = JbpmConfiguration.parseXmlString(
                   "<jbpm-configuration>" +
                  
                   " <jbpm-context>" +
                   " <service name='persistence' " +
                   " factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
                   " </jbpm-context>" +
                  (...)
                  

                  But when I changed this part to a simple invokation of the getInstance() methode everything worked fine.
                  jbpmConfiguration = JbpmConfiguration.getInstance();
                  

                  I wonder if the tutorial code is really buggy at this point. That would be pretty bad!! Or if I did something different so that the configuration initialisation went wrong.

                  @dleerob
                  thank again! :)

                  bye, lou

                  • 6. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
                    Karsten Dakenzschke Newbie

                     

                    "dleerob" wrote:

                    activation.jar
                    antlr-2.7.6.jar
                    asm.jar
                    bsh.jar
                    cglib.jar
                    commons-collections.jar
                    commons-logging.jar
                    dom4j.jar
                    hibernate.cfg.xml
                    hibernate3.jar
                    hsqldb.jar
                    jboss-backport-concurrent.jar
                    jboss-j2ee.jar
                    jboss-retro-1.1.0-rt.jar
                    jbpm-identity.jar
                    jbpm-jpdl.jar
                    jbpm.cfg.xml
                    jcr-1.0.jar
                    junit.jar
                    mail.jar
                    mysql-connector-java-5.0.3-bin.jar
                    servlet-api.jar
                    


                    Dependant on where you deploy it to (in my case Tomcat) you also need jta.jar. This jar contains javax.transaction.Synchronization. It is not needed when you deploy to jboss as.

                    • 7. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
                      David Roberts Apprentice

                      Aah, well spotted, thanks. Lucky for me my application already uses hibernate seperate to the JBoss libs, and when it's built it copies across jta.jar to my tomcat lib directory, so I didn't even notice it was missing.

                      • 8. Re: java.lang.NoClassDefFoundError: javax/transaction/Synchr
                        Bogumil Zieba Newbie

                        This tutorial is STILL very buggy. Thank you all for your contris to get me thorugh this!
                        Bless!
                        /b