I think I ran into exactly this problem yesterday.
I'll describe what I was doing.

I have a thread in which I batch load my rules script, and then run it.
This is my main rete thread.

      rete.executeCommand("(batch xxx.clp)");
      rete.executeCommand("(reset)");
      rete.executeCommand("(run)");

In another thread from my java code I get the rete instance, and
call assertString to put in some stuff which would fire some rules.

      rete.assertString("(justdoit)");

This doesn't work. Doing this in the rules script works.

The problem, I realized, was because in assertString() the engine
tries to lock m_tis to parse the facts. This however will block
because the (run) in the main thread would already have locked it.
So it's a deadlock situation.

The way I found around this was to use Funcall to do assert.

      Funcall f = new Funcall("assert", rete);
      f.add(new Value(new Fact("justdoit", rete), RU.FACT));
      f.execute(rete.getGlobalContext());

This doesn't try to acquire a lock on m_tis since you're already
parsing the fact yourself to create the Fact object.
Of course I'm not sure how you'd do it for a complicated fact,
didn't decipher the parseFact code that far.

It is working for me, of course that doesn't mean I'm right.

Richendra.

Ernest Friedman-Hill wrote:
> 
>       The most likely explanation is that assertString() is
>       throwing an exception that is being ignored in your code. Never write
>       Java catch blocks that look like
> 
>       catch (JessException je) {}
> 
>       Always at least include a print statement in the catch block!
> 
>       If this isn't it, though, show me the -smallest possible, complete
>       example- the reproduces the problem and we'll go from there.
> 
> 
>       I think [EMAIL PROTECTED] wrote:
>       > 
>       > 
>       > Hello Jess Users;
>       > 
>       > I have written rules in *.clp file. In this file some rules are fired,
>       > 
>       > after an assertion is done from Java.
>       > I have used assertString method defined in Rete.java in
>       >  myprogram.java.
>       > But this assert statement is not asserting the fact, and hence
>       > subsequent
>       > rules are not fired.
>       > 
>       > Any body can help me how to solve this problem.
>       > 
>       > If I assert initially  in *.clp file, then my rules are working fine.
>       > 
>       > Thank you
>       > RagJag
>       > 
> 

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to