java.lang.ClassNotFoundException:weka.core.FastVector

java.lang.ClassNotFoundException:weka.core.FastVector,java,weka,classnotfoundexception,Java,Weka,Classnotfoundexception,我有一个方法,在这个方法中我创建了一个arff文件,并且如果我运行它(在主方法中使用代码),它将按预期工作。当我尝试将代码放入另一个方法中,然后从另一个类(在我的例子中是从servlet类)调用该方法时,当调用构造函数时,我会从上面得到错误。我的wekka jar是3.8.1,FastVector类是去润滑的。你知道我该怎么解决这个问题吗?代码如下: public void createTestData(int id_student, String teacher_subject, int id

我有一个方法,在这个方法中我创建了一个arff文件,并且如果我运行它(在主方法中使用代码),它将按预期工作。当我尝试将代码放入另一个方法中,然后从另一个类(在我的例子中是从servlet类)调用该方法时,当调用构造函数时,我会从上面得到错误。我的wekka jar是3.8.1,FastVector类是去润滑的。你知道我该怎么解决这个问题吗?代码如下:

public void createTestData(int id_student, String teacher_subject, int id_level, boolean isMand)
        throws IOException {
    FastVector attribute, attributeVals;
    Instances data;
    Instances dataRel;
    double[] vals;

    String isMandatory = "" + isMand;
    int level = 10;

    String teacher = teacher_subject.split("-")[1];
    String subject = teacher_subject.split("-")[0];

    // 1. set up attributes
    attribute = new FastVector();
    attribute.addElement(new Attribute("id_student"));

    // - string
    attribute.addElement(new Attribute("subject", (FastVector) null));
    attribute.addElement(new Attribute("teacher", (FastVector) null));

    // - numeric
    attribute.addElement(new Attribute("level"));
    // - nominal
    attributeVals = new FastVector();
    attributeVals.addElement("true");
    attributeVals.addElement("false");
    attribute.addElement(new Attribute("isMandatory", attributeVals));
    // attribute.addElement(new Attribute("rezult"));

    // 2. create Instances object
    data = new Instances("MyRelation", attribute, 0);

    // 3. fill with data
    // first instance
    vals = new double[data.numAttributes()];
    // - numeric
    vals[0] = id_student;
    // - nominal
    vals[1] = data.attribute(1).addStringValue(subject);
    // - string
    vals[2] = data.attribute(2).addStringValue(teacher);
    // - date
    vals[3] = level;
    vals[4] = attributeVals.indexOf(isMandatory);
    // vals[5] = 10;
    // add
    data.add(new DenseInstance(1.0, vals));
    // 4. output data
    System.out.println(data);

    ArffSaver arffSaverInstance = new ArffSaver();
    arffSaverInstance.setInstances(data);
    arffSaverInstance.setFile(new File("test.arff"));
    arffSaverInstance.writeBatch();
}
在servlet类中:

DataForTrain testData = new DataForTrain();
    try {
        testData.createTestData(id_student, teacher_subject, id_level, isMandatory);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

解决方案是在Properties serch上找到Web部署程序集(右键单击项目=>Properties=>add=>Archives from file system并在那里添加weka jar。

运行软件的服务器上是否有该类的jar文件?