I’m constructing an application in Google App Engine (using Eclipse) that uses WEKA [1] in one of its parts. This app needs to load ARFF bases, but that’s allright. The directory in which these bases are is in project’s root directory. Following lines are responsible for loading bases:
1. DataSource source;
2. source = new DataSource("bases/iris.arff");
3. Instances trainInstances = source.getDataSet();
4. trainInstances.setClassIndex(trainInstances.numAttributes() - 1);
Above lines are part of the code that is called in a servlet responsible for execution of the application. Servlet runs ok, but ‘source’ variable doesn’t get to read arff file and, so, i get the following exception at line 3:
“java.io.IOException: No source has been specified
at weka.core.converters.ArffLoader.getDataSet(ArffLoader.java:1003)”
According to [2],
It is possible to read from a file which is uploaded as part of your application provided that it is in the following locations: war/WEB-INF // in a location matching the pattern in appengine-web.xml (which by default includes everything)
I’ve followed this two points, but with no sucess. To the second one, my configuration was the following:
<resource-files>
<include path="/bases/**.arff" />
</resource-files>
Given this long history, I ask to you: Is there anyway to put “bases” directory in some place, or configuring something on GAE xml files, or on Eclipse, that make possible ARFF bases be loaded?
References
[1] http://www.cs.waikato.ac.nz/ml/weka/
[2] https://developers.google.com/appengine/kb/java#readfile
Your problem is more about loading resources in web application environment.
Some additional resources in stackoverflow about loading resources in web application environment.
Put your arff file in your source-src directory. When you compile your application, files under this directory copied to web-inf/classes directory.
See
You can see where they are copied if you create a war file. See
After you make sure that your arff file is included in your web archive file (war file). You can use appropriate path to it. Like below. You need to use InputStream constructor not String one.
I have tried this with simple web application project, it works. My code is as below.
deneme.jsp
LoadArffFile.java
Output in tomcat.