Note that there are some explanatory texts on larger screens.

plurals
  1. POEOFException when reading serialized object in Servlet
    primarykey
    data
    text
    <p>I have an applet trying to send java serialized object to a servlet (hosted in Tomcat 6). The URLs are correct and the applet reaches the correct servlet, but when it comes to reading anything on the servlet side, I get an error.</p> <p>Here is the applet code :</p> <pre><code> String adresse = "/Applic_ClientsPartners/NewMemberServlet"; URL page = getDocumentBase(); String protocole = page.getProtocol(); String host = page.getHost(); int port = page.getPort(); System.out.println(protocole + "://" + host + ":" + port + adresse); URL serv = new URL(protocole, host, port, adresse); URLConnection conn = serv.openConnection(); conn.setUseCaches(false); conn.setDefaultUseCaches(false); //conn.setRequestProperty("Content-Type", "application/x-java-serialized-object"); conn.setRequestProperty("Content-Type", "application/octet-stream"); conn.setDoInput(true); conn.setDoOutput(true); System.out.println("Connection open"); ObjectOutputStream oos = new ObjectOutputStream(conn.getOutputStream()); ObjectInputStream ois = new ObjectInputStream(conn.getInputStream()); System.out.println("Envoi de 'test'"); //sending a test String String t = "test"; oos.writeObject(t); System.out.println("test flush"); oos.flush(); System.out.println("test between flush & writeObject"); oos.writeObject(nouveau); //this is a serializable custom object oos.flush(); //Boolean result = ois.readBoolean(); ois.close(); oos.close(); System.out.println("Streams fermés"); //streams closed successfully </code></pre> <p>Here is the servlet code :</p> <pre><code> response.setContentType("application/octet-stream"); ObjectInputStream ois = new ObjectInputStream(request.getInputStream()); ObjectOutputStream oos = new ObjectOutputStream(response.getOutputStream()); System.out.println("AVAILABLE " + ois.available()); System.out.println("Pré read test"); String t = (String) ois.readObject(); System.out.println(t + " lu"); Cards.Member nouveau = (Cards.Member) ois.readObject(); System.out.println("Post read test"); oos.close(); ois.close(); System.out.println("Streams fermés"); //Streams closed successfully return; </code></pre> <p>I have a try ... catch(IOException ex) surrounding both of course. The error is the following : </p> <pre><code> java.io.EOFException at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2554) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1297) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at Servlets.NewMemberServlet.doPost(NewMemberServlet.java:96) at javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619) </code></pre> <p>I really don't understand what's happening here : The servlet's ObjectInputStream seems to get nothing, but I have another applet-servlet in the same web project, albeit with an http tunnel, and they're working perfectly?!</p> <p>Any help would be greatly appreciated :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload