2017-06-24 1 views
0

私はarffファイルを作成し、それを(mainメソッドのコードを使って)実行すると、期待通りに動作するメソッドがあります。コードを他のメソッドに入れて、他のクラス(私の場合はサーブレットクラスから)からメソッドを呼び出すと、コンストラクターが呼び出されたときに上記のエラーが発生します。私のwekka jarは3.8.1で、FastVectorクラスは使用できません。任意のアイデアどのように私はこれを解決することができますか?サーブレットクラスでjava.lang.ClassNotFoundException:weka.core.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(); 
} 

:ここにコードがある

ソリューションは=>追加(右プロジェクト=> [プロパティ]をクリックします)プロパティSERCH上のWeb配置アセンブリを見つけることだった
DataForTrain testData = new DataForTrain(); 
    try { 
     testData.createTestData(id_student, teacher_subject, id_level, isMandatory); 
    } catch (Exception e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
+0

ソフトウェアを実行しているサーバーで、そのクラスのjarファイルを利用できますか? –

答えて

0

=>ファイルシステムからアーカイブし、そこにweka jarを追加します。