关于JBPM4.3与现有SSH框架系统结合过程中数据库事务问题

关于JBPM4.3与现有SSH框架系统结合过程中数据库事务问题
1.
在这里插入图片描述

这里报错,NoSuchMethodError,表示方法找不到,定位所在的类是;复制类的全路径,快捷键ctrl+shift+t,查找类型,得到结果如下,就表示冲突的包;解决办法,依次打开3个类,肯定有一个类中有这个方法,那么这个包就是要保留的。
在这里插入图片描述
2.
下一个,观察发现,这个类是jbpm.jar中的类,jar包我们也有,在tomcat的发布目录查看都存在,这个类的路径中包含hibernate字样,说明它和hibernate有啥关系,所以有可能是上一步hibernate的包没有删除干净引起的。在这里插入图片描述
  如果做了JBPM4.4与Spring整合(使用了jbpm.tx.spring.cfg.xml),则在程序中就一定要使用Spring注入ProcessEngine,千万不能使用Configuration.getProcessEngine()生成ProcessEngine,因为这时内部的代码有以下逻辑:如果整合了Spring但没有ApplicationContext,就默认读取applicationContext.xml创建ApplicationContext实例并从中获取名为”ProcessEngine”的对象。而这时如果把pe = Configuration.getProcessEngine()写成某Spring中管理的bean的初始化代码,就会有无限循环,不停的创建ApplicationContext了!
  事务处理
  1.修改 jbpm.tx.hibernate.cfg.xml
不让jBPM自行管理事务:去掉< standard-transaction-interceptor />
让Jbpm使用 SessionFactory.getCurrentSession():修改为 < hibernate-session current="true" />

2.配置可以使用SessionFactory.getCurrentSession(),在jbpm.hibernate.cfg.xml 中配置:< property name="hibernate.current_session_context_class"> thread </ property>

3.要使用同一个SessionFactory,且都要使用SessionFactory.getCurrentSession() 获取 Session:
3.1同一个SessionFactory:SessionFactory sf = processEngine.get(SessionFactory.class)
3.2在 BaseDaoImpl 中增加:
3.2.1 getSession() { return HibernateUtils.getSessionFactory().getCurrentSession(); }
3.2.2 getProcessEngine(){ return org.jbpm.api.Configuration.getProcessEngine(); }
4.统一的打开与提交或回滚事务:使用 OpenSessionInViewFilter 控制事务。

猜你喜欢

转载自blog.csdn.net/weixin_44142296/article/details/85055661
今日推荐