Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F - WHAT WE DID

2014-01-29 Thread SrjTx
So here's what we end up doing.

Updated the camel route coming into switchyard to have a bean in the middle.
This bean is basically a pass-through, but it has a static instance of the
"global" class we need.
As the java object passes thought the bean, we assigned our "global" class
to it, and then we can use it in "thens" by doing something like
ourObject.ourGlobal.foo();

Kind of a hack as your java objects need setter/getter for the "global", but
for now, it works.





--
View this message in context: 
http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876p4027910.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


Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-28 Thread SrjTx
Thanks!



--
View this message in context: 
http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876p4027886.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


Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-27 Thread Wolfgang Laun
On 28/01/2014, SrjTx  wrote:
> Thanks for the reply.
> I have read that section of the docs a multiple times.
>
> Unfortunately, I do not have a handle to the ksession to call setGlobal on.
>
> My knowledge session is created/owned by KIE-WB/Switchyard and we are
> looking for an API so that I can get a handle to something on which I can
> call setGlobal.

I've had a quick look at
   https://docs.jboss.org/author/display/SWITCHYARD/Knowledge+Services
and it seems to me that you need to define








I suspect that "from" should be some Java expression returning the
global object and "to" the global's DRL name, perhaps from the
SwitchYard Context. But the author doesn't provide any examples and no
details.

One other approach you might take is to install a global via a
high-priority one-shot rule:

rule "startup"
salience 9
when
then
   kcontext.getKieRuntime().setGlobal(...,"...");
end

Lastly, you can simply use a static object in some class:

import foo.bar.Globals;
...
then
   Globals.foo.store( whatever );
...

-W

>
> Ideally, I need something like
> xxx.getKnowledgeBaseByName("mykb");
> or maybe
> xxx.getKnowledgePackageByName("mykb");
> or maybe
> xxx.getKnowledgeSessionByName("mykb");
>
> which ever of those I can call setGlobal on.
>
> FYI, our KIE stuff is container managed via maven integration with kie-wb -
> we do not control the lifecycle of any KIE objects kb, package, session,
> etc.
>
> Thanks again
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876p4027881.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


Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-27 Thread SrjTx
Thanks for the reply.
I have read that section of the docs a multiple times.

Unfortunately, I do not have a handle to the ksession to call setGlobal on.

My knowledge session is created/owned by KIE-WB/Switchyard and we are
looking for an API so that I can get a handle to something on which I can
call setGlobal.

Ideally, I need something like
xxx.getKnowledgeBaseByName("mykb");
or maybe
xxx.getKnowledgePackageByName("mykb");
or maybe
xxx.getKnowledgeSessionByName("mykb");

which ever of those I can call setGlobal on.

FYI, our KIE stuff is container managed via maven integration with kie-wb -
we do not control the lifecycle of any KIE objects kb, package, session,
etc.

Thanks again



--
View this message in context: 
http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876p4027881.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


Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-27 Thread Wolfgang Laun
On 28/01/2014, SrjTx  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


Re: [rules-users] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-27 Thread SrjTx
That being said, I figured I could grab the knowledge base that I defined in
KIE and work with its working memory.
Much googling, cannot figure out how to get my knowledge base (or package)
by name.

I must be missing something, seems like this should be straight forward.




--
View this message in context: 
http://drools.46999.n3.nabble.com/Null-pointer-exception-when-using-global-in-rdrl-6-0-1-F-tp4027876p4027879.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] Null pointer exception when using global in rdrl 6.0.1.F

2014-01-27 Thread SrjTx
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

When I try to make a call on X.foo(), I get a null pointer exception.  (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 am guessing I need to write some java code that will create an instance of
X and inject into working memory?  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.



--
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