0

I have created a vocabulary as Network_Vocabulary interface

I have created a class CustomerAgentStatus implements the AgentAction

I have then created an ontology class defining the ontology as:

I was getting an error as :

 java.lang.ExceptionInitializerError

I then followed instructions as had been suggested in a similar problem as follows: http://jade.tilab.com/pipermail/jade-develop/2013q3/019284.html

Accordingly i put the

    **ontology =  NetworkOntology.getInstance();**

inside the setup() method and surrounded it with try/catch

After the stack Trace i got the following errors, I feel there is some error in the ontology class:

I'm getting an error as:

 Java.Lang.ClassCastException: jade.content.schema.Concept Schema cannot be cast to jade      .content.schema.PrimitiveSchema** 

My Ontology class implementation is as follows:

package CellularNetwork;
import jade.content.onto.*;

import jade.content.schema.*;

public class Network_Ontology extends Ontology implements Network_Vocabulary {
public static final String ONTOLOGY_NAME = "Network-Ontology";
private static Ontology instance = new Network_Ontology();
public static Ontology getInstance() { return instance; }
// Private constructor

private Network_Ontology() {

  super(ONTOLOGY_NAME, BasicOntology.getInstance());

  try{

            AgentActionSchema cs = new AgentActionSchema(CUSTOMERAGENTSTATUS);

            add(cs, CustomerAgentStatus.class);

            cs.add(X_CO_ORDINATE, (PrimitiveSchema) getSchema(BasicOntology.FLOAT));

            cs.add(Y_CO_ORDINATE, (PrimitiveSchema) getSchema(BasicOntology.FLOAT));

            cs.add(DIRECTION, (PrimitiveSchema) getSchema(BasicOntology.STRING));

            cs.add(SPEED, (PrimitiveSchema) getSchema(BasicOntology.FLOAT));

            cs.add(CURRENT_PROVIDER,(PrimitiveSchema) getSchema(BasicOntology.AID));        

  }

  catch (OntologyException oe) {

  oe.printStackTrace();

  }

  }

 }// Network_Ontology
Mike Causer
  • 8,196
  • 2
  • 43
  • 63
  • You should remove the Jade tag, it refers to the template engine, not what you're talking about. I couldn't remove it whitout editing at least 6 characters from your post... – Waldo Jeffers Aug 28 '14 at 13:49
  • Sorry, Sir. But I couldn't follow. Actually I was using Ontology feature in Jade for ACLMessaging. Where I came across this error. – Shreeparna Sarkar Aug 28 '14 at 13:59

1 Answers1

0

If you are trying to represent an AID object with CURRENT_PROVIDER, then you have to add this schema as a ConceptSchema object, not as a PrimitiveSchema object. Just change this line:

cs.add(CURRENT_PROVIDER,(PrimitiveSchema) getSchema(BasicOntology.AID)); 

to this:

cs.add(CURRENT_PROVIDER,(ConceptSchema) getSchema(BasicOntology.AID));