On 28/01/2014, SrjTx <clickt...@yahoo.com> wrote: > I have a class that I declared final, has a private constructor, has only > static members and methods. > Some of its members are static instance of classes. > In KIE-WBI added a global of that type with name X
You can't use a global that has a type X as you describe it, as you won't be able to instantiate an X object if the constructor is private. (OK, you could have a static getInstance method according to the singleton pattern - but the use of an object where everything in the class is static is rather doubtful.) > > When I try to make a call on X.foo(), I get a null pointer exception. Well, if there's no object you haven't initialised the global. > (note > that x.foo() calls y.foo(), where y is a static member of X. > > I've read some posts that a global has to be static, am I stretching, what > it means for a global to be static? I don't know where you've read that, but do read the documentation first. > > I am guessing I need to write some java code that will create an instance > of > X and inject into working memory? You are guessing, and you are guessing wrong. kSession.setGlobal( "theDRLnameOfTheGlobal", new XbutNotAsYouDescribedIt() ) > I was hoping to be able to create this > object within either the drools or SY framework. > > I have googled and be reading on this for quite a bit now, but I think I > have succeeded only in confusing myself. > > Any help greatly appreciated. Documentation, 7.5.2, global - about all you need to know. -W > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users