Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mytest.stream;
- import java.util.Date;
- declare MyEvent
- @role( event )
- @expires( 3s )
- end
- rule 'MyEvent'
- when
- $m: MyEvent()
- then
- System.out.println(new Date() + " demoReload: Got MyEvent, id=" + $m.getId());
- end
- package com.mytest.stream;
- import java.io.Serializable;
- public class MyEvent implements Serializable {
- private static final long serialVersionUID = 1L;
- private String id;
- public MyEvent(String id) {
- this.id = id;
- }
- public static long getSerialversionuid() {
- return serialVersionUID;
- }
- public String getId() {
- return id;
- }
- }
- package com.mytest.stream;
- import javax.persistence.Persistence;
- import org.junit.Test;
- import org.kie.api.KieBase;
- import org.kie.api.KieServices;
- import org.kie.api.runtime.Environment;
- import org.kie.api.runtime.EnvironmentName;
- import org.kie.api.runtime.KieContainer;
- import org.kie.api.runtime.KieSession;
- import bitronix.tm.TransactionManagerServices;
- import bitronix.tm.resource.jdbc.PoolingDataSource;
- import com.mytest.stream.MyEvent;
- import java.util.Date;
- public class DroolsTest {
- @Test
- public void demoReloadFailure() throws Throwable {
- System.getProperties().put("java.naming.factory.initial","bitronix.tm.jndi.BitronixInitialContextFactory");
- PoolingDataSource ds = new PoolingDataSource();
- ds.setUniqueName("jdbc/BitronixJTADataSource");
- ds.setClassName("org.h2.jdbcx.JdbcDataSource");
- ds.setMaxPoolSize( 3 );
- ds.setAllowLocalTransactions( true );
- ds.getDriverProperties().put( "user", "sa" );
- ds.getDriverProperties().put( "password", "" );
- ds.getDriverProperties().put( "URL", "jdbc:h2:file:./sql/mytest");
- ds.init();
- try {
- KieServices ks = KieServices.Factory.get();
- Environment env = ks.newEnvironment();
- env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory( "myPU" ) );
- env.set( EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager() );
- KieContainer kieContainer = ks.getKieClasspathContainer();
- KieBase kieBase = kieContainer.getKieBase("rules");
- KieSession kieSession = ks.getStoreServices().newKieSession(kieBase, null, env);
- long kieSessionId = kieSession.getIdentifier();
- kieSession.insert(new MyEvent("EVENT1"));
- kieSession.fireAllRules();
- kieSession.dispose();
- // Timer in MyEvent.drl set for 3 second expiration, so it will already have expired
- // when session reload is attempted.
- //
- Thread.sleep(5000);
- kieSession = ks.getStoreServices().loadKieSession( kieSessionId, kieBase, null, env );
- kieSession.fireAllRules();
- kieSession.dispose();
- } catch (Exception e) {
- System.out.println(new Date() + " demoReloadFailure: Caught Exception, message=" + e.getMessage());
- }
- }
- }
- [main] DEBUG bitronix.tm.resource.jdbc.PoolingDataSource - building XA pool for jdbc/BitronixJTADataSource with 0 connection(s)
- 20 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'URL' to 'jdbc:h2:file:./sql/mytest'
- 23 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'user' to 'sa'
- 23 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'password' to ''
- 35 [main] DEBUG bitronix.tm.timer.TaskScheduler - task scheduler backed by ConcurrentSkipListSet
- 50 [main] DEBUG bitronix.tm.timer.TaskScheduler - scheduling pool shrinking task on an XAPool of resource jdbc/BitronixJTADataSource with 0 connection(s) (0 still available) for Tue Jan 06 21:47:35 EST 1970
- 50 [main] DEBUG bitronix.tm.timer.TaskScheduler - removing task by an XAPool of resource jdbc/BitronixJTADataSource with 0 connection(s) (0 still available)
- 51 [main] DEBUG bitronix.tm.timer.TaskScheduler - scheduled a PoolShrinkingTask scheduled for Tue Jan 06 21:47:35 EST 1970 on an XAPool of resource jdbc/BitronixJTADataSource with 0 connection(s) (0 still available), total task(s) queued: 1
- 53 [main] DEBUG bitronix.tm.Configuration - loading default configuration
- 53 [main] DEBUG bitronix.tm.Configuration - no configuration file found, using default settings
- 129 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4jLoggerProvider
- 229 [main] DEBUG org.hibernate.jpa.boot.spi.ProviderChecker - Persistence-unit [myPU] requested PersistenceProvider [org.hibernate.jpa.HibernatePersistenceProvider]
- 235 [main] DEBUG org.hibernate.jpa.internal.util.LogHelper - PersistenceUnitInfo [
- name: myPU
- persistence provider classname: org.hibernate.jpa.HibernatePersistenceProvider
- classloader: null
- excludeUnlistedClasses: false
- JTA datasource: jdbc/BitronixJTADataSource
- Non JTA datasource: null
- Transaction type: JTA
- PU root URL: file:/C:/Users/ks922p/workspace_luna/drools-stream-a/target/classes/
- Shared Cache Mode: null
- Validation Mode: null
- Jar files URLs []
- Managed classes names [
- org.drools.persistence.info.SessionInfo
- org.drools.persistence.info.WorkItemInfo]
- Mapping files names []
- Properties [
- hibernate.max_fetch_depth: 3
- hibernate.transaction.manager_lookup_class: org.hibernate.transaction.BTMTransactionManagerLookup
- hibernate.dialect: org.hibernate.dialect.H2Dialect
- hibernate.show_sql: true
- hibernate.hbm2ddl.auto: update]
- 245 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator].
- 246 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
- 248 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.cache.internal.CollectionCacheInvalidator].
- 248 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.jpa.event.spi.JpaIntegrator].
- 8266 [main] DEBUG bitronix.tm.BitronixTransaction - executing synchronization a DeferredReleaseSynchronization of a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state NOT_ACCESSIBLE with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA with status=ROLLEDBACK
- 8266 [main] DEBUG bitronix.tm.resource.common.DeferredReleaseSynchronization - DeferredReleaseSynchronization requeuing a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state NOT_ACCESSIBLE with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA
- 8266 [main] DEBUG bitronix.tm.resource.common.AbstractXAStatefulHolder - notifying 2 stateChangeEventListener(s) about state changing from NOT_ACCESSIBLE to IN_POOL in a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state NOT_ACCESSIBLE with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA
- 8266 [main] DEBUG bitronix.tm.resource.jdbc.JdbcPooledConnection - closing 0 dangling uncached statement(s)
- 8266 [main] DEBUG bitronix.tm.resource.jdbc.JdbcPooledConnection - clearing warnings of conn3: url=jdbc:h2:file:./sql/mytest user=SA
- 8266 [main] DEBUG bitronix.tm.resource.common.AbstractXAStatefulHolder - state changing from NOT_ACCESSIBLE to IN_POOL in a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state NOT_ACCESSIBLE with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA
- 8266 [main] DEBUG bitronix.tm.resource.common.AbstractXAStatefulHolder - notifying 2 stateChangeEventListener(s) about state changed from NOT_ACCESSIBLE to IN_POOL in a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state IN_POOL with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA
- 8266 [main] DEBUG bitronix.tm.resource.jdbc.JdbcPooledConnection - requeued JDBC connection of a PoolingDataSource containing an XAPool of resource jdbc/BitronixJTADataSource with 2 connection(s) (1 still available)
- 8266 [main] DEBUG bitronix.tm.resource.common.XAPool - a connection's state changed to IN_POOL, notifying a thread eventually waiting for a connection
- 8266 [main] DEBUG bitronix.tm.resource.common.DeferredReleaseSynchronization - DeferredReleaseSynchronization requeued a JdbcPooledConnection from datasource jdbc/BitronixJTADataSource in state IN_POOL with usage count 0 wrapping xads1: conn2: url=jdbc:h2:file:./sql/mytest user=SA
- 8267 [main] WARN org.drools.persistence.jta.JtaTransactionManager - Unable to commit transaction
- bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
- at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:241)
- at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:143)
- at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:236)
- at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:185)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
- at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:111)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:39)
- at com.mytest.stream.DroolsTest.demoReloadFailure(DroolsTest.java:52)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:497)
- at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
- at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
- at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
- at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
- at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
- at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
- at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
- at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
- at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
- at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
- at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
- at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
- at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
- at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
- Caused by: java.lang.NullPointerException
- at org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:618)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeTimers(ProtobufOutputMarshaller.java:882)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:214)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:120)
- at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:154)
- at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:138)
- at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:79)
- at org.drools.persistence.info.SessionInfo.transform(SessionInfo.java:96)
- at org.drools.persistence.TriggerUpdateTransactionSynchronization.beforeCompletion(TriggerUpdateTransactionSynchronization.java:57)
- at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.beforeCompletion(JtaTransactionSynchronizationAdapter.java:54)
- at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:532)
- at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:235)
- ... 34 more
- 8268 [main] WARN org.drools.persistence.SingleSessionCommandService - Could not commit session
- java.lang.RuntimeException: Unable to commit transaction
- at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:239)
- at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:185)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
- at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:111)
- at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:39)
- at com.mytest.stream.DroolsTest.demoReloadFailure(DroolsTest.java:52)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:497)
- at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
- at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
- at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
- at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
- at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
- at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
- at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
- at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
- at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
- at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
- at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
- at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
- at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
- at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
- at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
- at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
- Caused by: bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
- at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:241)
- at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:143)
- at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:236)
- ... 32 more
- Caused by: java.lang.NullPointerException
- at org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:618)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeTimers(ProtobufOutputMarshaller.java:882)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:214)
- at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:120)
- at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:154)
- at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:138)
- at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:79)
- at org.drools.persistence.info.SessionInfo.transform(SessionInfo.java:96)
- at org.drools.persistence.TriggerUpdateTransactionSynchronization.beforeCompletion(TriggerUpdateTransactionSynchronization.java:57)
- at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.beforeCompletion(JtaTransactionSynchronizationAdapter.java:54)
- at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:532)
- at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:235)
- ... 34 more
- Wed Apr 20 16:56:06 EDT 2016 demoReloadFailure: Caught Exception, message=java.lang.reflect.InvocationTargetException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement