[rules-users] Multiple Object Referencing error

Fnu Mahalakshmi FMahalakshmi at nyx.com
Mon Jun 7 17:21:39 EDT 2010


Hi David,

I am giving it the input exactly as I put up. It seems to be fine.
Could it be because there are new objects of room formed even though the attributes they hold are similar???

Thank you
M
-----Original Message-----
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of rules-users-request at lists.jboss.org
Sent: Monday, June 07, 2010 5:12 PM
To: rules-users at lists.jboss.org
Subject: rules-users Digest, Vol 43, Issue 31

Send rules-users mailing list submissions to
        rules-users at lists.jboss.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.jboss.org/mailman/listinfo/rules-users
or, via email, send a message with subject or body 'help' to
        rules-users-request at lists.jboss.org

You can reach the person managing the list at
        rules-users-owner at lists.jboss.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of rules-users digest..."


Today's Topics:

   1. Re: Exception using persistence (Robert)
   2. Multiple Object Referencing problem (Fnu Mahalakshmi)
   3. Re: Multiple Object Referencing problem (David Sinclair)


----------------------------------------------------------------------

Message: 1
Date: Mon, 07 Jun 2010 20:49:45 +0200
From: Robert <robert.weissmann at web.de>
Subject: Re: [rules-users] Exception using persistence
To: "Rules Users List" <rules-users at lists.jboss.org>, "Mark Proctor"
        <mproctor at codehaus.org>, "PAYET, Manuel" <manuel.payet at capgemini.com>
Message-ID: <op.vdx087wrgqrarf at ntnbrwe.rgb.systemagmbh.de>
Content-Type: text/plain; charset=iso-8859-15; format=flowed;
        delsp=yes

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 at 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 at lists.jboss.org
> [mailto:rules-users-bounces at lists.jboss.org] De la part de Robert
> Envoy? : lundi 7 juin 2010 16:16
> ? : rules-users at 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 at 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 at 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 at 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 at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


--
Erstellt mit Operas revolution?rem E-Mail-Modul: http://www.opera.com/mail/


------------------------------

Message: 2
Date: Mon, 7 Jun 2010 17:04:19 -0400
From: Fnu Mahalakshmi <FMahalakshmi at nyx.com>
Subject: [rules-users] Multiple Object Referencing problem
To: "'rules-users at lists.jboss.org'" <rules-users at lists.jboss.org>
Message-ID:
        <994758E35590274E955FA75763C5AA5002D01084 at MTEXMBXP01.ad.NYX.com>
Content-Type: text/plain; charset="us-ascii"

Hi,

I am trying out this example from the book :

public class Room {

    private String name

    // getter and setter methods here

}

public classs Sprinkler {

    private Room room;

    private boolean on;

    // getter and setter methods here

}

public class Fire {

    private Room room;

    // getter and setter methods here

}

I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
                           2. with data of sprinkler and Room { " ", r1; " " , r2}

I am writing rule " if fire exists in room start sprinkler" { so if f1 and r1 in this case: I should get s1, r1 }
when
    Fire($room : room)
    $sprinkler : Sprinkler( room == $room, modified == false )
Then
    $sprinkler.setmodified(true);
    modify( $sprinkler ) { setSprinkle( "s1" ) };
end

But this gives me error:
Exception in thread "main" java.lang.NullPointerException
      at java.io.Writer.write(Unknown Source)
      at com.org.RulesTest.main(RulesTest.java:58)

>From what I observed this rule is not getting fired at all.
I want this rule to be fired on the data in my second input file.
The rules for my first input file get executed properly.

Can any1 tell me where I am going wrong??
Is there any way in which we can use the modified data { after rules are fired on the first input data and it is  modified}to fire another set of rules on the same input depending on the next input file???

Thank you.

-M
</pre>

<P><hr size=1></P>
<P><STRONG><font color=green>Please consider the environment before printing this email.</font></STRONG></P>
<P><STRONG>Visit our website at <a href="http://www.nyse.com">http://www.nyse.com</a> <br>

*****************************************************************************
<br>
Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.

</STRONG></P><pre>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100607/87b7206d/attachment-0001.html

------------------------------

Message: 3
Date: Mon, 7 Jun 2010 17:12:16 -0400
From: David Sinclair <dsinclair at chariotsolutions.com>
Subject: Re: [rules-users] Multiple Object Referencing problem
To: Rules Users List <rules-users at lists.jboss.org>
Message-ID:
        <AANLkTikJxjKh0BjNMqFU8RB5Mx10uv5eQ47Rd79d-prS at mail.gmail.com>
Content-Type: text/plain; charset="windows-1252"

This has nothing to do with Drools. It looks like you are giving Writer bad
input perhaps??

Exception in thread "main" *java.lang.NullPointerException*

      at java.io.Writer.write(Unknown Source)

      at com.org.RulesTest.main(*RulesTest.java:58*)




2010/6/7 Fnu Mahalakshmi <FMahalakshmi at nyx.com>

>  Hi,
>
>
>
> I am trying out this example from the book :
>
> public class Room {
>
>     private String name
>
>     // getter and setter methods here
>
> }
>
> public classs Sprinkler {
>
>     private Room room;
>
>     private boolean on;
>
>     // getter and setter methods here
>
> }
>
> public class Fire {
>
>     private Room room;
>
>     // getter and setter methods here
>
> }
>
>
>
> I load 2 input files: 1. with data of fire and Room { f1, r1;f2, r2}
>
>                            2. with data of sprinkler and Room { ? ?, r1; ?
> ? , r2}
>
>
>
> I am writing rule ? if fire exists in room start sprinkler? { so if f1 and
> r1 in this case: I should get s1, r1 }
>
> when
>
>     Fire($room : room)
>
>     $sprinkler : Sprinkler( room == $room, modified == false )
>
> Then
>
>     $sprinkler.setmodified(true);
>
>     modify( $sprinkler ) { setSprinkle( ?s1? ) };
>
> end
>
>
>
> But this gives me error:
>
> Exception in thread "main" *java.lang.NullPointerException*
>
>       at java.io.Writer.write(Unknown Source)
>
>       at com.org.RulesTest.main(*RulesTest.java:58*)
>
>
>
> From what I observed this rule is not getting fired at all.
>
> I want this rule to be fired on the data in my second input file.
>
> The rules for my first input file get executed properly.
>
>
>
> Can any1 tell me where I am going wrong??
>
> Is there any way in which we can use the modified data { after rules are
> fired on the first input data and it is  modified}to fire another set of
> rules on the same input depending on the next input file???
>
>
>
> Thank you.
>
>
>
> -M
>
> ------------------------------
>
> *Please consider the environment before printing this email.*
>
> *Visit our website at http://www.nyse.com
> *****************************************************************************
>
> Note: The information contained in this message and any attachment to it is
> privileged, confidential and protected from disclosure. If the reader of
> this message is not the intended recipient, or an employee or agent
> responsible for delivering this message to the intended recipient, you are
> hereby notified that any dissemination, distribution or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, please notify the sender immediately by replying to
> the message, and please delete it from your system. Thank you. NYSE
> Euronext. *
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100607/942cf4e0/attachment.html

------------------------------

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


End of rules-users Digest, Vol 43, Issue 31
*******************************************
Please consider the environment before printing this email.

Visit our website at http://www.nyse.com

****************************************************

Note:  The information contained in this message and any attachment to it is privileged, confidential and protected from disclosure.  If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.  If you have received this communication in error, please notify the sender immediately by replying to the message, and please delete it from your system.  Thank you.  NYSE Euronext.





More information about the rules-users mailing list