[JBoss jBPM] - custom task instance problem
by XerXes_BPM
hi everyone!
i have a problem while trying to use custom task instances in jbpm.
for the first test i just wantet to copy the usual taskInstance and add an addittional property. the table gets created in the database and everything seems to work, but in the end when i try to save the process instance i get an hibernate error. i'm using jbpm 3.1.1 with ms sql server 2003 and jboss ide 1.6.
i have done what was mentioned in the userguide and in this forum:
- create a subclass of TaskInstance
| public class CustomTaskInstance extends TaskInstance {
|
| private String customProperty;
|
| public String getCustomProperty() {
| return customProperty;
| }
|
| public void setCustomProperty(String customProperty) {
| this.customProperty = customProperty;
| }
|
| }
|
|
- create an implementation of org.jbpm.taskmgmt.TaskInstanceFactory
| public class CustomTaskInstanceFactoryImpl implements TaskInstanceFactory {
|
| public TaskInstance createTaskInstance(ExecutionContext executionContext) {
|
| //just a simple mapping to CustomTaskInstance
|
| return new CustomTaskInstance();
| }
|
| }
|
|
- update the property jbpm.task.instance.factory to specify the name of custom class
| <bean name='jbpm.task.instance.factory' class='com.dumdidum.pc.CustomTaskInstanceFactoryImpl' singleton='true' />
|
- create a mapping file for the subclass, for mapping the extra properties you want to save
| <?xml version="1.0"?>
|
| <!DOCTYPE hibernate-mapping PUBLIC
| "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
| "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
| <hibernate-mapping default-access="field">
|
| <class name="com.dumdidum.pc.CustomTaskInstance"
| table="JBPM_CUSTOMTASKINSTANCE"
| discriminator-value="C">
| <id name="id" column="ID_"><generator class="native" /></id>
| <discriminator type="char" column="CLASS_"/>
|
| <property name="name" column="NAME_" />
| <property name="description" column="DESCRIPTION_" type="string_max" length="4000"/>
| <property name="actorId" column="ACTORID_" index="IDX_TASK_ACTORID"/>
| <property name="create" column="CREATE_" />
| <property name="start" column="START_" />
| <property name="end" column="END_" />
| <property name="dueDate" column="DUEDATE_" />
| <property name="priority" column="PRIORITY_" />
| <property name="isCancelled" column="ISCANCELLED_" />
| <property name="isSuspended" column="ISSUSPENDED_" />
| <property name="isOpen" column="ISOPEN_" />
| <property name="isSignalling" column="ISSIGNALLING_" />
| <property name="isBlocking" column="ISBLOCKING_" />
| <property name="customProperty" column="CUSTOMPROPERTY_" />
|
| <many-to-one name="task"
| column="TASK_"
| foreign-key="FK_TASKINST_TASK"/>
| <many-to-one name="token"
| column="TOKEN_"
| foreign-key="FK_TASKINST_TOKEN"/>
| <many-to-one name="swimlaneInstance"
| column="SWIMLANINSTANCE_"
| foreign-key="FK_TASKINST_SLINST"/>
| <many-to-one name="taskMgmtInstance"
| column="TASKMGMTINSTANCE_"
| foreign-key="FK_TASKINST_TMINST"/>
|
| <map name="variableInstances" cascade="all">
| <key column="TASKINSTANCE_" foreign-key="FK_VAR_TSKINST"/>
| <index type="string" column="NAME_" />
| <one-to-many class="org.jbpm.context.exe.VariableInstance" />
| </map>
| <set name="pooledActors"
| cascade="all"
| table="JBPM_TASKACTORPOOL">
| <key column="TASKINSTANCE_" foreign-key="FK_TASKACTPL_TSKI"/>
| <many-to-many class="org.jbpm.taskmgmt.exe.PooledActor" column="POOLEDACTOR_" />
| </set>
| <list name="comments" cascade="all" >
| <key column="TASKINSTANCE_" />
| <index column="TASKINSTANCEINDEX_" />
| <one-to-many class="org.jbpm.graph.exe.Comment" />
| </list>
|
| </class>
|
| </hibernate-mapping>
|
|
- add that mapping file to the list of mapping files
| <mapping resource="com/dumdidum/pc/CustomTaskInstance.hbm.xml"/>
|
- use custom assignementHandler
| public class MyAssignmentHandler implements AssignmentHandler {
|
| public void assign(Assignable assignable, ExecutionContext executionContext)
| throws Exception {
|
|
| CustomTaskInstance cti = (CustomTaskInstance) assignable;
| cti.setActorId("UserPc1");
| cti.setCustomProperty("testtest");
|
| }
|
| }
|
|
the simple process:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="urn:jbpm.org:jpdl-3.1" name="simpleTask">
| <start-state name="start">
| <transition name="" to="task1"></transition>
| </start-state>
| <end-state name="end1"></end-state>
| <task-node name="task1">
| <task name="testTask">
| <assignment class="com.dumdidum.pc.MyAssignmentHandler"></assignment>
| </task>
| <transition name="" to="state1"></transition>
| </task-node>
| <state name="state1">
| <transition name="" to="end1"></transition>
| </state>
| </process-definition>
|
the result is the following error when trying to flush the session:
| 17:10:42,305 [main] DEBUG Services : executing default save operations
| 17:10:42,305 [main] DEBUG HibernateSaveOperation : saving process instance
| 17:10:42,305 [main] DEBUG SaveLogsOperation : flushing logs to logging service.
| org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
| at org.jbpm.svc.Services.close(Services.java:211)
| at org.jbpm.JbpmContext.close(JbpmContext.java:141)
| at com.rockwell.pc.JBPMWrapper.participateInProcess(JBPMWrapper.java:218)
| at com.rockwell.pc.ProcessTester.main(ProcessTester.java:36)
| Caused by: org.hibernate.AssertionFailure: null id in org.jbpm.taskmgmt.log.TaskAssignLog entry (don't flush the Session after an exception occurs)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)17:10:42,315 [main] WARN JDBCExceptionReporter : SQL Error: 547, SQLState: 23000
| 17:10:42,315 [main] ERROR JDBCExceptionReporter : INSERT statement conflicted with COLUMN FOREIGN KEY constraint 'FK_LOG_TASKINST'. The conflict occurred in database 'JBPM', table 'JBPM_TASKINSTANCE', column 'ID_'.
| 17:10:42,315 [main] DEBUG JbpmContext : closing JbpmContext
| 17:10:42,315 [main] DEBUG Services : closing service 'persistence': org.jbpm.persistence.db.DbPersistenceService@1abdac9
| 17:10:42,315 [main] DEBUG DbPersistenceService : committing hibernate transaction
| 17:10:42,325 [main] ERROR AssertionFailure : an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
| org.hibernate.AssertionFailure: null id in org.jbpm.taskmgmt.log.TaskAssignLog entry (don't flush the Session after an exception occurs)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
| at org.jbpm.svc.Services.close(Services.java:211)
| at org.jbpm.JbpmContext.close(JbpmContext.java:141)
| at com.rockwell.pc.JBPMWrapper.participateInProcess(JBPMWrapper.java:218)
| at com.rockwell.pc.ProcessTester.main(ProcessTester.java:36)
| 17:10:42,345 [main] ERROR Services : problem closing service 'persistence'
| org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
| at org.jbpm.svc.Services.close(Services.java:211)
| at org.jbpm.JbpmContext.close(JbpmContext.java:141)
| at com.rockwell.pc.JBPMWrapper.participateInProcess(JBPMWrapper.java:218)
| at com.rockwell.pc.ProcessTester.main(ProcessTester.java:36)
| Caused by: org.hibernate.AssertionFailure: null id in org.jbpm.taskmgmt.log.TaskAssignLog entry (don't flush the Session after an exception occurs)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
| ... 4 more
|
| at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
| ... 4 more
| org.jbpm.JbpmException: problem closing services {persistence=org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session}
| at org.jbpm.svc.Services.close(Services.java:223)
| at org.jbpm.JbpmContext.close(JbpmContext.java:141)
| at com.rockwell.pc.JBPMWrapper.participateInProcess(JBPMWrapper.java:218)
| at com.rockwell.pc.ProcessTester.main(ProcessTester.java:36)
| Caused by: org.jbpm.persistence.JbpmPersistenceException: couldn't commit hibernate session
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:171)
| at org.jbpm.svc.Services.close(Services.java:211)
| ... 3 more
| Caused by: org.hibernate.AssertionFailure: null id in org.jbpm.taskmgmt.log.TaskAssignLog entry (don't flush the Session after an exception occurs)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:48)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:150)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
| at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
| at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:353)
| at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
| at org.jbpm.persistence.db.DbPersistenceService.close(DbPersistenceService.java:161)
| ... 4 more
| 17:10:42,345 [main] DEBUG Services : closing service 'logging': org.jbpm.logging.db.DbLoggingService@1e8c585
|
|
any help would be appreciated!
best regards
gregor
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080044#4080044
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080044
18Â years, 7Â months
[JBoss Seam] - EntitySecurityListener and MDBs
by mtpettyp
I've just recently started using Seam's JBoss Rules support for securing entities and I've run into an issue. When one of my MDBs tries to write to the database, I get the following exception:
| java.lang.IllegalStateException: No active session context
| at org.jboss.seam.security.Identity.instance(Identity.java:157)
| at org.jboss.seam.security.EntitySecurityListener.postLoad(EntitySecurityListener.java:26)
| ...
|
This makes complete sense, as there obviously isn't a session context in an MDB.
Anyone have any ideas on how to work around this? Ideally I'd like to be able to turn off EntitySecurityListener when running in my MDB, but I can't see an easy way to do this. Each method of EntitySecurityListener checks the static method Identity.isSecurityEnabled(), but if I was to turn security off it would affect my entire application, which is not desirable.
I'd also like to be able turn off entity security for the duration of my authentication method (since I load the User entities to see if the passed-in credentials are valid, but would like to be able to protect access after logging in).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080036#4080036
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080036
18Â years, 7Â months
[JBoss Seam] Data access
by José Moreira
Hello,
how is it possible to encapsulate data acess / business logic with Seam?
most of the examples i have seen, for example,
query the entity manager directly from the "actions".
i was starting to code @stateless ejb's but had some compile errors and
i had to switch to @stateful.
--
Melhores cumprimentos,
José Moreira
18Â years, 7Â months
[JBoss Portal] - LinkageError when accessing to admin portal
by angelo.dangelo
Hi,
I'm using JBoss Portal 2.6.1 in bundle with AS 4.2.1 and Oracle 10 db.
I deployed my ear application, which contains (besides the WARs of my portlets) the following libraries:
- commons-validator-1.3.0.jar
- jakarta-oro-2.0.8.jar
- joda-time-1.4.jar
- jsf-facelets.jar (ver 1.1.12)
- jsf-portlet.jar (ver 1.2.1)
- tomahawk-1.1.6.jar
After visited my portlets, If I try to access to admin portal, clicking Admin link in the dashboard nav, I have this error:
| 15:27:04,828 ERROR [CommandServlet] Exception in command invocation
| java.lang.LinkageError: loader constraints violated when linking javax/faces/component/UIComponent class
| at java.lang.Class.forName0(Native Method)
| at java.lang.Class.forName(Class.java:242)
| at com.sun.facelets.compiler.ReflectionUtil.forName(ReflectionUtil.java:55)
| at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.createClass(TagLibraryConfig.java:278)
| at com.sun.facelets.compiler.TagLibraryConfig$LibraryHandler.endElement(TagLibraryConfig.java:205)
| at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
| ...
|
Could you, please, help me to solve this problem?
Thank you.
Angelo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4080033#4080033
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4080033
18Â years, 7Â months