Well I got it working by a hack. I enabled the socket listener of the EPAgent and wrote the XML packet to the socket in the java code. It works, but I don't like it and would like a better solution if anyone is able to provide one. Below is the code. I'm passing in localhost and 8000 as the host and port parameters.
public WilyMetricReporter(String metricName, long val, String host, int port) {
try {
Socket socket = new Socket(host, port);
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.write("<metric type=\"LongCounter\" name=\"" + metricName + "\" value=\"" + val + "\"/>");
out.flush();
out.close();
} catch (IOException ex) {
Logger.getLogger(WilyMetricReporter.class.getName()).log(Level.SEVERE, null, ex);
}
}