Robert,
Try this:
create a directory called META-INF in your classpath
in that directory, add a file called jndi.properties
in that file, add the line:
java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextFactory
Does that fix things?
Alan
Robert <robert.weissmann(a)web.de
Sent by:
rules-users-bounces(a)lists.jboss.org
08/06/2010 13:22
Please respond to
Rules Users List <rules-users(a)lists.jboss.org>
To
"Rules Users List" <rules-users(a)lists.jboss.org>, "Mark Proctor"
<mproctor(a)codehaus.org>, "PAYET, Manuel"
<manuel.payet(a)capgemini.com>
cc
Subject
Re: [rules-users] Exception using persistence
I did, but I get the same Exception as before, but on this new line
UserTransaction ut = (UserTransaction) new
InitialContext().lookup("java:comp/UserTransaction" );
08.06.2010 14:10:58 org.eclipse.jetty.util.log.Slf4jLog info
INFO: Logging to
org.slf4j.impl.JDK14LoggerAdapter(org.eclipse.jetty.util.log) via
org.eclipse.jetty.util.log.Slf4jLog
Exception in thread "main" javax.naming.NameNotFoundException; remaining
name 'UserTransaction'
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:576)
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:663)
at
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:678)
at
org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:110)
at
javax.naming.InitialContext.lookup(InitialContext.java:392)
at com.rob.tests.AnyTest$.test2(AnyTest.scala:38)
at com.rob.tests.AnyTest$.main(AnyTest.scala:18)
at com.rob.tests.AnyTest.main(AnyTest.scala)
I still don't understand where the "java:comp/UserTransaction" will be
accessible/come-from/being-created ... ?
Am 08.06.2010, 13:42 Uhr, schrieb PAYET, Manuel
<manuel.payet(a)capgemini.com>:
I've made the same mistake at the beginning:
You'd probably want to replace:
val emf : EntityManagerFactory =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" )
val env : Environment = KnowledgeBaseFactory.newEnvironment()
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf )
val ksession : StatefulKnowledgeSession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env )
val sessionId = ksession.getId
ksession.startProcess( "Process4" )
ksession.dispose();
By:
UserTransaction ut =
(UserTransaction) new InitialContext().lookup(
"java:comp/UserTransaction" );
ut.begin();
val emf : EntityManagerFactory =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" )
val env : Environment = KnowledgeBaseFactory.newEnvironment()
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf )
val ksession : StatefulKnowledgeSession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env )
val sessionId = ksession.getId
ksession.startProcess( "Process4" )
ksession.dispose();
Ut.commit();
(you didn't open a transaction before ;))
-----Message d'origine-----
De : robert.weissmann(a)web.de [mailto:robert.weissmann@web.de]
Envoyé : mardi 8 juin 2010 13:42
À : Rules Users List; Mark Proctor; PAYET, Manuel
Objet : Re: [rules-users] Exception using persistence
Ok, let me start from what the drools doc descripes at
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-flow/html...
Here is my code
val kbuilder: KnowledgeBuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder
kbuilder.add(ResourceFactory.newClassPathResource("processes/process4.rf"),
ResourceType.DRF);
val kbase: KnowledgeBase = kbuilder.newKnowledgeBase
val ds : PoolingDataSource = new PoolingDataSource()
ds.setUniqueName("jdbc/processInstanceDS")
ds.setClassName("org.h2.jdbcx.JdbcDataSource")
ds.setMaxPoolSize(3)
ds.setAllowLocalTransactions(true)
ds.getDriverProperties().put("user", "sa")
ds.getDriverProperties().put("password", "sasa")
ds.getDriverProperties().put("URL",
"jdbc:h2:file:/NotBackedUp/data/process-instance-db")
ds.init
val emf : EntityManagerFactory =
Persistence.createEntityManagerFactory( "org.drools.persistence.jpa" )
val env : Environment = KnowledgeBaseFactory.newEnvironment()
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf )
val ksession : StatefulKnowledgeSession =
JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env )
val sessionId = ksession.getId
ksession.startProcess( "Process4" )
ksession.dispose();
and the persistence.xml:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?> <persistence
version="1.0"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="org.drools.persistence.jpa">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/processInstanceDS</jta-data-source>
<class>org.drools.persistence.session.SessionInfo</class>
<class>org.drools.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo</class>
> <class>org.drools.persistence.processinstance.WorkItemInfo</class>
>
> <properties>
> <property name="hibernate.dialect"
> value="org.hibernate.dialect.H2Dialect"/>
> <property name="hibernate.max_fetch_depth"
value="3"/>
> <property name="hibernate.hbm2ddl.auto"
value="update"/>
> <property name="hibernate.show_sql" value="true"/>
> <property name="hibernate.transaction.manager_lookup_class"
> value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
> </properties>
> </persistence-unit>
> </persistence>
>
>
> Thats pretty much whats in the drools doc.
>
> But I get
>
>
> 08.06.2010 13:31:52 org.hibernate.cfg.annotations.Version <clinit>
> INFO: Hibernate Annotations 3.4.0.GA
> 08.06.2010 13:31:52 org.hibernate.cfg.Environment <clinit>
> INFO: Hibernate 3.3.0.SP1
> 08.06.2010 13:31:52 org.hibernate.cfg.Environment <clinit>
> INFO: hibernate.properties not found
> 08.06.2010 13:31:52 org.hibernate.cfg.Environment buildBytecodeProvider
> INFO: Bytecode provider name : javassist 08.06.2010 13:31:52
> org.hibernate.cfg.Environment <clinit>
> INFO: using JDK 1.4 java.sql.Timestamp handling 08.06.2010 13:31:52
> org.hibernate.annotations.common.Version <clinit>
> INFO: Hibernate Commons Annotations 3.1.0.GA 08.06.2010 13:31:52
> org.hibernate.ejb.Version <clinit>
> INFO: Hibernate EntityManager 3.4.0.GA
> 08.06.2010 13:31:53 org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
> org.drools.persistence.session.SessionInfo
> 08.06.2010 13:31:53 org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity org.drools.persistence.session.SessionInfo on table
> SessionInfo 08.06.2010 13:31:53 org.hibernate.cfg.AnnotationBinder
> bindClass
> INFO: Binding entity from annotated class:
> org.drools.persistence.processinstance.ProcessInstanceInfo
> 08.06.2010 13:31:53 org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity
> org.drools.persistence.processinstance.ProcessInstanceInfo on table
> ProcessInstanceInfo 08.06.2010 13:31:53
> org.hibernate.cfg.AnnotationBinder bindClass
> INFO: Binding entity from annotated class:
org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo
> 08.06.2010 13:31:53 org.hibernate.cfg.annotations.EntityBinder bindTable
> INFO: Bind entity
org.drools.persistence.processinstance.variabletypes.VariableInstanceInfo
on table VariableInstanceInfo
08.06.2010 13:31:53 org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class:
org.drools.persistence.processinstance.WorkItemInfo
08.06.2010 13:31:53 org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity org.drools.persistence.processinstance.WorkItemInfo on
> table WorkItemInfo 08.06.2010 13:31:54
> org.hibernate.cfg.annotations.CollectionBinder
> bindOneToManySecondPass
> INFO: Mapping collection:
> org.drools.persistence.processinstance.ProcessInstanceInfo.variables -
> VariableInstanceInfo 08.06.2010 13:31:54
> org.hibernate.cfg.AnnotationConfiguration
> secondPassCompile
> INFO: Hibernate Validator not found: ignoring 08.06.2010 13:31:54
> org.hibernate.cfg.search.HibernateSearchEventListenerRegister
> enableHibernateSearch
> INFO: Unable to find
> org.hibernate.search.event.FullTextIndexEventListener
> on the classpath. Hibernate Search is not enabled.
> 08.06.2010 13:31:54 org.hibernate.util.NamingHelper getInitialContext
> INFO: JNDI InitialContext properties:{}
> 08.06.2010 13:31:54
org.hibernate.connection.DatasourceConnectionProvider
configure
INFO: Using datasource: jdbc/processInstanceDS 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: H2, version: 1.0.77 (2008-08-16) 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: H2 JDBC Driver, version: 1.0.77 (2008-08-16)
08.06.2010 13:31:56 org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.H2Dialect 08.06.2010 13:31:56
org.hibernate.transaction.TransactionFactoryFactory
buildTransactionFactory
INFO: Transaction strategy:
org.hibernate.ejb.transaction.JoinableCMTTransactionFactory
08.06.2010 13:31:56
org.hibernate.transaction.TransactionManagerLookupFactory
getTransactionManagerLookup
INFO: instantiating TransactionManagerLookup:
org.hibernate.transaction.BTMTransactionManagerLookup
08.06.2010 13:31:56
org.hibernate.transaction.TransactionManagerLookupFactory
getTransactionManagerLookup
INFO: instantiated TransactionManagerLookup 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled 08.06.2010
13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled 08.06.2010
13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch size: 15
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC batch updates for versioned data: disabled 08.06.2010
13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): enabled
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Maximum outer join fetch depth: 3
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled 08.06.2010 13:31:56
org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
08.06.2010 13:31:56 org.hibernate.hql.ast.ASTQueryTranslatorFactory
<init>
INFO: Using ASTQueryTranslatorFactory
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: enabled
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory
createRegionFactory
> INFO: Cache region factory :
> org.hibernate.cache.impl.NoCachingRegionFactory
> 08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Optimize cache for minimal puts: disabled 08.06.2010 13:31:56
> org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Structured second-level cache entries: disabled 08.06.2010
> 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Echoing all SQL to stdout
> 08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Statistics: disabled
> 08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Deleted entity synthetic identifier rollback: disabled 08.06.2010
> 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Default entity-mode: pojo
> 08.06.2010 13:31:56 org.hibernate.cfg.SettingsFactory buildSettings
> INFO: Named query checking : enabled
> 08.06.2010 13:31:56 org.hibernate.impl.SessionFactoryImpl <init>
> INFO: building session factory
> 08.06.2010 13:31:57 org.hibernate.impl.SessionFactoryObjectFactory
> addInstance
> INFO: Not binding factory to JNDI, no JNDI name configured 08.06.2010
> 13:31:57 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> INFO: Running hbm2ddl schema update
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> INFO: fetching database metadata
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> INFO: updating schema
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: table found: PROCESS-INSTANCE-DB.PUBLIC.PROCESSINSTANCEINFO
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: columns: [externalvariables, startdate, lastreaddate, state,
> processinstancebytearray, optlock, processid, lastmodificationdate,
> processinstanceid] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: foreign keys: []
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: indexes: [primary_key_4]
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: table found:
> PROCESS-INSTANCE-DB.PUBLIC.PROCESSINSTANCEINFO_EVENTTYPES
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: columns: [element, processinstanceinfo_processinstanceid]
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: foreign keys: [fk2fd59d8cbee4613c] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: indexes: [fk2fd59d8cbee4613c_index_b] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: table found: PROCESS-INSTANCE-DB.PUBLIC.SESSIONINFO
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: columns: [rulesbytearray, id, startdate, dirty,
> lastmodificationdate] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: foreign keys: []
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: indexes: [primary_key_7]
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: table found: PROCESS-INSTANCE-DB.PUBLIC.VARIABLEINSTANCEINFO
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: columns: [id, persister, name, type, processid] 08.06.2010
> 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: foreign keys: [fk7be49b9f9123c534] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: indexes: [fk7be49b9f9123c534_index_2, primary_key_2] 08.06.2010
> 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: table found: PROCESS-INSTANCE-DB.PUBLIC.WORKITEMINFO
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: columns: [workitembytearray, name, workitemid, state, optlock,
> creationdate, processinstanceid] 08.06.2010 13:31:57
> org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: foreign keys: []
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.TableMetadata <init>
> INFO: indexes: [primary_key_b]
> 08.06.2010 13:31:57 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
> INFO: schema update complete
> 08.06.2010 13:31:57 bitronix.tm.BitronixTransactionManager logVersion
> INFO: Bitronix Transaction Manager version 1.3.2 08.06.2010 13:31:57
> bitronix.tm.Configuration buildServerIdArray
> WARNUNG: cannot get this JVM unique ID. Make sure it is configured and
> you only use ASCII characters. Will use IP address instead (unsafe for
> production usage!).
> 08.06.2010 13:31:58 bitronix.tm.Configuration buildServerIdArray
> INFO: JVM unique ID: <192.168.254.2>
> 08.06.2010 13:31:58 bitronix.tm.journal.DiskJournal open
> WARNUNG: active log file is unclean, previous server crash ?
> 08.06.2010 13:31:58 bitronix.tm.recovery.Recoverer run
> INFO: recovery committed 0 dangling transaction(s) and rolled back 0
> aborted transaction(s) on 1 resource(s) [jdbc/processInstanceDS]
> 08.06.2010 13:31:58 org.eclipse.jetty.util.log.Slf4jLog info
> INFO: Logging to
> org.slf4j.impl.JDK14LoggerAdapter(org.eclipse.jetty.util.log) via
> org.eclipse.jetty.util.log.Slf4jLog
> Exception in thread "main" java.lang.RuntimeException: Could not commit
> session
> at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
> at
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
> at
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
> at com.rob.tests.AnyTest$.test2(AnyTest.scala:44)
> at com.rob.tests.AnyTest$.main(AnyTest.scala:18)
> at com.rob.tests.AnyTest.main(AnyTest.scala)
> Caused by: javax.naming.NameNotFoundException; remaining name
> 'UserTransaction'
> at
> org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:576)
> at
> org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:663)
> at
> org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:678)
> at
org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:110)
> at javax.naming.InitialContext.lookup(InitialContext.java:392)
> at
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:109)
> ... 5 more
>
> (This test is in a class file called "AnyTest.scala")
>
> Cheers, Rob
>
> P.S. Thanks for your patience and help.
>
>
> Am 08.06.2010, 09:44 Uhr, schrieb PAYET, Manuel
> <manuel.payet(a)capgemini.com>:
>
>> Robert, what's your application server, or your transaction manager?
>> I successfully tested with bitronix in my J2SE application, and with
>> the jboss application server transaction manager.
>>
>> I don't have any further idea for your problem, but, from my own point
>> of view, it's not so dirty to bind it to java:comp/UserTransaction,
>> and is probably your only way to do things without patching the code
>> (as you seem to have seen in the source code
>> "java:comp/UserTransaction" is not in a variable so...
>>
>> -----Message d'origine-----
>> De : robert.weissmann(a)web.de [mailto:robert.weissmann@web.de] Envoyé :
>> lundi 7 juin 2010 20:50 À : Rules Users List; Mark Proctor; PAYET,
>> Manuel Objet : Re: [rules-users] Exception using persistence
>>
>> For additional information:
>>
>> JPAKnowledgeService.newStatefulKnowledgeSession uses
>>
>> org.drools.persistence.session.SingleSessionCommandService
>>
>> where "java:comp/UserTransaction" is used (I checked the drools source
>> code). Looks like there is no way to change this.
>>
>> I just wonder that I am the only one having this problem.
>>
>> As I said "comp/UserTransaction" works, but
"java:comp/UserTransaction"
>> doesn't, but in the docs "java:comp/UserTransaction" is used
!?!?!?
>>
>> Cheers, Rob.
>>
>> Am 07.06.2010, 16:22 Uhr, schrieb PAYET, Manuel
>> <manuel.payet(a)capgemini.com>:
>>
>>> It's probably that your transaction manager, for an odd reason,
>>> doesn't bind with the good name; You can do the following workaround:
>>>
>>> Final InitialContext initContext = new InitialContext();
>>>
initContext.bind("java:comp/UserTransaction",initContext.lookup("comp
>>> /
>>> UserTransaction"));
>>>
>>> And voila, those two jndi name should point to the same object.
>>>
>>> I stress the fact that what I've written hasn't been tested.
>>>
>>> -----Message d'origine-----
>>> De : rules-users-bounces(a)lists.jboss.org
>>> [mailto:rules-users-bounces@lists.jboss.org] De la part de Robert
>>> Envoyé : lundi 7 juin 2010 16:16 À : rules-users(a)lists.jboss.org;
>>> Mark Proctor Objet : Re: [rules-users] Exception using persistence
>>>
>>> Hi,
>>>
>>> still struggling with this one (see below),
>>>
>>> but I did a slide change in the test-code
>>>
>>> try {
>>> val env = new java.util.Hashtable[String, String]
>>> env.put(Context.INITIAL_CONTEXT_FACTORY,
>>> "bitronix.tm.jndi.BitronixInitialContextFactory")
>>> val ctx = new InitialContext(env)
>>> val ut1 : UserTransaction = (ctx.lookup(
>>> "java:comp/UserTransaction")).asInstanceOf[UserTransaction]
>>> } catch {
>>> case ex: Exception => ex.printStackTrace()
>>> }
>>>
>>> (Sorry, code is in Scala, but should not be a problem to read it).
>>>
>>> Instead of "java:comp/UserTransaction" (as written in the docs) I
>>> wrote "comp/UserTransaction" and it works.
>>>
>>> But since this is some test-code and I am able to do the look-up as I
>>> want ("comp/UserTransaction"), as soon as I use
>>>
>>>
>>> JPAKnowledgeService.newStatefulKnowledgeSession( kbase, null, env )
>>>
>>>
>>> I have no influence anymore (its drools-code ;-) and it looks like
>>> its using internally "java:comp/UserTransaction".
>>>
>>>
>>> Is there any way to change this (setting it) ?
>>>
>>> Cheers, Rob
>>>
>>>
>>>
>>> Am 01.06.2010, 23:54 Uhr, schrieb Robert <robert.weissmann(a)web.de>:
>>>
>>>> Well, I tried this but it does not work.
>>>>
>>>> Checking additionally the BitronixInitialContextFactory API where it
>>>> says:
>>>>
>>>> ---------------------------------------------
>>>> "Implementation of InitialContextFactory that allows lookup of
>>>> transaction manager and registered resources.
>>>>
>>>> The easiest way to use this provider is to create a jndi.properties
>>>> file in your classpath with this content:
>>>> java.naming.factory.initial=bitronix.tm.jndi.BitronixInitialContextF
>>>> a c tory Alternatively, you can create a InitialContext object with
>>>> an environment pointing to this class:
>>>> Hashtable env = new Hashtable();
>>>> env.put(Context.INITIAL_CONTEXT_FACTORY,
>>>> "bitronix.tm.jndi.BitronixInitialContextFactory");
>>>> Context ctx = new InitialContext(env);
>>>>
>>>> The transaction manager can be looked up at the standard URL
>>>> java:comp/UserTransaction while resources can be looked up using
>>>> their unique name as set in ResourceBean.getUniqueName(). "
>>>> ---------------------------------------------
>>>>
>>>>
>>>> So, I tried the following ( Its in Scala, but shouldn't be a problem
>>>> to
>>>> read):
>>>>
>>>> try {
>>>> val env = new java.util.Hashtable[String, String]
>>>> env.put(Context.INITIAL_CONTEXT_FACTORY,
>>>> "bitronix.tm.jndi.BitronixInitialContextFactory");
>>>> val ctx = new InitialContext(env);
>>>> val ut1 : UserTransaction = (ctx.lookup(
>>>> "java:comp/UserTransaction"
>>>> )).asInstanceOf[UserTransaction]
>>>> } catch {
>>>> case ex: Exception => ex.printStackTrace()
>>>> }
>>>>
>>>>
>>>> But still getting the same problem as before at line "val ut1 :
>>>> ...".
>>>>
>>>> What I do not get is that the Bitronix API says that the standard
>>>> URL is "java:comp/UserTransaction", but its somehow not found
!?!?!?
>>>>
>>>> Any ideas ?
>>>>
>>>> Cheers, Rob.
>>>>
>>>>
>>>>
>>>> Am 31.05.2010, 02:54 Uhr, schrieb Mark Proctor
>>>> <mproctor(a)codehaus.org>:
>>>>
>>>>> On 30/05/2010 20:28, Robert wrote:
>>>>>> Hi, I followed the instructions on setting up the persistence in
>>>>>> the drools flow doc, but I get the following exception:
>>>>>>
>>>>>>
>>>>>> Exception in thread "main" java.lang.RuntimeException:
Could not
>>>>>> commit session
>>>>>> at
>>>>>
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:133)
>>>>>> at
>>>>>
org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.newStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:44)
>>>>>> at
>>>>>
org.drools.persistence.jpa.JPAKnowledgeService.newStatefulKnowledgeSession(JPAKnowledgeService.java:93)
>>>>>> at
>>>>>
com.rob.server.core.process.drools.tasks.DroolsProcessHandler.<init>(DroolsProcessHandler.scala:130)
>>>>>> at
>>>>>
com.rob.server.core.process.drools.tasks.StartDroolsProcessHandler$.main(DroolsProcessHandler.scala:33)
>>>>> at
>>>>> com.rob.server.core.process.drools.tasks.StartDroolsProcessHandler.
>>>>> m
>>>>> ain(DroolsProcessHandler.scala) Caused by:
>>>>> javax.naming.NameNotFoundException; remaining name
'UserTransaction'
>>>>>> at
>>>>>>
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:576)
>>>>>> at
>>>>>>
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:663)
>>>>>> at
>>>>>>
org.eclipse.jetty.jndi.NamingContext.lookup(NamingContext.java:678)
>>>>>> at
>>>>>
org.eclipse.jetty.jndi.java.javaRootURLContext.lookup(javaRootURLContext.java:110)
>>>>>> at javax.naming.InitialContext.lookup(InitialContext.java:392)
>>>>>> at
>>>>>
org.drools.persistence.session.SingleSessionCommandService.<init>(SingleSessionCommandService.java:109)
>>>>> ... 5 more
>>>>>
>>>>>
>>>>> I have no idea what this means. I guess
>>>>> SingleSessionCommandService is looking up for
"UserTransaction",
>>>>> but whats the "UserTransaction"
>>>>> ?
>>>>>
>>>> You need to configure JTA and JNDI, it uses the standard JNDI
>>>> lookup mechanism to find the UserTransaction it's to be associated
>>>> with.
>>>> See javadocs example here:
>>>>
http://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artif
>>>> a
>>>> c
>>>> t/trunk/target/javadocs/stable/drools-api/org/drools/persistence/jp
>>>> a
>>>> /
>>>> JPAKnowledgeService.html
>>>>
>>>> Each transaction framework has a different way to be configured,
>>>> some are simpler than others.
>>>>
>>>> Mark
>>>>> Cheers, Rob.
>>>>>
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users(a)lists.jboss.org
>>>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>>
>>>
>>
>>
>> --
>> Erstellt mit Operas revolutionärem E-Mail-Modul:
>>
http://www.opera.com/mail/
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>>
>>
>>
>>
>> This message contains information that may be privileged or
>> confidential and is the property of the Capgemini Group. It is
>> intended only for the person to whom it is addressed. If you are not
>> the intended recipient, you are not authorized to read, print,
>> retain, copy, disseminate, distribute, or use this message or any
>> part thereof. If you receive this message in error, please notify the
>> sender immediately and delete all copies of this message.
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
--
Erstellt mit Operas revolutionärem E-Mail-Modul:
http://www.opera.com/mail/
This message contains information that may be privileged or confidential
and is the property of the Capgemini Group. It is
intended only for the person to whom it is addressed. If you are not the
intended recipient, you are not authorized to
read, print, retain, copy, disseminate, distribute, or use this message
or any part thereof. If you receive this message
in error, please notify the sender immediately and delete all copies of
this message.
--
Erstellt mit Operas revolutionärem E-Mail-Modul:
http://www.opera.com/mail/
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users