I'm trying to follow the path indicated by Demian (save and retrieve information from BAM tables) but I simply can not make persistence work.
I get this exception where I try to excute the following junit test :
SimpleNamingContextBuilder builder = SimpleNamingContextBuilder.emptyActivatedContextBuilder();
// Construct DataSource
JdbcDataSource ds = new org.h2.jdbcx.JdbcDataSource();
ds.setURL("jdbc:h2:jdbc/DataSource");
ds.setUser("sa");
ds.setPassword("sa");
builder.bind("jdbc/DataSource", ds);
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"));
env.set( EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager() );
session = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.drools.persistence.jpa.KnowledgeStoreServiceImpl.buildCommanService(KnowledgeStoreServiceImpl.java:116)
... 33 more
Caused by: java.lang.RuntimeException: Could not commit session or rollback
at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:317)
at org.drools.persistence.SingleSessionCommandService.<init>(SingleSessionCommandService.java:130)
... 38 more
Caused by: java.lang.RuntimeException: Unable to rollback transaction
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:189)
at org.drools.persistence.SingleSessionCommandService.rollbackTransaction(SingleSessionCommandService.java:314)
... 39 more
Caused by: java.lang.NullPointerException
at org.drools.persistence.jta.JtaTransactionManager.rollback(JtaTransactionManager.java:185)
I have:
1) Created a persistence.xml file under META-INF (attached)
2)