I am experiencing these errors: when I run my Weka program on the server
side and try to communicate with it using RPC.
Problem instantiating package manager. Using DefaultPackageManager.
Jul 18, 2012 6:20:19 PM
com.google.appengine.tools.development.ApiProxyLocalImpl log
SEVERE: javax.servlet.ServletContext log: Exception while dispatching
incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public
abstract java.util.ArrayList
tts.client.PredictClient.myMethod(java.lang.String[],int,java.util.ArrayList)'
threw an unexpected exception: java.lang.ExceptionInInitializerError
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:35)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:60)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
at
org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at
com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at
com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:370)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at
org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at
org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at
org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
Caused by: java.lang.ExceptionInInitializerError
at weka.core.Utils.readProperties(Utils.java:142)
at weka.core.Capabilities.<init>(Capabilities.java:261)
at weka.filters.Filter.getCapabilities(Filter.java:160)
at weka.filters.unsupervised.attribute.Add.getCapabilities(Add.java:284)
at weka.filters.Filter.getCapabilities(Filter.java:193)
at weka.filters.Filter.testInputFormat(Filter.java:446)
at weka.filters.Filter.setInputFormat(Filter.java:464)
at weka.filters.unsupervised.attribute.Add.setInputFormat(Add.java:310)
at
weka.classifiers.timeseries.core.TSLagMaker.createDateTimestampRemap(TSLagMaker.java:1578)
at
weka.classifiers.timeseries.core.TSLagMaker.getTransformedData(TSLagMaker.java:3077)
at
weka.classifiers.timeseries.WekaForecaster.buildForecaster(WekaForecaster.java:1007)
at tts.server.Predictor.predict(Predictor.java:151)
at
tts.server.PredictClientServlet.myMethod(PredictClientServlet.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 34 more
Any help will be great.
attached is the Predictor.java file the error starts in.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/wCrfKs4QPZoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.
package tts.server;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.TreeMap;
import weka.classifiers.evaluation.NumericPrediction;
import weka.classifiers.timeseries.WekaForecaster;
import weka.core.Attribute;
import weka.core.DenseInstance;
import weka.core.Instances;
public class Predictor {
private TS targetData = null;
private HashSet<String> filters = new HashSet<String>();
private HashSet<PredictionAlgoritm> predictionAlgoritms = new HashSet<PredictionAlgoritm>();
private HashMap<PredictionAlgoritm,Predictions> predictions = new HashMap<PredictionAlgoritm,Predictions>();
private HashSet<String> usedFilters = new HashSet<String>();
//Number of elements to be predicted
private int numPredictions = 3;
//maximum and minimum lag
private int minlag = 1;
private int maxlag = 6;
/**
* Create a new Predictor. The current version already set the algorithms to be used for the prediction
*/
public Predictor() {
predictionAlgoritms.add(PredictionAlgoritm.GAUSSIAN);
predictionAlgoritms.add(PredictionAlgoritm.SMO);
predictionAlgoritms.add(PredictionAlgoritm.LINEAR_REGRESSION);
}
/**
* Set the time series that would be predicted
* @param targetData
* @throws InvalidTSException if the time series is invalid
*/
public void setTargetData(TS targetData) throws InvalidTSException {
if (targetData == null) throw new InvalidTSException("The target time series has not been assigned.");
if (targetData.size() == 0) throw new InvalidTSException("The target time series has now elements.");
if (targetData.invalid()) throw new InvalidTSException("The target time series is invalid.");
this.targetData = targetData;
}
/**
* Check if the filter is in the database
* @param filter the filter that is being tested
* @return true if there is data for this filter, false in any other case
* @throws InvalidFilterException if the filter is not available
*/
public boolean testFilter(String filter) throws InvalidFilterException {
if (filter == null) throw new InvalidFilterException("Filter can not be null");
if (filter.length() == 0 || !filter.matches("[A-Za-z_][\\w_]+")) throw new InvalidFilterException(" Invalid Filter Expression");
return true;
}
/**
* Add a new filter to the predictor (fails silently if the filter is already in the list)
* @param filter the filter to be added
* @throws InvalidFilterException
*/
public void addFilter(String filter) throws InvalidFilterException {
if (filter == null) throw new InvalidFilterException("Filter can not be null");
if (filter.length() == 0 || !filter.matches("[A-Za-z_][\\w_]+")) throw new InvalidFilterException(" Invalid Filter Expression");
this.filters.add(filter.toLowerCase());
}
public TS getTargetData() {
return targetData;
}
public List<Predictions> getPredictions() {
return new ArrayList<Predictions>(this.predictions.values());
}
public List<String> usedFilters() {
return this.usedFilters();
}
public void predict() throws Exception {
//we should add other test in this part
if (this.targetData == null) throw new InvalidTSException("The target time series has not been assigned.");
if (this.targetData.size() == 0) throw new InvalidTSException("The target time series has now elements.");
if (this.filters.isEmpty()) throw new InvalidFilterException("There must be at least one filter assigned");
//here comes the Shiwen Magic
TreeMap<String,TS> featureSeries = loadTimeSeries();
//Create the attributes
ArrayList<Attribute> fvWekaAttributes = new ArrayList<Attribute>();
//Create the for the filter observations
for (String f: featureSeries.keySet()) {
this.usedFilters.add(f);
fvWekaAttributes.add(new Attribute(f));
}
//Create the attribute for the target
fvWekaAttributes.add(new Attribute("target"));
//Create the attribute to handle dates
Attribute dateAtt = new Attribute("Date","yyyy-MM-dd");
fvWekaAttributes.add(dateAtt);
//Create the examples
Instances isTrainingSet = new Instances("TS-Prediction", fvWekaAttributes, this.targetData.size());
for (Date d: this.targetData.getDates()) {
DenseInstance iExample = new DenseInstance(fvWekaAttributes.size());
int c = 0;
for (String f: featureSeries.keySet()) {
iExample.setValue(fvWekaAttributes.get(c),featureSeries.get(f).value(d));
c++;
}
//Set the value for the target data and the time
iExample.setValue(fvWekaAttributes.get(c++),this.targetData.value(d));
iExample.setValue(fvWekaAttributes.get(c), d.getTime());
isTrainingSet.add(iExample);
}
Instances instances = isTrainingSet;
//For each prediction algorithm run a forecaster and create the predictions
for (PredictionAlgoritm algorithm : this.predictionAlgoritms) {
//Create and initialize the forecaster
WekaForecaster forecaster = new WekaForecaster();
forecaster.setFieldsToForecast("target");
forecaster.setBaseForecaster(PredictionAlgoritm.getClassifier(algorithm));
forecaster.setCalculateConfIntervalsForForecasts(numPredictions);
forecaster.getTSLagMaker().setTimeStampField("Date");
forecaster.getTSLagMaker().setMinLag(getMinlag());
forecaster.getTSLagMaker().setMaxLag(getMaxlag());
forecaster.buildForecaster(instances, System.out);
forecaster.primeForecaster(instances);
List<List<NumericPrediction>> forecast = forecaster.forecast(numPredictions, System.err);
//Set the predictions for this algorithm
Predictions preds = new Predictions(this.predictionAlgoritms.toString());
for (int i = 0; i < numPredictions; i++) {
List<NumericPrediction> predsAtStep = forecast.get(i);
for (int j = 0; j < 1; j++) {
NumericPrediction predForTarget = predsAtStep.get(j);
double value = predForTarget.predicted();
double[][] confidence = predForTarget.predictionIntervals();
Prediction p = new Prediction(value, confidence[0][0],confidence[0][1]);
preds.addPrediction(p);
}
}
this.predictions.put(algorithm, preds);
}
}
private TreeMap<String, TS> loadTimeSeries() {
return new TreeMap<String, TS>();
}
public int getNumPredictions() {
return numPredictions;
}
public void setNumPredictions(int numPredictions) {
if (numPredictions <= 0) throw new IllegalArgumentException("Number of predictions should be greater than zero)");
this.numPredictions = numPredictions;
}
public int getMinlag() {
return minlag;
}
public void setMinlag(int minlag) throws Exception {
if (minlag > this.maxlag || minlag <= 0) throw new IllegalArgumentException("Invalid lag (should be greater than the minimun and greater than zero)");
this.minlag = minlag;
}
public int getMaxlag() {
return maxlag;
}
public void setMaxlag(int maxlag) throws Exception {
if (maxlag < this.minlag || maxlag <= 0) throw new IllegalArgumentException("Invalid lag (should be greater than the minimun and greater than zero)");
this.maxlag = maxlag;
}
}