[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Info-gnuprologjava] Problem on firing a query
From: |
Daniel Thomas |
Subject: |
Re: [Info-gnuprologjava] Problem on firing a query |
Date: |
Fri, 01 Jun 2012 10:07:34 +0100 |
Since I don't have the prolog file which defines the limited_history
predicate when I try to run the code you sent me I get an existence
error because the predicate is not defined. (the meaning of
existence_error is defined in the prolog standard)
If you switch your runOnce for a prepareGoal and then execute then you
will get the actual correct error rather than an unhelpful one.
Daniel
On Fri, 2012-06-01 at 08:59 +0000, Jagadish Koneti wrote:
> Hello ,
>
> Thank you for the reply . can you please elaborate on what exactly "
> error(existence_error(procedure,limited_history / 2),error) " implies ? . we
> have understood that limited_history is a 2 array predicate but we are unable
> to comprehend more than that .
>
>
> Thanks
> Jagadish koneti
> Infosys , Bangalore .
>
>
>
> -----Original Message-----
> From: address@hidden [mailto:address@hidden On Behalf Of Daniel Thomas
> Sent: Thursday, May 31, 2012 2:10 AM
> To: Suman Roy
> Cc: address@hidden
> Subject: Re: [Info-gnuprologjava] Problem on firing a query
>
> So this is the runOnce causing unhelpful error messages problem again.
>
> Also:
> > catch (Exception e) {
> >
> > System.out.println("fail");
> >
> > }
> Is bad practice and very unhelpful for debugging.
>
> After fixing that and using prepareGoal and then execute.
>
> gnu.prolog.vm.PrologException:
> error(existence_error(procedure,limited_history / 2),error)
> at gnu.prolog.vm.PrologException.getError(PrologException.java:129)
> at gnu.prolog.vm.PrologException.getError(PrologException.java:118)
> at
> gnu.prolog.vm.PrologException.existenceError(PrologException.java:155)
> at
> gnu.prolog.vm.UndefinedPredicateCode.execute(UndefinedPredicateCode.java:62)
> at
> gnu.prolog.vm.interpreter.InterpretedByteCode.execute(InterpretedByteCode.java:522)
> at
> gnu.prolog.vm.interpreter.Predicate_call.staticExecute(Predicate_call.java:144)
> at gnu.prolog.vm.Interpreter.execute(Interpreter.java:507)
> at Fresh_06.main(Fresh_06.java:74)
>
> Which makes it fairly clear as to what the problem is.
>
> You might get a different error as "D:/RSAE/latest-rule_11.pl" might exist on
> your computer.
>
> I hope that helps,
>
> Daniel
>
> On Mon, 2012-05-28 at 16:44 +0530, Suman Roy wrote:
> > Hi,
> >
> >
> >
> > We are using the following code to generate the query
> >
> >
> >
> > “limited_history(H,5),happens3(end(dofulfillmentProcess1),_,H).”
> >
> >
> >
> > This has to be fired on prolog rules (attached) written for business
> > artifact. However, when this query is fired through gnuprolog java JAR
> > file, it is showing that
> >
> > “the current goal is not active’.
> >
> >
> >
> > But this query works fine when we fire them directly to prolog!
> >
> >
> >
> > Can you please tell us what is the problem?
> >
> >
> >
> > Thanks and regards,
> >
> > --Suman
> >
> >
> >
> >
> >
> > ====================================
> >
> >
> >
> >
> >
> > package RSAE.util;
> >
> >
> >
> > import gnu.prolog.term.AtomTerm;
> >
> > import gnu.prolog.term.CompoundTerm;
> >
> > import gnu.prolog.term.CompoundTermTag;
> >
> > import gnu.prolog.term.IntegerTerm;
> >
> > import gnu.prolog.term.Term;
> >
> > import gnu.prolog.term.VariableTerm;
> >
> > import gnu.prolog.vm.Environment;
> >
> > import gnu.prolog.vm.Interpreter;
> >
> > import gnu.prolog.vm.PrologCode;
> >
> >
> >
> > public class Fresh_06 {
> >
> >
> >
> > public static void main(String[] args) {
> >
> >
> >
> >
> >
> >
> >
> > //limited_history(H,5),happens3(end(dofulfillmentProcess1),_,H).
> >
> > try {
> >
> > VariableTerm H = new VariableTerm();
> >
> > gnu.prolog.vm.Environment gve = new Environment();
> >
> >
> > gve.ensureLoaded(AtomTerm.get("D:/RSAE/latest-rule_11.pl"));
> >
> > Interpreter in = gve.createInterpreter();
> >
> > gve.runInitialization(in);
> >
> >
> >
> >
> >
> > Term lHistory[] = { H, new IntegerTerm(5) };
> >
> > CompoundTerm lTerm = new
> > CompoundTerm("limited_history", lHistory);
> >
> > //replace with process code works
> >
> > Term t1[] = { AtomTerm.get("sendFreightInvoice1") };
> >
> > CompoundTerm cTerm2 = new CompoundTerm(",", 2);
> >
> > CompoundTerm ct1 = new CompoundTerm("end", t1);
> >
> > CompoundTerm gTerm1 = new
> > CompoundTerm(CompoundTermTag.get(
> >
> > "happens3", 3), ct1, new VariableTerm(),
> > H);
> >
> >
> >
> > cTerm2.args[0] = lTerm;
> >
> > cTerm2.args[1] = gTerm1;
> >
> > int rc = in.runOnce(cTerm2);
> >
> >
> >
> > if (rc == PrologCode.SUCCESS || rc ==
> > PrologCode.SUCCESS_LAST) {
> >
> > System.out.println("success");
> >
> > }
> >
> > }
> >
> >
> >
> > catch (Exception e) {
> >
> > System.out.println("fail");
> >
> > }
> >
> > }
> >
> > }
> >
> >
> >
> > ========================================
> >
> >
> >
> >
> > **************** CAUTION - Disclaimer ***************** This e-mail
> > contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for
> > the use of the addressee(s). If you are not the intended recipient,
> > please notify the sender by e-mail and delete the original message.
> > Further, you are not to copy, disclose, or distribute this e-mail or
> > its contents to any other person and any such actions are unlawful.
> > This e-mail may contain viruses. Infosys has taken every reasonable
> > precaution to minimize this risk, but is not liable for any damage you
> > may sustain as a result of any virus in this e-mail. You should carry
> > out your own virus checks before opening the e-mail or attachment.
> > Infosys reserves the right to monitor and review the content of all
> > messages sent to or from this e-mail address. Messages sent to or from this
> > e-mail address may be stored on the Infosys e-mail system.
> > ***INFOSYS******** End of Disclaimer ********INFOSYS***
>
signature.asc
Description: This is a digitally signed message part