Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.70 KB | None | 0 0
  1. package com.mytest.stream;
  2.  
  3. import java.util.Date;
  4.  
  5. declare MyEvent
  6. @role( event )
  7. @expires( 3s )
  8. end
  9.  
  10. rule 'MyEvent'
  11. when
  12. $m: MyEvent()
  13. then
  14. System.out.println(new Date() + " demoReload: Got MyEvent, id=" + $m.getId());
  15. end
  16.  
  17. package com.mytest.stream;
  18. import java.io.Serializable;
  19. public class MyEvent implements Serializable {
  20. private static final long serialVersionUID = 1L;
  21. private String id;
  22. public MyEvent(String id) {
  23. this.id = id;
  24. }
  25. public static long getSerialversionuid() {
  26. return serialVersionUID;
  27. }
  28. public String getId() {
  29. return id;
  30. }
  31. }
  32.  
  33. package com.mytest.stream;
  34.  
  35. import javax.persistence.Persistence;
  36.  
  37. import org.junit.Test;
  38. import org.kie.api.KieBase;
  39. import org.kie.api.KieServices;
  40. import org.kie.api.runtime.Environment;
  41. import org.kie.api.runtime.EnvironmentName;
  42. import org.kie.api.runtime.KieContainer;
  43. import org.kie.api.runtime.KieSession;
  44.  
  45. import bitronix.tm.TransactionManagerServices;
  46. import bitronix.tm.resource.jdbc.PoolingDataSource;
  47.  
  48. import com.mytest.stream.MyEvent;
  49.  
  50. import java.util.Date;
  51. public class DroolsTest {
  52.  
  53. @Test
  54. public void demoReloadFailure() throws Throwable {
  55. System.getProperties().put("java.naming.factory.initial","bitronix.tm.jndi.BitronixInitialContextFactory");
  56. PoolingDataSource ds = new PoolingDataSource();
  57. ds.setUniqueName("jdbc/BitronixJTADataSource");
  58. ds.setClassName("org.h2.jdbcx.JdbcDataSource");
  59. ds.setMaxPoolSize( 3 );
  60. ds.setAllowLocalTransactions( true );
  61. ds.getDriverProperties().put( "user", "sa" );
  62. ds.getDriverProperties().put( "password", "" );
  63. ds.getDriverProperties().put( "URL", "jdbc:h2:file:./sql/mytest");
  64. ds.init();
  65.  
  66. try {
  67. KieServices ks = KieServices.Factory.get();
  68. Environment env = ks.newEnvironment();
  69. env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory( "myPU" ) );
  70. env.set( EnvironmentName.TRANSACTION_MANAGER,TransactionManagerServices.getTransactionManager() );
  71. KieContainer kieContainer = ks.getKieClasspathContainer();
  72. KieBase kieBase = kieContainer.getKieBase("rules");
  73. KieSession kieSession = ks.getStoreServices().newKieSession(kieBase, null, env);
  74. long kieSessionId = kieSession.getIdentifier();
  75. kieSession.insert(new MyEvent("EVENT1"));
  76. kieSession.fireAllRules();
  77. kieSession.dispose();
  78.  
  79. // Timer in MyEvent.drl set for 3 second expiration, so it will already have expired
  80. // when session reload is attempted.
  81. //
  82. Thread.sleep(5000);
  83.  
  84. kieSession = ks.getStoreServices().loadKieSession( kieSessionId, kieBase, null, env );
  85. kieSession.fireAllRules();
  86. kieSession.dispose();
  87.  
  88. } catch (Exception e) {
  89. System.out.println(new Date() + " demoReloadFailure: Caught Exception, message=" + e.getMessage());
  90. }
  91. }
  92. }
  93.  
  94. [main] DEBUG bitronix.tm.resource.jdbc.PoolingDataSource - building XA pool for jdbc/BitronixJTADataSource with 0 connection(s)
  95. 20 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'URL' to 'jdbc:h2:file:./sql/mytest'
  96. 23 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'user' to 'sa'
  97. 23 [main] DEBUG bitronix.tm.resource.common.XAPool - setting vendor property 'password' to ''
  98. 35 [main] DEBUG bitronix.tm.timer.TaskScheduler - task scheduler backed by ConcurrentSkipListSet
  99. 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
  100. 50 [main] DEBUG bitronix.tm.timer.TaskScheduler - removing task by an XAPool of resource jdbc/BitronixJTADataSource with 0 connection(s) (0 still available)
  101. 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
  102. 53 [main] DEBUG bitronix.tm.Configuration - loading default configuration
  103. 53 [main] DEBUG bitronix.tm.Configuration - no configuration file found, using default settings
  104. 129 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4jLoggerProvider
  105. 229 [main] DEBUG org.hibernate.jpa.boot.spi.ProviderChecker - Persistence-unit [myPU] requested PersistenceProvider [org.hibernate.jpa.HibernatePersistenceProvider]
  106. 235 [main] DEBUG org.hibernate.jpa.internal.util.LogHelper - PersistenceUnitInfo [
  107. name: myPU
  108. persistence provider classname: org.hibernate.jpa.HibernatePersistenceProvider
  109. classloader: null
  110. excludeUnlistedClasses: false
  111. JTA datasource: jdbc/BitronixJTADataSource
  112. Non JTA datasource: null
  113. Transaction type: JTA
  114. PU root URL: file:/C:/Users/ks922p/workspace_luna/drools-stream-a/target/classes/
  115. Shared Cache Mode: null
  116. Validation Mode: null
  117. Jar files URLs []
  118. Managed classes names [
  119. org.drools.persistence.info.SessionInfo
  120. org.drools.persistence.info.WorkItemInfo]
  121. Mapping files names []
  122. Properties [
  123. hibernate.max_fetch_depth: 3
  124. hibernate.transaction.manager_lookup_class: org.hibernate.transaction.BTMTransactionManagerLookup
  125. hibernate.dialect: org.hibernate.dialect.H2Dialect
  126. hibernate.show_sql: true
  127. hibernate.hbm2ddl.auto: update]
  128. 245 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.cfg.beanvalidation.BeanValidationIntegrator].
  129. 246 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.secure.spi.JaccIntegrator].
  130. 248 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.cache.internal.CollectionCacheInvalidator].
  131. 248 [main] DEBUG org.hibernate.integrator.internal.IntegratorServiceImpl - Adding Integrator [org.hibernate.jpa.event.spi.JpaIntegrator].
  132. 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
  133. 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
  134. 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
  135. 8266 [main] DEBUG bitronix.tm.resource.jdbc.JdbcPooledConnection - closing 0 dangling uncached statement(s)
  136. 8266 [main] DEBUG bitronix.tm.resource.jdbc.JdbcPooledConnection - clearing warnings of conn3: url=jdbc:h2:file:./sql/mytest user=SA
  137. 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
  138. 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
  139. 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)
  140. 8266 [main] DEBUG bitronix.tm.resource.common.XAPool - a connection's state changed to IN_POOL, notifying a thread eventually waiting for a connection
  141. 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
  142. 8267 [main] WARN org.drools.persistence.jta.JtaTransactionManager - Unable to commit transaction
  143. bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
  144. at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:241)
  145. at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:143)
  146. at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:236)
  147. at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:185)
  148. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  149. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  150. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  151. at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
  152. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)
  153. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:111)
  154. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:39)
  155. at com.mytest.stream.DroolsTest.demoReloadFailure(DroolsTest.java:52)
  156. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  157. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  158. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  159. at java.lang.reflect.Method.invoke(Method.java:497)
  160. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  161. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  162. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  163. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  164. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  165. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  166. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  167. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  168. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  169. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  170. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  171. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  172. at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  173. at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  174. at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  175. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  176. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
  177. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  178. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  179. Caused by: java.lang.NullPointerException
  180. at org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:618)
  181. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeTimers(ProtobufOutputMarshaller.java:882)
  182. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:214)
  183. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:120)
  184. at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:154)
  185. at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:138)
  186. at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:79)
  187. at org.drools.persistence.info.SessionInfo.transform(SessionInfo.java:96)
  188. at org.drools.persistence.TriggerUpdateTransactionSynchronization.beforeCompletion(TriggerUpdateTransactionSynchronization.java:57)
  189. at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.beforeCompletion(JtaTransactionSynchronizationAdapter.java:54)
  190. at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:532)
  191. at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:235)
  192. ... 34 more
  193. 8268 [main] WARN org.drools.persistence.SingleSessionCommandService - Could not commit session
  194. java.lang.RuntimeException: Unable to commit transaction
  195. at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:239)
  196. at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:185)
  197. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  198. at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  199. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  200. at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
  201. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommandService(KnowledgeStoreServiceImpl.java:143)
  202. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:111)
  203. at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.loadKieSession(KnowledgeStoreServiceImpl.java:39)
  204. at com.mytest.stream.DroolsTest.demoReloadFailure(DroolsTest.java:52)
  205. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  206. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  207. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  208. at java.lang.reflect.Method.invoke(Method.java:497)
  209. at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
  210. at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  211. at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
  212. at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
  213. at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
  214. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
  215. at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
  216. at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
  217. at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
  218. at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
  219. at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
  220. at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
  221. at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
  222. at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
  223. at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
  224. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
  225. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
  226. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
  227. at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  228. Caused by: bitronix.tm.internal.BitronixRollbackException: RuntimeException thrown during beforeCompletion cycle caused transaction rollback
  229. at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:241)
  230. at bitronix.tm.BitronixTransactionManager.commit(BitronixTransactionManager.java:143)
  231. at org.drools.persistence.jta.JtaTransactionManager.commit(JtaTransactionManager.java:236)
  232. ... 32 more
  233. Caused by: java.lang.NullPointerException
  234. at org.drools.core.reteoo.ObjectTypeNode$ExpireJobContextTimerOutputMarshaller.serialize(ObjectTypeNode.java:618)
  235. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeTimers(ProtobufOutputMarshaller.java:882)
  236. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.serializeSession(ProtobufOutputMarshaller.java:214)
  237. at org.drools.core.marshalling.impl.ProtobufOutputMarshaller.writeSession(ProtobufOutputMarshaller.java:120)
  238. at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:154)
  239. at org.drools.core.marshalling.impl.ProtobufMarshaller.marshall(ProtobufMarshaller.java:138)
  240. at org.drools.persistence.SessionMarshallingHelper.getSnapshot(SessionMarshallingHelper.java:79)
  241. at org.drools.persistence.info.SessionInfo.transform(SessionInfo.java:96)
  242. at org.drools.persistence.TriggerUpdateTransactionSynchronization.beforeCompletion(TriggerUpdateTransactionSynchronization.java:57)
  243. at org.drools.persistence.jta.JtaTransactionSynchronizationAdapter.beforeCompletion(JtaTransactionSynchronizationAdapter.java:54)
  244. at bitronix.tm.BitronixTransaction.fireBeforeCompletionEvent(BitronixTransaction.java:532)
  245. at bitronix.tm.BitronixTransaction.commit(BitronixTransaction.java:235)
  246. ... 34 more
  247. 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