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.BitronixInitialContextFac
> 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/artifac
>> t/trunk/target/javadocs/stable/drools-api/org/drools/persistence/jpa/
>> 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