[jBPM Users] - Re: JBPM 4.1 Blob issue on AS400 DB2
by irisjacky99
OK, after a lot of troubleshooting debugging. Finally find a solution for it. I really hope someone from JBPM team can comment on this.
Basically, the LobLocator won't work if I try to getBytes once the resultset is closed. This is because BlobStrategyBlob in JBPM has following method
public byte[] get(Lob lob) {
| if (lob.cachedBytes!=null) {
| return lob.cachedBytes;
| }
|
| java.sql.Blob sqlBlob = lob.blob;
| if (sqlBlob!=null) {
| try {
| return sqlBlob.getBytes(1, (int) sqlBlob.length());
| } catch (SQLException e) {
| throw new JbpmException("couldn't extract bytes out of blob", e);
| }
| }
| return null;
| }
The highlighted one is calling hibernate code, and then use the lob locator. If it is new deployment with the test, the cachedBytes is return, therefore, no problem.
When we start process from existing deployment. it call this.
log.trace("loading deployment "+deploymentId+" from db");
| DeploymentImpl deployment = (DeploymentImpl) session.load(DeploymentImpl.class, Long.parseLong(deploymentId));
| deployerManager.deploy(deployment);
| object = repositoryCache.get(deploymentId, objectName);
| if (object==null) {
| throw new JbpmException("deployment "+deploymentId+" doesn't contain object "+objectName);
| }
The highlighted code does the loading from db. But it will not load blob data and just have lob locator instead. Then the deployerManager.deploy(deployment);
will call the lob locator to get data. And it is not happy because the resultset is closed by then. Therefore, exception in the original post happened.
I finally get around it by specifying the jdbc properties
<prop key="lob threshold">1048576</prop>
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4264917#4264917
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4264917
16 years, 7 months
[jBPM Users] - Re: JBPM 4.1 Blob issue on AS400 DB2
by irisjacky99
Thanks, Robinthomas.
I did notice this issue on DB2, which will result in another sql exception, DataTruncationException. We fixed this one already. We didn't let JBPM hbm to generate tables. Instead, we use table script to create them. The length of the BLOB is 1048576 now.
In fact, the above code works when we use it in unit test extending AbstractTransactionalSpringJbpmTestCase when the deployment is created fresh with the start process. However, it won't work if we try to start a process already deployed in the database, even unit testing. Found a link seems to related to this.
http://www-01.ibm.com/support/docview.wss?uid=nas16b3919404d0b1c2a86256ed...
But upgrading jt400.jar doesn't solved the problem, already tried. Hibernate 3.3.2 documentation also says
anonymous wrote :
| clob, blob
|
| Type mappings for the JDBC classes java.sql.Clob and java.sql.Blob. These types can be inconvenient for some applications, since the blob or clob object cannot be reused outside of a transaction. Driver support is patchy and inconsistent.
|
I also debug the JBPM code. the getBytes() called outside the session.load() . Not sure it is related to the way JBPM is implemented just doesn't fit AS400 DB2. I tried to changed the behavior of transactions on JBPM, but there is little documentation talking about that. Only a little bit mentioned in the JBPM Dev Guide, talking about using SpringTransactionInterceptor. Our caller method of above code is already wrapped in the Required transaction. It should join the tx if JBPM is using required as well.
I am posting the whole jbpm config here in case someone can help.
| <?xml version="1.0" encoding="UTF-8"?>
|
| <jbpm-configuration>
|
| <import resource="jbpm.jpdl.cfg.xml" />
| <import resource="jbpm.identity.cfg.xml" />
| <import resource="jbpm.jobexecutor.cfg.xml" />
| <import resource="jbpm.businesscalendar.cfg.xml" />
| <process-engine-context>
| <repository-service />
| <repository-cache />
| <execution-service />
| <history-service />
| <management-service />
| <identity-service />
| <task-service />
|
| <!-- Here we needed to change the transaction interceptor -->
| <command-service>
| <retry-interceptor />
| <environment-interceptor />
| <spring-transaction-interceptor />
| </command-service>
|
| <!-- Added spring as read-context-->
| <script-manager default-expression-language="juel"
| default-script-language="juel"
| read-contexts="execution, environment, process-engine, spring"
| write-context="">
| <script-language name="juel"
| factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
| </script-manager>
|
| <id-generator />
| <types resource="jbpm.variable.types.xml" />
|
| <address-resolver />
|
|
| <mail-template name='task-notification'>
| <to users="${task.assignee}"/>
| <subject>${task.name}</subject>
| <text><![CDATA[Hi ${task.assignee},
| Task "${task.name}" has been assigned to you.
| ${task.description}
|
| Sent by JBoss jBPM
| ]]></text>
| </mail-template>
|
| <mail-template name='task-reminder'>
| <to users="${task.assignee}"/>
| <subject>${task.name}</subject>
| <text><![CDATA[Hey ${task.assignee},
| Do not forget about task "${task.name}".
| ${task.description}
|
| Sent by JBoss jBPM
| ]]></text>
| </mail-template>
|
| </process-engine-context>
|
| <transaction-context>
| <repository-session />
| <db-session />
|
| <message-session />
| <timer-session />
| <history-session />
| <mail-session>
| <mail-server>
| <session-properties resource="jbpm.mail.properties" />
| </mail-server>
| </mail-session>
|
| <!--
| Need to set explicitly that we don't want jbpm to create sessions
| -->
| <hibernate-session current="true" />
| </transaction-context>
| </jbpm-configuration>
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4264910#4264910
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4264910
16 years, 7 months