请教大神,org.jbpm.api.JbpmException: couldn'tandroid acquiree block of ids时lobvar.diff怎么用

jbpm4.4默认用的是hibernate3,如果要使用hibernate4整合,则要覆写一些类,一共3个,如图:
1、BlobStrategyBlob.java
package org.jbpm.pvm.internal.
import java.sql.SQLE
import org.apache.struts2.ServletActionC
import org.hibernate.H
import org.hibernate.LobH
import org.hibernate.S
import org.hibernate.SessionF
import org.hibernate.internal.SessionI
import org.jbpm.api.JbpmE
import org.springframework.beans.factory.annotation.A
import org.springframework.context.ApplicationC
import org.springframework.stereotype.R
import org.springframework.web.context.WebApplicationC
import org.springframework.web.context.support.WebApplicationContextU
public class BlobStrategyBlob implements BlobStrategy {
public void set(byte[] bytes, Lob lob) {
if (bytes != null) {
lob.cachedBytes =
ApplicationContext ac =
WebApplicationContextUtils.getWebApplicationContext(ServletActionContext.getServletContext());
SessionFactory sessionFactory = (SessionFactory)ac.getBean(&sessionFactory&);
Session session = sessionFactory.getCurrentSession();
lob.blob = session.getLobHelper().createBlob(bytes);
public byte[] get(Lob lob) {
if (lob.cachedBytes != null) {
return lob.cachedB
java.sql.Blob sqlBlob = lob.
if (sqlBlob != null) {
return sqlBlob.getBytes(1, (int) sqlBlob.length());
} catch (SQLException e) {
throw new JbpmException(&couldn't extract bytes out of blob&, e);
2、SpringProcessEngine.java
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
* T you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software F either version 2.1 of
* the License, or (at your option) any later version.
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License alon if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
USA, or see the FSF site: http://www.fsf.org.
package org.jbpm.pvm.internal.
import java.util.P
import org.hibernate.cfg.C
import org.springframework.context.ApplicationC
import org.springframework.context.annotation.B
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.support.ClassPathXmlApplicationC
import org.springframework.orm.hibernate4.LocalSessionFactoryB
import org.jbpm.api.ProcessE
import org.jbpm.internal.log.L
import org.jbpm.pvm.internal.cfg.ConfigurationI
import org.jbpm.pvm.internal.env.EnvironmentI
import org.jbpm.pvm.internal.env.PvmE
import org.jbpm.pvm.internal.env.SpringC
import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectD
* this environment factory will see only the singleton beans.
* The created {@link SpringEnvironment}s will see the prototype beans and it will cache them.
* @author Andries Inze
public class SpringProcessEngine extends ProcessEngineImpl {
private static final Log log = Log.getLog(SpringProcessEngine.class.getName());
private static final long serialVersionUID = 1L;
private ApplicationContext applicationC
public static ProcessEngine create(ConfigurationImpl configuration) {
SpringProcessEngine springProcessEngine =
ApplicationContext applicationContext =
if (configuration.isInstantiatedFromSpring()) {
applicationContext = (ApplicationContext) configuration.getApplicationContext();
springProcessEngine = new SpringProcessEngine();
springProcessEngine.applicationContext = applicationC
springProcessEngine.initializeProcessEngine(configuration);
LocalSessionFactoryBean localSessionFactoryBean = springProcessEngine.get(LocalSessionFactoryBean.class);
Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
springProcessEngine.processEngineWireContext.getWireDefinition().addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));
springProcessEngine.checkDb(configuration);
String springCfg = (String) configuration.getProcessEngineWireContext().get(&spring.cfg&);
if (springCfg == null) {
springCfg = &applicationContext.xml&;
applicationContext = new ClassPathXmlApplicationContext(springCfg);
springProcessEngine = (SpringProcessEngine) applicationContext.getBean(&processEngine&);
return springProcessE
public EnvironmentImpl openEnvironment() {
PvmEnvironment environment = new PvmEnvironment(this);
if (log.isTraceEnabled())
log.trace(&opening jbpm-spring& + environment);
environment.setContext(new SpringContext(applicationContext));
installAuthenticatedUserId(environment);
installProcessEngineContext(environment);
installTransactionContext(environment);
@SuppressWarnings(&unchecked&)
public &T& T get(Class&T& type) {
T candidateComponent = super.get(type);
if (candidateComponent != null) {
return candidateC
String[] names = applicationContext.getBeanNamesForType(type);
if (names.length &= 1) {
if (names.length & 1 && log.isWarnEnabled()) {
log.warn(&Multiple beans for type & + type + & found. Returning the first result.&);
return (T) applicationContext.getBean(names[0]);
public Object get(String key) {
if (applicationContext.containsBean(key)) {
return applicationContext.getBean(key);
return super.get(key);
3、HibernateSessionDescriptor.java
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
* T you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software F either version 2.1 of
* the License, or (at your option) any later version.
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License alon if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
USA, or see the FSF site: http://www.fsf.org.
package org.jbpm.pvm.internal.wire.
import java.sql.C
import org.hibernate.S
import org.hibernate.SessionF
import org.hibernate.internal.SessionI
import org.jbpm.internal.log.L
import org.jbpm.pvm.internal.env.EnvironmentI
import org.jbpm.pvm.internal.tx.HibernateSessionR
import org.jbpm.pvm.internal.tx.StandardT
import org.jbpm.pvm.internal.wire.WireC
import org.jbpm.pvm.internal.wire.WireD
import org.jbpm.pvm.internal.wire.WireE
* @author Tom Baeyens
public class HibernateSessionDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
private static final Log log = Log.getLog(HibernateSessionDescriptor.class.getName());
protected String factoryN
protected boolean useCurrent =
protected boolean tx =
protected boolean close =
protected String standardTransactionN
protected String connectionN
public Object construct(WireContext wireContext) {
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
if (environment == null) {
throw new WireException(&no environment&);
// get the hibernate-session-factory
SessionFactory sessionFactory =
if (factoryName != null) {
sessionFactory = (SessionFactory) wireContext.get(factoryName);
sessionFactory = environment.get(SessionFactory.class);
if (sessionFactory == null) {
throw new WireException(&couldn't find hibernate-session-factory & + (factoryName != null ? &'& + factoryName + &'& : &by type &) + &to open a hibernate-session&);
// open the hibernate-session
Session session =
if (useCurrent) {
if (log.isTraceEnabled())
log.trace(&getting current hibernate session&);
session = sessionFactory.getCurrentSession();
} else if (connectionName != null) {
Connection connection = (Connection) wireContext.get(connectionName);
if (log.isTraceEnabled())
log.trace(&creating hibernate session with connection & + connection);
session = (Session) sessionFactory.openStatelessSession(connection);
if (log.isTraceEnabled())
log.trace(&creating hibernate session&);
session = sessionFactory.openSession();
StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
if (standardTransaction != null) {
HibernateSessionResource hibernateSessionResource = new HibernateSessionResource(session);
standardTransaction.enlistResource(hibernateSessionResource);
public Class&?& getType(WireDefinition wireDefinition) {
return SessionImpl.
public void setFactoryName(String factoryName) {
this.factoryName = factoryN
public void setTx(boolean tx) {
public void setStandardTransactionName(String standardTransactionName) {
this.standardTransactionName = standardTransactionN
public void setConnectionName(String connectionName) {
this.connectionName = connectionN
public void setUseCurrent(boolean useCurrent) {
this.useCurrent = useC
public void setClose(boolean close) {
this.close =
这样执行过程中就不会报错不兼容了,主要是将用到3的地方更换为4即可,其他配置请参考其他文章。
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:9966次
排名:千里之外
原创:17篇
转载:10篇
(1)(1)(1)(4)(4)(13)(3)jbpm4 hibernate3 spring2 在获取session时出现 org.jbpm.api.JbpmException_百度知道
jbpm4 hibernate3 spring2 在获取session时出现 org.jbpm.api.JbpmException
jbpm.EnvironmentI&gt. value=&请问高手到底是哪里出现的问题.jbpm.IdentitySessionIimport resource=&quot。.IdentitySessionImpl&& /
&lt。;(IdentitySessionImpl.transaction-context&gt.xml&quot.session = BasicE
&import resource=&jbpm-configuration&import resource=&quot.transaction-context&
&lt.cfg.java。:&lt.class); &#47.cfg.xml&&gt.JbpmException.biz.pvm.getFromCurrent(EnvironmentImpl: no environment to get org.env.cfg.object class=&quot.impl.hibernate-session current=& encoding=&
&init&gt.xml&quot.
&lt.xml中是这样配置的;
&lt.xml&& /true&quot.jbpm.jbpm.spring.bpmn:org.cfg.Session&#47.api.forever.getFromCurrent(EnvironmentIobject&gt.java.&&#47:203)&applicationCUTF-8& /process-engine-context&import resource=&string name=&
&&org.leave..&#47.import resource=&quot. / &#47.xml&quot.xml&
&lt.getFromCurrent(Session。运行时出现错误.0&
at org?xml version=&quot.&
&&gt?&gt.cfg&import resource=&quot.jbpm.xml&&lt.
};.cfg,如何解决啊使用自己定义的用户认证IdentitySessionImpl implements IdentitySession {
protected S
public IdentitySessionImpl() {&gt:21)我在&process-engine-context&gt.businesscalendar.xml&quot.
& &#47.jobexecutor.EnvironmentI&jbpm-configuration& /
&/jbpm.import resource=&quot
我有更好的答案
检查相关包是否已导入,还有配置文件检查是否有错误
其他类似问题
为您推荐:
jbpm4的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁jBPM(三):Spring 集成 jBPM4.3 (jBPM4+Hibernate4) -
- ITeye技术网站
博客分类:
Spring 集成 jBPM4.3 主要工作有2点:
1. 将jbpm默认的hibernate事务换成spring事务,即在jbpm.cfg.xml文件中将
&import resource="jbpm.tx.hibernate.cfg.xml" /&
&import resource="jbpm.tx.spring.cfg.xml" /&
2. jBPM的核心控件processEngine由Spring生成、管理。
这2方面的内容,网上有很多资料查询,但基本都是在xml文件中进行配置,而我是在之前的代码中集成jBPM,之前的代码采用的是注解的方式(Spring注解,Hibernate注解),所以采用编码的方式获得了processEngine对象,即:
@Bean(name="processEngine")
@DependsOn("sessionFactory")
public ProcessEngine getProcessEngine() throws Exception{
processEngine = new ConfigurationImpl().springEnabled()
.setHibernateSessionFactory(this.getSessionFactory())
.springInitiated(applicationContext)
.buildProcessEngine();
return processE
从上述代码中可以看到,生成processEngine对象需要设置SessionFactory对象。查看jBPM4.3源码SpringProcessEngine.java类,发现其获取的是LocalSessionFactoryBena对象,而我在代码中采用的是注解方式,所以生成的是AnnotationSessionFactoryBean对象,即:
@Bean(name="annotationSessionFactoryBean")
@DependsOn("dataSource")
public AnnotationSessionFactoryBean getAnnotationSessionFactoryBean() throws Exception {
Properties properties = new Properties();
properties.put("hibernate.dialect", dialect);
properties.put("hibernate.show_sql", showSql);
properties.put("hibernate.hbm2ddl.auto", hbm2ddl);
properties.put("hibernate.max_fetch_depth", max_fetch_depth);
properties.put("hibernate.temp.use_jdbc_metadata_defaults", "false");
properties.put("hibernate.jdbc.fetch_size", "50");
properties.put("hibernate.jdbc.batch_size", "25");
AnnotationSessionFactoryBean a = new AnnotationSessionFactoryBean();
a.setDataSource(this.getDataSource());
a.setHibernateProperties(properties);
a.setPackagesToScan(models.split(","));
// jbpm文件
a.setMappingResources(new String[]{"jbpm.repository.hbm.xml","jbpm.execution.hbm.xml","jbpm.history.hbm.xml","jbpm.task.hbm.xml","jbpm.identity.hbm.xml"});
a.afterPropertiesSet();
解决的办法是在本地源码中新建一个对应的SpringProcessEngine类,用以覆盖jBPM源码。修改其中的代码,获取AnnotationSessionFactoryBean对象。以下是修改的create方法:
public static ProcessEngine create(ConfigurationImpl configuration) {
SpringProcessEngine springProcessEngine =
ApplicationContext applicationContext =
if (configuration.isInstantiatedFromSpring()) {
applicationContext = (ApplicationContext) configuration.getApplicationContext();
springProcessEngine = new SpringProcessEngine();
springProcessEngine.applicationContext = applicationC
springProcessEngine.initializeProcessEngine(configuration);
原先的代码
LocalSessionFactoryBean localSessionFactoryBean = springProcessEngine.get(LocalSessionFactoryBean.class);
Configuration hibernateConfiguration = localSessionFactoryBean.getConfiguration();
springProcessEngine.processEngineWireContext
.getWireDefinition()
.addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));
springProcessEngine.checkDb(configuration);
// 将LocalSessionFactoryBean 换成 AnnotationSessionFactoryBean
AnnotationSessionFactoryBean annotationSessionFactoryBean = springProcessEngine.get(AnnotationSessionFactoryBean.class);
Configuration hibernateConfiguration = annotationSessionFactoryBean.getConfiguration();
springProcessEngine.processEngineWireContext
.getWireDefinition()
.addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true));
springProcessEngine.checkDb(configuration);
String springCfg = (String) configuration.getProcessEngineWireContext().get("spring.cfg");
if (springCfg==null) {
springCfg = "applicationContext.xml";
applicationContext = new ClassPathXmlApplicationContext(springCfg);
springProcessEngine = (SpringProcessEngine) applicationContext.getBean("processEngine");
return springProcessE
本地新建的类:
lb250028 写道chenjl 写道楼主,还有一个问题想请问你一下。
//1.布署流程
RepositoryService repositoryService = processEngine
.getRepositoryService();
ZipInputStream zis = new ZipInputStream(this.getClass()
.getResourceAsStream("/omaterial.zip"));
repositoryService.createDeployment()
.addResourcesFromZipInputStream(zis).deploy();
/** ExecutionService接口,用来管理流程实例
ExecutionService executionService = processEngine.getExecutionService();
我在布署流程的时候,读入zip文件,DEBUG进去发现BlobStrategyBlob这个类中,使用Hibernate.createBlob(bytes);这个在hibernate4中是没有。请问一下要怎么修改呢?还有JBPM4.4集成hibernate4还会出现什么问题呢?谢谢!!同楼主提到的方法一样,重写org/jbpm/pvm/internal/lob/BlobStrategyBlob 类,因为原代码中使用的是hibernate3的Hibernate.createLob(),这个方法在h4中已经取消了,可以使用 session.getLobHelper() 得到一个帮助类操作Bolb。我使用的是Spring注入SessionFactory 然后获取currentSession,暂时没出现什么问题 ,有其他方法的同学可以交流探讨下.我是通过看HIBERNATE3中源码发现,Hibernate.createLob()相当于NonContextualLobCreator.INSTANCE.wrap(NonContextualLobCreator.INSTANCE.createBlob(bytes))但是在之后使用的过程中发现仍然会抛出异常java.lang.AbstractMethodError at mons.dbcp.DelegatingPreparedStatement.setBinaryStream(DelegatingPreparedStatement.java:318) at mons.dbcp.DelegatingPreparedStatement.setBinaryStream(DelegatingPreparedStatement.java:318)不知道该怎么解决··我也这样操作,org/jbpm/pvm/internal/lob/BlobStrategyBlob重写了,添加了一个SessionFactory成员变量,setter方法,然后通过Spring配置中注入SessionFactory了,但是为什么没有注入进去呢,总是空呢
chenjl 写道楼主,还有一个问题想请问你一下。
//1.布署流程
RepositoryService repositoryService = processEngine
.getRepositoryService();
ZipInputStream zis = new ZipInputStream(this.getClass()
.getResourceAsStream("/omaterial.zip"));
repositoryService.createDeployment()
.addResourcesFromZipInputStream(zis).deploy();
/** ExecutionService接口,用来管理流程实例
ExecutionService executionService = processEngine.getExecutionService();
我在布署流程的时候,读入zip文件,DEBUG进去发现BlobStrategyBlob这个类中,使用Hibernate.createBlob(bytes);这个在hibernate4中是没有。请问一下要怎么修改呢?还有JBPM4.4集成hibernate4还会出现什么问题呢?谢谢!!同楼主提到的方法一样,重写org/jbpm/pvm/internal/lob/BlobStrategyBlob 类,因为原代码中使用的是hibernate3的Hibernate.createLob(),这个方法在h4中已经取消了,可以使用 session.getLobHelper() 得到一个帮助类操作Bolb。我使用的是Spring注入SessionFactory 然后获取currentSession,暂时没出现什么问题 ,有其他方法的同学可以交流探讨下.我是通过看HIBERNATE3中源码发现,Hibernate.createLob()相当于NonContextualLobCreator.INSTANCE.wrap(NonContextualLobCreator.INSTANCE.createBlob(bytes))但是在之后使用的过程中发现仍然会抛出异常java.lang.AbstractMethodError at mons.dbcp.DelegatingPreparedStatement.setBinaryStream(DelegatingPreparedStatement.java:318) at mons.dbcp.DelegatingPreparedStatement.setBinaryStream(DelegatingPreparedStatement.java:318)不知道该怎么解决··
楼主,还有一个问题想请问你一下。
//1.布署流程
RepositoryService repositoryService = processEngine
.getRepositoryService();
ZipInputStream zis = new ZipInputStream(this.getClass()
.getResourceAsStream("/omaterial.zip"));
repositoryService.createDeployment()
.addResourcesFromZipInputStream(zis).deploy();
/** ExecutionService接口,用来管理流程实例
ExecutionService executionService = processEngine.getExecutionService();
我在布署流程的时候,读入zip文件,DEBUG进去发现BlobStrategyBlob这个类中,使用Hibernate.createBlob(bytes);这个在hibernate4中是没有。请问一下要怎么修改呢?还有JBPM4.4集成hibernate4还会出现什么问题呢?谢谢!!同楼主提到的方法一样,重写org/jbpm/pvm/internal/lob/BlobStrategyBlob 类,因为原代码中使用的是hibernate3的Hibernate.createLob(),这个方法在h4中已经取消了,可以使用 session.getLobHelper() 得到一个帮助类操作Bolb。我使用的是Spring注入SessionFactory 然后获取currentSession,暂时没出现什么问题 ,有其他方法的同学可以交流探讨下.
你好,请问一下,我用的是hibernate4,在集成jbpm4.4的时候,报如下异常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine' defined in class path resource [spring-hibernate.xml]: Instanti nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine()] nested exception is java.lang.NoClassDefFoundError: org/hibernate/impl/SessionImpl 按照你的方法,新建了一个类SpringProcessEngine类,覆盖了jBPM源码。
public static ProcessEngine create(ConfigurationImpl configuration) {
SpringProcessEngine springProcessEngine =
ApplicationContext applicationContext =
if (configuration.isInstantiatedFromSpring()) {
applicationContext = (ApplicationContext) configuration
.getApplicationContext();
springProcessEngine = new SpringProcessEngine();
springProcessEngine.applicationContext = applicationC
springProcessEngine.initializeProcessEngine(configuration);
LocalSessionFactoryBean localSessionFactoryBean = springProcessEngine
.get(LocalSessionFactoryBean.class);
Configuration hibernateConfiguration = localSessionFactoryBean
.getConfiguration();
springProcessEngine.processEngineWireContext.getWireDefinition()
.addDescriptor(
new ProvidedObjectDescriptor(
hibernateConfiguration, true));
springProcessEngine.checkDb(configuration);
String springCfg = (String) configuration
.getProcessEngineWireContext().get("spring.cfg");
if (springCfg == null) {
springCfg = "applicationContext.xml";
applicationContext = new ClassPathXmlApplicationContext(springCfg);
springProcessEngine = (SpringProcessEngine) applicationContext
.getBean("processEngine");
return springProcessE
这里的LocalSessionFactoryBean是org.springframework.orm.hibernate4.LocalSessionFactoryB不清楚问题出在哪里,请指教一下,谢谢。org/hibernate/impl/SessionImpl 是Hibernate3中的,Hibernate4中是org.hibernate.internal.SessionImpl 。 jbpm4中默认是hibernate3,我看了源码是在HibernateSessionDescriptor类中用到了SessionImpl,所以你再新建一个HibernateSessionDescriptor类覆盖。我已经试过了,是可以的。
浏览: 70434 次
来自: 南通
握着橄榄枝的人 写道在一对多关联中,在多的一方设置invers ...
请教一下,在BlobStrategyBlob类中session ...
aqaqaeae1234 写道lb250028 写道chenj ...
从头看到尾,看了不下10遍了,从刚开始的什么都看不懂,直到把j ...
楼主你好,我也是用hibernate4去集成jbpm4, 出现 ...

我要回帖

更多关于 python acquire 的文章

 

随机推荐