Hello.
Im testing a Java application that connects to a servlet and send it some objects,
then the server connects to a RMI remote object and do some tasks on it.
I think everything is well configured but get this exception when trying to connect to
the server:
------ Exception ---------
2001-05-26 12:39:02 - ContextManager: SocketException reading request,
ignored - java.net.SocketException: Connection reset by peer: JVM_recv
in socket input stream read
at java.net.SocketInputStream.socketRead(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:86)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:186)
at java.io.BufferedInputStream.read(BufferedInputStream.java:204)
at
org.apache.tomcat.service.http.HttpRequestAdapter.doRead(HttpRequestAdapter.java:115)
at
org.apache.tomcat.core.BufferedServletInputStream.doRead(BufferedServletInputStream.java:106)
at
org.apache.tomcat.core.BufferedServletInputStream.read(BufferedServletInputStream.java:128)
at javax.servlet.ServletInputStream.readLine(ServletInputStream.java:138)
at
org.apache.tomcat.service.http.HttpRequestAdapter.readNextRequest(HttpRequestAdapter.java:129)
at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:195)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:484)
-------- /Exception ----------
I think hat the exception occurs before init method of the servlet.
The code of the java program that connect to the server is:
---- Code of the client ------
URL servlet = new URL("http://127.0.0.1:8080/prueba/anyadirMensajeServlet");
Mensaje msg = new MensajeReal();
URLConnection con = servlet.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(msg);
out.writeInt(1);
out.flush();
out.close();
------- /code of the client ------
and the code of the servlet is
------ code of the servlet ------
public void doPost( HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
ObjectInputStream in = new ObjectInputStream(req.getInputStream());
try {
Mensaje mensaje = (Mensaje) in.readObject();
int foro = (int) in.readInt();
//The parent class of this server connects to a RMI Servidor object
//and asings it to servidro object
servidor.anyadirMensaje(mensaje, foro);
} catch (Exception e) {
e.printStackTrace();
}
in.close();
}
------ /code of the servlet ------
Thank you in advance and sorry for having to send this big post.