[jboss-jira] [JBoss JIRA] (DROOLS-102) Error inserting facts after session restore

Nedo Nedic (JIRA) jira-events at lists.jboss.org
Wed Apr 10 09:43:55 EDT 2013


Nedo Nedic created DROOLS-102:
---------------------------------

             Summary: Error inserting facts after session restore 
                 Key: DROOLS-102
                 URL: https://issues.jboss.org/browse/DROOLS-102
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
    Affects Versions: 5.5
         Environment: JBoss AS 5.0
Drools 5.4
Linux Ubuntu
JDK 1.6
            Reporter: Nedo Nedic
            Assignee: Mark Proctor


I'm using Drools 5.4.0 to save the session state when the application server restarts / stops. Everything works fine and the session state is properly restored, but when new fact is inserted the following exception is thrown:

java.lang.NullPointerException
        at java.lang.Class.isAssignableFrom(Native Method)
        at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:57)
        at org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:68)
        at org.drools.common.AbstractFactHandleFactory.newFactHandle(AbstractFactHandleFactory.java:53)
        at org.drools.common.NamedEntryPoint.createHandle(NamedEntryPoint.java:745)
        at org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:287)
        at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:888)
        at org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:847)
        at org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:269)


I explored through Drools code, and figured out time stamp extractor getExtractToClass method is evaluating to null (line 57 ReteooFactHandleFactory):

public final InternalFactHandle newFactHandle(final int id,
                                                  final Object object,
                                                  final long recency,
                                                  final ObjectTypeConf conf,
                                                  final InternalWorkingMemory workingMemory,
                                                  final WorkingMemoryEntryPoint wmEntryPoint) {
        if ( conf != null && conf.isEvent() ) {
            TypeDeclaration type = conf.getTypeDeclaration();
            long timestamp;
            if ( type.getTimestampExtractor() != null ) {
                if ( Date.class.isAssignableFrom( type.getTimestampExtractor().getExtractToClass() ) ) {
                    timestamp = ((Date) type.getTimestampExtractor().getValue( workingMemory,
                                                                               object )).getTime();
                } else {
                    timestamp = type.getTimestampExtractor().getLongValue( workingMemory,
                                                                           object );
                }
            } else {
                timestamp = workingMemory.getTimerService().getCurrentTime();
....


My code for storing / restoring session:

        public void saveCorrelator(FileOutputStream output) throws IOException {
               
                DroolsObjectOutputStream droolsOut = new DroolsObjectOutputStream(output);
                droolsOut.writeObject(ksession.getKnowledgeBase());
                Marshaller mas = createMarshaller(ksession.getKnowledgeBase());
                mas.marshall(droolsOut, ksession);
                droolsOut.flush();
                droolsOut.close();
        }

       
        public void loadCorrelator(FileInputStream input) throws IOException,
                        ClassNotFoundException {
               
                DroolsObjectInputStream droolsIn = new DroolsObjectInputStream(input, this.getClass().getClassLoader());
                try {
                        KnowledgeBase kbase = (KnowledgeBase) droolsIn.readObject();
                        Marshaller mas = createMarshaller(kbase);
                        ksession = mas.unmarshall(droolsIn);
                } catch(EOFException e) {
                        log.error("EOFException on correlator restore");
                } finally {
                        droolsIn.close();
                }
               
        }

        private Marshaller createMarshaller(KnowledgeBase kbase) {
                ObjectMarshallingStrategyAcceptor acceptor = MarshallerFactory
                                .newClassFilterAcceptor(new String[] { "*.*" });
                ObjectMarshallingStrategy strategy = MarshallerFactory
                                .newSerializeMarshallingStrategy(acceptor);
                return MarshallerFactory.newMarshaller(kbase,
                                new ObjectMarshallingStrategy[] { strategy });
        }


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list