1.       问题1

a)       报错

                       i.             java.lang.NoClassDefFoundError:org/hibernate/impl/SessionImpl

b)       原因

                       i.             JBPM4默认使用的Hibernate3Hibernate4SessionImpl不再org/hibernate/impl包下

                     ii.             当引用此包时,就会导致找不到此类而报错;

c)       错误所在类

                       i.             在类org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor中使用到了该类;

d)      解决:

                       i.             找到源文件,修改SessionImpl的引用包为

                     ii.             importorg.hibernate.internal.SessionImpl;

2.       问题2

a)       报错

                       i.             java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session

b)       原因

                       i.             解决问题1,而附带出来的问题;

                     ii.             因为Hibernate3中有方法sessionFactory.openSession(Connection),而在Hibernate4中     则没有了此方法,从而导致找不到;

c)       错误所在类

                       i.             在类org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor中使用到了该类;

d)      解决方法1

                       i.             将该方法改为openSession(),不带参数;

                     ii.             缺点:

1.       每次都客气一个session,浪费;

e)       解决方法2

                       i.             将该方法改为getCurrentSession(),同时*.cfg.xml中添加

                thread

                     ii.             缺点:

1.       可能导致问题Session was already closed

3.       问题3

a)       报错

                 i.             Session was already closed

b)       原因

                       i.             使用了getCurrentSession()方法获取session

                     ii.             可能当前还没有创建好session,而进行获取,从而导致的错误;

c)       错误所在类

                       i.             在类org.jbpm.pvm.internal.wire.descriptor.HibernateSessionDescriptor中使用到了该类;

d)       解决方法1

                       i.             换做openSession()

e)       解决方法2(还没有实践):

                       i.             使用getCurrentSession()获取session

                     ii.             如果整合Spring的话,使用Spring注入不出错;

4.       问题4

a)       错误

                       i.             java.lang.NoSuchMethodError:org.hibernate.Hibernate.createBlob([B)Ljava/sql/Blob;      at org.jbpm.pvm.

b)       原因

                       i.             JBPM4.4中使用的Hibernate3Hibernate.createBlob()方法创建Blob大数据对象;

                     ii.             Hibernate4中取消了此方法,所以会导致找不到该方法;

c)       错误所在类

                   i.             org.jbpm.pvm.internal.lob.BlobStrategyBlob

d)      解决方法1

                       i.             找到错误的类;

                     ii.             使用Hibernate4中提供的LobHelper#createBlob(bytes)方法生成Blob对象;

                   iii.             该类为SessionImpl类的内部类,需要通过SessionFactory对象获取到该类,在通过session#getLobHelper()方法获取

e)       SessionFactory对象的获取:

                       i.             通过直接读取Spring配置文件获取;(注入报空指针)

ApplicationContextfactory = new
ClassPathXmlApplicationContext("applicationContext.xml");
SessionFactory sessionFactory =(SessionFactory)factory.getBean("sessionFactory");
LobHelperlobHelper =
sessionFactory.openSession().getLobHelper();

                     ii.             直接代码生成

public LobHelpergetLogHelper(){   
        Configuration configuration =new Configuration();
        configuration.configure("jbpm.hibernate.cfg.xml");
        org.hibernate.service.ServiceRegistryserviceRegisy =
                new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()) .build();
        SessionFactory sessionFactory=
                configuration.buildSessionFactory(serviceRegisy);
        LobHelper lobHelper =  sessionFactory.openSession().getLobHelper();
        return lobHelper;
    }

5.       错误6

a)       报错

                       i.             Error creating bean with name 'processEngine' defined in ServletContext resource [/WEB-INF/config/applicationContext_jbpm.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine()] threw exception; nested exception is java.lang.NullPointerException

b)       原因

                       i.             在使用Spring4的时候,JBPM默认生成SpringProcessEngine类的时候,引用的是import org.springframework.orm.hibernate3.LocalSessionFactoryBean;包下的类;

c)       解决:

                       i.             该为引用hibernate4的包

6.       问题6

a)       报错

                       i.             获取SessionFactory的时候为空

b)       原因

                       i.             使用的是注入的SessionFactory,每次确实注入了,但不知为什么获取不到;

c)       解决:

                       i.             org.jbpm.pvm.internal.lob.BlobStrategyBlob类中,直接读取Spring配置文件,获取SessionFactory,从而创建需要的实例

ApplicationContextfactory = new ClassPathXmlApplicationContext("applicationContext.xml");
SessionFactory sessionFactory =(SessionFactory)factory.getBean("sessionFactory");
LobHelper lobHelper =sessionFactory.openSession().getLobHelper();

7.       问题7

a)       报错

                       i.             org.springframework.dao.DataIntegrityViolationException:Could not execute JDBC batch update; SQL [delete

b)       原因

                       i.             JBPM4.4整合Spring后,所使用的数据库方言问题,

c)       解决

        

org.hibernate.dialect.MySQL5Dialect

改为

org.hibernate.dialect.MySQL5InnoDBDialect

 

参考了http://lijiejava.iteye.com/blog/1934927,如果整合的是Spring3可以参考下;