<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
java.lang.IllegalArgumentException: attempt to create merge event with null entity
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/houxiaojun">Xiaojun Hou</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/610453#610453">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>In my project,i use the code below to configure the persistence:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>try {</p><p>            PoolingDataSource ds = new PoolingDataSource();</p><p>            ds.setUniqueName("jdbc/testDS");</p><p>            ds.setClassName("com.mysql.jdbc.jdbc2.optional.MysqlXADataSource");</p><p>            ds.setMaxPoolSize(3);</p><p>            ds.setAllowLocalTransactions(true);</p><p>            ds.getDriverProperties().put("user", "root");</p><p>            ds.getDriverProperties().put("password", "root");</p><p>            ds.getDriverProperties().put("URL", "jdbc:mysql://localhost:3306/jbpm5");</p><p>            ds.init();</p><p>            // load up the knowledge base</p><p>            KnowledgeBase kbase = readKnowledgeBase();</p><p>            // start a new process instance</p><p>            EntityManagerFactory emf = Persistence</p><p>                    .createEntityManagerFactory("org.jbpm.persistence.jpa");</p><p>            Environment env = KnowledgeBaseFactory.newEnvironment();</p><p>            env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,</p><p>                    emf);</p><p>            env.set(EnvironmentName.TRANSACTION_MANAGER,</p><p>                    TransactionManagerServices.getTransactionManager());</p><p>            </p><p>            // create a new knowledge session that uses JPA to store the runtime</p><p>            // state</p><p>            StatefulKnowledgeSession ksession=null;</p><p>            ksession= JPAKnowledgeService.newStatefulKnowledgeSession(</p><p>                    kbase,</p><p>                    null,</p><p>                    env);</p><p>            </p><p>            JPAWorkingMemoryDbLogger logger = new JPAWorkingMemoryDbLogger(ksession);</p><p>            ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());</p><p>            // start a new process instance</p><p>            Map<String, Object> params = new HashMap<String, Object>();</p><p>            params.put("employee", "krisv");</p><p>            ksession.startProcess("com.sample.evaluation",params);</p><p>            </p><p>            logger.dispose();</p><p>} catch (Throwable t) {</p><p>            t.printStackTrace();</p><p>        }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>However,when i start a new processinstance and try to complete the first task,exception happens just like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Registered human task listener</p><p>[2011:06:167 10:06:520:debug] Message receieved on client : AddTaskResponse</p><p>[2011:06:167 10:06:520:debug] Arguments : [1]</p><p>[2011:06:167 10:06:324:debug] Message receieved on client : EventTriggerResponse</p><p>[2011:06:167 10:06:324:debug] Arguments : [org.jbpm.task.event.EventPayload@b98a06]</p><p>Task completed 1</p><p>[2011:06:167 10:06:609:debug] Message receieved on client : GetTaskResponse</p><p>[2011:06:167 10:06:609:debug] Arguments : [org.jbpm.task.Task@2a7159ce]</p><p>[2011:06:167 10:06:610:exception] Uncaught exception on client</p><p>java.lang.IllegalArgumentException: attempt to create merge event with null entity</p><p>    at org.hibernate.event.MergeEvent.<init>(MergeEvent.java:60)</p><p>    at org.hibernate.event.MergeEvent.<init>(MergeEvent.java:43)</p><p>    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)</p><p>    at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)</p><p>    at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:235)</p><p>    at org.drools.persistence.jpa.JpaPersistenceContext.merge(JpaPersistenceContext.java:49)</p><p>    at org.drools.persistence.jpa.processinstance.JPAWorkItemManager.abortWorkItem(JPAWorkItemManager.java:136)</p><p>    at org.jbpm.process.workitem.wsht.WSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(WSHumanTaskHandler.java:249)</p><p>    at org.jbpm.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:81)</p><p>    at org.jbpm.task.service.mina.MinaTaskClientHandler.messageReceived(MinaTaskClientHandler.java:47)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:713)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)</p><p>    at org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:375)</p><p>    at org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:229)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:46)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:793)</p><p>    at org.apache.mina.core.filterchain.IoFilterAdapter.messageReceived(IoFilterAdapter.java:119)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:434)</p><p>    at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:426)</p><p>    at org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:638)</p><p>    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:598)</p><p>    at org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:587)</p><p>    at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:61)</p><p>    at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:969)</p><p>    at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64)</p><p>    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)</p><p>    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)</p><p>    at java.lang.Thread.run(Thread.java:619)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>after the exception,the task stored in the database has a "completed" status,Can somebody help me to solve the problem?</p><p>By the way,If i run the code above twice,exception will also happen just like this:</p><p>javax.persistence.PersistenceException: [PersistenceUnit: org.jbpm.persistence.jpa] Unable to build EntityManagerFactory</p><p>    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)</p><p>    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)</p><p>    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)</p><p>    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)</p><p>    at com.sample.ProcessTest.main(ProcessTest.java:71)</p><p>Caused by: org.hibernate.HibernateException: Could not obtain BTM transaction manager instance</p><p>    at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:50)</p><p>    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:357)</p><p>    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)</p><p>    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)</p><p>    at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)</p><p>    ... 4 more</p><p>Caused by: java.lang.reflect.InvocationTargetException</p><p>    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</p><p>    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</p><p>    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</p><p>    at java.lang.reflect.Method.invoke(Method.java:597)</p><p>    at org.hibernate.transaction.BTMTransactionManagerLookup.getTransactionManager(BTMTransactionManagerLookup.java:47)</p><p>    ... 8 more</p><p>Caused by: bitronix.tm.utils.InitializationException: cannot open disk journal</p><p>    at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:59)</p><p>    at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:43)</p><p>    ... 13 more</p><p>Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file</p><p>    at java.io.RandomAccessFile.read(Native Method)</p><p>    at java.io.RandomAccessFile.readInt(RandomAccessFile.java:720)</p><p>    at bitronix.tm.journal.TransactionLogHeader.<init>(TransactionLogHeader.java:77)</p><p>    at bitronix.tm.journal.TransactionLogAppender.<init>(TransactionLogAppender.java:50)</p><p>    at bitronix.tm.journal.DiskJournal.open(DiskJournal.java:132)</p><p>    at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:46)</p><p>    ... 14 more</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Hope someone can help me out here!!!</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/610453#610453">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>