Bug 740499 - NPE when persisting timers
Summary: NPE when persisting timers
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: BRE (Expert, Fusion)
Version: BRMS 5.2.0.GA
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
: BRMS 5.2.0.GA
Assignee: Tihomir Surdilovic
QA Contact: Tomas Schlosser
URL:
Whiteboard:
Depends On: BRMS-636
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-09-22 09:10 UTC by Tomas Schlosser
Modified: 2011-09-30 08:07 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)

Description Tomas Schlosser 2011-09-22 09:10:43 UTC
Description of problem:
When trying to persist session with events contining timers I get NullPointerException.

Version-Release number of selected component (if applicable):
5.2.0.ER4, bitronix, hsqldb

How reproducible:
every time

Steps to Reproduce:
1. create persisted session
2. insert event with timer
3. run fireAllRules()
  
Actual results:
Caused by null
org.drools.marshalling.impl.OutputMarshaller.writeTimers(OutputMarshaller.java:1019)
at org.drools.marshalling.impl.OutputMarshaller.writeSession(OutputMarshaller.java:165)
at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:142)
at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:125)
at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:72)
at org.drools.persistence.info.SessionInfo.update(SessionInfo.java:84) 

Expected results:


Additional info:
complete stacktrace
Unable to commit transaction
org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:182)
at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:326)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.fireAllRules(CommandBasedStatefulKnowledgeSession.java:244)
at org.jboss.qa.drools.features.PersistenceTest.testInsertEvent(PersistenceTest.java:179)
25 lines not shown

Caused by error during managed flush
org.hibernate.ejb.AbstractEntityManagerImpl$3.mapManagedFlushFailure(AbstractEntityManagerImpl.java:1073)
at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:122)
at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)
at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)
at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)
at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:326)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.fireAllRules(CommandBasedStatefulKnowledgeSession.java:244)
at org.jboss.qa.drools.features.PersistenceTest.testInsertEvent(PersistenceTest.java:179)
25 lines not shown

Caused by null
org.drools.marshalling.impl.OutputMarshaller.writeTimers(OutputMarshaller.java:1019)
at org.drools.marshalling.impl.OutputMarshaller.writeSession(OutputMarshaller.java:165)
at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:142)
at org.drools.marshalling.impl.DefaultMarshaller.marshall(DefaultMarshaller.java:125)
at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:72)
at org.drools.persistence.info.SessionInfo.update(SessionInfo.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.hibernate.ejb.event.BeanCallback.invoke(BeanCallback.java:37)
at org.hibernate.ejb.event.EntityCallbackHandler.callback(EntityCallbackHandler.java:94)
at org.hibernate.ejb.event.EntityCallbackHandler.preUpdate(EntityCallbackHandler.java:79)
at org.hibernate.ejb.event.EJB3FlushEntityEventListener.invokeInterceptor(EJB3FlushEntityEventListener.java:61)
at org.hibernate.event.def.DefaultFlushEntityEventListener.handleInterception(DefaultFlushEntityEventListener.java:349)
at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:287)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:117)
at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51)
at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:478)
at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:193)
at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:120)
at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:179)
at org.drools.persistence.SingleSessionCommandService.execute(SingleSessionCommandService.java:326)
at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.fireAllRules(CommandBasedStatefulKnowledgeSession.java:244)
at org.jboss.qa.drools.features.PersistenceTest.testInsertEvent(PersistenceTest.java:179)
25 lines not shown

Comment 2 Mark Proctor 2011-09-22 09:19:50 UTC
I'll need a test case to fix this.

Comment 3 Tomas Schlosser 2011-09-22 10:02:35 UTC
Add this method to org.drools.timer.integrationtests.TimerAndCalendarTest in drools-persistence-jpa tests.

    @Test
    public void testEventExpires() throws Exception {
        String timerRule = "package org.drools.test\n" +
                "declare TestEvent \n" +
                "    @role( event )\n" +
                "    @expires( 10s )\n" +
                "end\n" +
                "" +
                "rule TimerRule \n" +
                "    when \n" +
                "        TestEvent( ) from entry-point \"Test\"\n" +
                "    then \n" +
                "end";
        KnowledgeBaseConfiguration kbconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
        kbconf.setOption(EventProcessingOption.STREAM);
        KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbconf);
        Resource resource = ResourceFactory.newByteArrayResource(timerRule.getBytes());
        Collection<KnowledgePackage> kpackages = buildKnowledgePackage(resource, ResourceType.DRL);
        kbase.addKnowledgePackages(kpackages);
        StatefulKnowledgeSession ksession = createSession(kbase);

        FactType type = kbase.getFactType("org.drools.test", "TestEvent");
        Assert.assertNotNull("could not get type", type);

        ksession = disposeAndReloadSession(ksession,kbase);
        ksession.getWorkingMemoryEntryPoint("Test").insert(type.newInstance());
        ksession.fireAllRules();
        ksession = disposeAndReloadSession(ksession,kbase);

        ksession = disposeAndReloadSession(ksession,kbase);
    }

Comment 4 Mark Proctor 2011-09-22 23:43:00 UTC
thanks, I have identified the issue and fixing. I'll have a fix for tomorrow 23/sept.

Comment 5 Tomas Schlosser 2011-09-30 08:07:45 UTC
This bug was fixed in BRMS-5.2.0.ER5, marking it verified.


Note You need to log in before you can comment on or make changes to this bug.