info-gnuprologjava
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-gnuprologjava] FW: Errors encountered while executing query wi


From: Daniel Thomas
Subject: Re: [Info-gnuprologjava] FW: Errors encountered while executing query with " runOnce " , " prepareGoal " functionalities .
Date: Wed, 06 Jun 2012 21:58:53 +0100

So you get a error(instantiation_error,error) when you use prepareGoal
as I suggested. This means that a variable term is being used when a
variable is invalid, in particular from the stack trace it shows that
the variable term is being evaluated as an arthmetic expression
(probably using is/1) and this is invalid causing the exception.

So either you can look through your code for incorrect use of is/1 or
similar or you could set a breakpoint in Evaluate on line 153 and see
what variable it is that is being evaluated and so find out where is/1
is being incorrectly used.
The 0.3.x release will provide a better error message for this but I
don't have an ETA for that.

Daniel

On Mon, 2012-06-04 at 18:32 +0530, Suman Roy wrote:
> Hi,
> 
>  
> 
> Here are the codes with the execution results, both for runOnce and
> prepareGoal etc …
> 
>  
> 
> Regards,
> 
> --Suman
> 
>  
> 
> Suman Roy, Ph.D.
> Infosys LABS, 
> 
> Infosys Technologies Ltd.,
> 
> Bangalore, India.     
> 
> Mob. +91 98860 23203 
> 
> 
> 
> 
>  
> 
>  
> 
> For runOnce : 
> 
>  
> 
>  
> 
> package usecase_editr;
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 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.Interpreter.Goal;
> 
> import gnu.prolog.vm.PrologCode;
> 
> import gnu.prolog.vm.PrologException;
> 
> import java.util.logging.Level;
> 
> import java.util.logging.Logger;
> 
> import javax.swing.JOptionPane;
> 
>  
> 
>  
> 
> public class fresh_07 {
> 
>  
> 
>     public static void main (String []args) throws PrologException{
> 
>  
> 
>  
> 
>  
> 
>  
> 
>             gnu.prolog.vm.Environment gve = new Environment();
> 
>             gve.ensureLoaded(AtomTerm.get("D:/jagadish
> java/usecase_editr/src/usecase_editr/latest-rule_11"));
> 
>             Interpreter in = gve.createInterpreter();
> 
>             gve.runInitialization(in);
> 
>  
> 
> VariableTerm vt= new VariableTerm();
> 
> int val= 5;
> 
> IntegerTerm iterm=new IntegerTerm(val);
> 
>  
> 
> Term t1[]={vt,iterm};
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> Term t2[]={AtomTerm.get("receiveFreightInvoice1")};
> 
>  
> 
>  
> 
> CompoundTerm ct1=new CompoundTerm("limited_history",t1);
> 
>  
> 
>  
> 
>  
> 
> CompoundTerm ct2=new CompoundTerm("end",t2);
> 
>  
> 
> VariableTerm dcare= new VariableTerm();
> 
>  
> 
> CompoundTerm ct3=new
> CompoundTerm(CompoundTermTag.get("c",3),ct2,dcare,vt);
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>         int chk =in.runOnce(ct3);
> 
>  
> 
>            if (chk == PrologCode.SUCCESS || chk ==
> PrologCode.SUCCESS_LAST) {
> 
>                 System.out.println("Succesful execution ");
> 
>             }
> 
>            else {
> 
>                 System.out.println("Failed execution ");
> 
>            }
> 
>  
> 
>  
> 
>  
> 
>         }
> 
>         }
> 
>  
> 
>  
> 
>  
> 
> Error : run: 
> 
>  
> 
> Exception in thread "main" java.lang.IllegalArgumentException: The
> goal is not currently active
> 
>         at gnu.prolog.vm.Interpreter.stop(Interpreter.java:564)
> 
>         at gnu.prolog.vm.Interpreter.runOnce(Interpreter.java:629)
> 
>         at usecase_editr.fresh_07.main(fresh_07.java:61)
> 
> Java Result: 1
> 
> BUILD SUCCESSFUL (total time: 1 second)
> 
>  
> 
>  
> 
>  
> 
> For Prepare goal : 
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 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.Interpreter.Goal;
> 
> import gnu.prolog.vm.PrologCode;
> 
> import gnu.prolog.vm.PrologException;
> 
> import java.util.logging.Level;
> 
> import java.util.logging.Logger;
> 
> import javax.swing.JOptionPane;
> 
>  
> 
>  
> 
> public class fresh_07 {
> 
>  
> 
>     public static void main (String []args) throws PrologException{
> 
>  
> 
>  
> 
>  
> 
>  
> 
>             gnu.prolog.vm.Environment gve = new Environment();
> 
>             gve.ensureLoaded(AtomTerm.get("D:/jagadish
> java/usecase_editr/src/usecase_editr/latest-rule_11"));
> 
>             Interpreter in = gve.createInterpreter();
> 
>             gve.runInitialization(in);
> 
>  
> 
>  
> 
>  
> 
> VariableTerm vt= new VariableTerm();
> 
> int val= 5;
> 
> IntegerTerm iterm=new IntegerTerm(val);
> 
>  
> 
> Term t1[]={vt,iterm};
> 
>  
> 
>  
> 
>  
> 
>  
> 
>  
> 
> Term t2[]={AtomTerm.get("receiveFreightInvoice1")};
> 
>  
> 
>  
> 
> CompoundTerm ct1=new CompoundTerm("limited_history",t1);
> 
>  
> 
>  
> 
>  
> 
> CompoundTerm ct2=new CompoundTerm("end",t2);
> 
>  
> 
> VariableTerm dcare= new VariableTerm();
> 
>  
> 
> CompoundTerm ct3=new
> CompoundTerm(CompoundTermTag.get("happens3",3),ct2,dcare,vt);
> 
>  
> 
>  
> 
>  
> 
>  
> 
>         Goal prepareGoal1 = in.prepareGoal(ct3);
> 
>  
> 
>  
> 
>  
> 
>         int chk =in.execute(prepareGoal1);
> 
>  
> 
>            if (chk == PrologCode.SUCCESS || chk ==
> PrologCode.SUCCESS_LAST) {
> 
>                 System.out.println("Succesful execution ");
> 
>             }
> 
>            else {
> 
>                 System.out.println("Failed execution ");
> 
>            }
> 
>  
> 
>  
> 
>  
> 
>         }
> 
>         }
> 
>  
> 
>  
> 
>  
> 
> Error : 
> 
> Exception in thread "main" gnu.prolog.vm.PrologException:
> error(instantiation_error,error)
> 
>         at
> gnu.prolog.vm.PrologException.getError(PrologException.java:129)
> 
>         at
> gnu.prolog.vm.PrologException.getError(PrologException.java:118)
> 
>         at
> gnu.prolog.vm.PrologException.instantiationError(PrologException.java:145)
> 
>         at gnu.prolog.vm.Evaluate.evaluate(Evaluate.java:153)
> 
>         at gnu.prolog.vm.Evaluate.evaluate(Evaluate.java:164)
> 
>         at
> gnu.prolog.vm.buildins.arithmetics.Predicate_is.execute(Predicate_is.java:35)
> 
>         at
> gnu.prolog.vm.interpreter.InterpretedByteCode.execute(InterpretedByteCode.java:522)
> 
>         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_07.main(fresh_07.java:64)
> 
> Java Result: 1
> 
> BUILD SUCCESSFUL (total time: 0 seconds)
> 
>  
> 
> 
> **************** 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***

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]