Menu

Null pointer

Help
yanet
2016-06-23
2016-06-23
  • yanet

    yanet - 2016-06-23

    Hi, I am traying this simple example and i hav a null pointer exception , I can´t see where

    @Agent
    public class TestBDI {
    @AgentFeature
    protected IBDIAgentFeature bdi;

    String f;
    
    @Belief 
    Map <String, String> frases;
    
    
    @AgentCreated
    public void init (){
    
        frases = new HashMap<String, String>();
        frases.put("Nombre", "Alice");
        frases.put("Edad", "40");
        frases.put("Cancer","No puede ser");
        frases.put("Buenas", "Buen dia");
        frases.put("Nada", "Gracias a Dios!");
        frases.put("Lo siento", "Usted está equivocado. Adios");
    
    
    }
    
    
    
    @Goal
    class Responder{
        protected String frase;
    
        public Responder(String f){
            frase = f;
        }
    
        public void setFrase(String f){
            frase = f;
        }
    
        public String getFrase(){
            return frase;
        }
    
    }
    
    @Plan(trigger=@Trigger(goals=Responder.class))
    public void Responder(Responder g){
    
       System.out.println(frases.get(g.frase) );
    
    }
    
    @AgentBody
    
    public IFuture<Void> Do(){
    
        Scanner preg = new Scanner(System.in);
        f = preg.next();        
        Responder resp= (Responder) bdi.dispatchTopLevelGoal(new Responder(f)).get();
    
    return IFuture.DONE;
    
    }
    

    }

    The null pointer is on

    Responder resp= (Responder) bdi.dispatchTopLevelGoal(new Responder(f)).get();

    Thx

     
  • yanet

    yanet - 2016-06-23

    Hi, It run ok, whit JCC , but I want it run whit java debugger , because I need to see step by step the execution, How can I do this??

    Thx, a lot

     

    Last edit: yanet 2016-06-23
  • yanet

    yanet - 2016-06-23

    hello???

     
  • Lars Braubach

    Lars Braubach - 2016-06-23

    The same way as any other Java program. Use 'debug' in eclipse and use jadex.base.Starter as start class.

     
  • yanet

    yanet - 2016-06-23

    Hi, first , Thanks for helping me, I did , but I have the same error,

     
  • Lars Braubach

    Lars Braubach - 2016-06-23

    Open 'this' in variable view and check which fields are null. Is bdi null? Is f null? etc.

     
  • yanet

    yanet - 2016-06-23

    bdi,

     
  • Lars Braubach

    Lars Braubach - 2016-06-23

    Then injection does not work. Is the annotation in place?

     
  • yanet

    yanet - 2016-06-23

    I think so,

     
  • yanet

    yanet - 2016-06-23

    It works in JCC,

     
  • yanet

    yanet - 2016-06-23

    I can´t find the problem... Maybe I am doing somthing wrong, how do you debug this code in eclipse

    thx

     

    Last edit: yanet 2016-06-23

Log in to post a comment.

MongoDB Logo MongoDB