SocketException during reads - JVM_recv in socket input stream read

I am getting a SocketException when a Java applet talks to our
WebLogic 7.0 server. The catch is that it only occurs at one site
(that has very high T1 utilization, although latency is only ~60 ms)
Our setup is such that the calls hit an Alteon load balancer, which
then sends the request out to one of 4 IIS clustered servers, where it
then is sent to one of 2 WL clustered servers. I figured latency
would be the cause, but on IIS and on WL, the timeouts are set to
several hundred seconds, so I am not quite seeing where the connection
is being reset. To be honest, I really don't know if it is WL that is
killing the connection, as nothing abnormal shows up in the WL log. I
have seen similar problems in this group, though, although the stack
traces never follow the same path mine does. I do have the following
call stack from the Java plug-in console, though. Any ideas would be
greatly appreciated.
java.net.SocketException: Connection reset by peer: JVM_recv in socket
input stream read
     at java.net.SocketInputStream.socketRead0(Native Method)
     at java.net.SocketInputStream.read(Unknown Source)
     at java.io.BufferedInputStream.fill(Unknown Source)
     at java.io.BufferedInputStream.read1(Unknown Source)
     at java.io.BufferedInputStream.read(Unknown Source)
     at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
     at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
     at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
     at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
     at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
     at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
Source)
     at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
Source)
     at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
     at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
     at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
     at sun.applet.AppletPanel.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
Also, here is my code, although I can't see anything on the client
side that seems off:
public Object sendRequest( Object request, URL receiver ) throws
Exception{
Object response = null;
URLConnection con = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
con = receiver.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setDefaultUseCaches(false);
con.setAllowUserInteraction(false);
out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(request);
out.flush();
out.close();
in = new ObjectInputStream(con.getInputStream());
response = in.readObject();
in.close();
} catch (ClassCastException e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
} catch (Exception e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
throw e;
return response;

There is a known bug on earlier 1.3.1 releases with sockets on Windows 2k
and XP. I don't remember all the details.
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Keith Patrick" <[email protected]> wrote in message
news:[email protected]...
I'm getting the exception on the client, which is an XP machine, while
the server is Win2K. I can't recall which, but either the applet or
the server runs 1.3x while the other runs 1.4. I discounted that
factor, though, as the problem only occurs on one site, which on all
others it works fine.
"Cameron Purdy" <[email protected]> wrote in message
news:<[email protected]>...
Exception is in the applet or on the server?
Would one of those by any chance be running on W2K with JDK 131_01 orolder?
>>
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Keith Patrick" <[email protected]> wrote in message
news:[email protected]...
I am getting a SocketException when a Java applet talks to our
WebLogic 7.0 server. The catch is that it only occurs at one site
(that has very high T1 utilization, although latency is only ~60 ms)
Our setup is such that the calls hit an Alteon load balancer, which
then sends the request out to one of 4 IIS clustered servers, where it
then is sent to one of 2 WL clustered servers. I figured latency
would be the cause, but on IIS and on WL, the timeouts are set to
several hundred seconds, so I am not quite seeing where the connection
is being reset. To be honest, I really don't know if it is WL that is
killing the connection, as nothing abnormal shows up in the WL log. I
have seen similar problems in this group, though, although the stack
traces never follow the same path mine does. I do have the following
call stack from the Java plug-in console, though. Any ideas would be
greatly appreciated.
java.net.SocketException: Connection reset by peer: JVM_recv in socket
input stream read
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTPHeader(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.http.HttpClient.parseHTTP(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at
sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(Unknown
Source)
atsun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(Unknown
Source)
atsun.plugin.net.protocol.http.HttpURLConnection.getInputStream(Unknown
Source)
at org.xxxx.abstracts.Controller.sendRequest(Controller.java:39)
at org.xxxx.data.DataMediator.getDataNode(DataMediator.java:46)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Also, here is my code, although I can't see anything on the client
side that seems off:
public Object sendRequest( Object request, URL receiver ) throws
Exception{
Object response = null;
URLConnection con = null;
ObjectOutputStream out = null;
ObjectInputStream in = null;
try {
con = receiver.openConnection();
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setDefaultUseCaches(false);
con.setAllowUserInteraction(false);
out = new ObjectOutputStream(con.getOutputStream());
out.writeObject(request);
out.flush();
out.close();
in = new ObjectInputStream(con.getInputStream());
response = in.readObject();
in.close();
} catch (ClassCastException e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
} catch (Exception e) {
if( out != null ){
out.close();
if( in != null ){
in.close();
throw e;
return response;

Similar Messages

  • Re: Connection Failure: ReadFile on fd=1231 failed with err=64  + JVM_recv in socket input stream read

    Jon,
    I believe that this error is similar to a "connection reset by peer". It is
    a Window specific error. I believe it indicates that something has happened
    on the other end of the socket such that the socket has gone bad.
    I think that this should only occur when people reset their connection
    before the reply is sent. I don't believe that it is indicative of any
    serious problem other than this communication failure caused by the client.
    I've opened an issue to catch and squelch these spurious exceptions rather
    than logging them. For now I think it is safe to ignore them.
    Regards,
    Adam
    "Jon Mountjoy" <[email protected]> wrote in message
    news:[email protected]...
    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does aselect,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser,say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stoppedIO
    exceptions that were being raised by the servlet when it tried to outputto
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhzusing
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    java.net.SocketException: Connection reset by peer: JVM_recv in socketinput
    stream read
    at java.net.SocketInputStream.socketRead(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, CompiledCode)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, CompiledCode)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java,Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

    We are seeing the same error since switching to sp11 (we had been using
    sp10). Haven't seen it in Solaris though. What is causing it?
    Wed May 08 12:01:48 EDT 2002:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=3640 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java:259)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java:178)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:280)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
    "John Slaman" <[email protected]> wrote in message
    news:[email protected]..
    >
    I'm getting a error as follows:
    Mon Apr 22 19:04:10 EDT 2002:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=2368 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    I have no idea as to the cause. It's been posted in the archives before -but with
    no particular solution.
    I'm using WLS 5.1 SP11, JDK 1.2.2_007. Win2000.
    Does anybody know the cause/solution?
    Thanks.
    "Jon Mountjoy" <[email protected]> wrote:
    Hi,
    I have noticed that applying the service pack helps things quite a bit.
    I no longer get NT muxer errors etc etc. just the "connection reset by
    peer"
    every now and again.
    As I am repeatedly hitting the server from one browser, your 'connection
    going bad' scenario probably
    applies quite well.
    (btw. before the SP, the errors seemed to crop up more just before/during
    a
    GC.)
    Jon

  • JDBC Connection reset by peer: JVM_recv in socket input stream read

    Hey Guys,
    Has anyone seen this issue? We get this error in our Weblogic app logs at times and no one is able to login to our application. Our database server and SQL server seem fine at a high level. Any ideas what is causing this?
    com.s1.arch.persistence.exception.PersistenceException weblogic.jdbc.mssqlserver4.TdsException: I/O exception while talking to the server, java.net.SocketException: Connection reset by peer: JVM_recv in socket input stream read
    Thanks

    please make sure that there is no Firewall between your servers and DB server. this message usually happen when there is a fire wall between the servers. if yes please make sure that the connection time on fire wall is longer than the time needed to complete an operation another thing that you need to check if you have a fire wall which is to make sure that Oracle DBMS return the request to the same port that it is listening to (1521 default).

  • Connection Failure: ReadFile on fd=1231 failed with err=64  + JVM_recv in socket input stream read

    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does a select,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser, say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stopped IO
    exceptions that were being raised by the servlet when it tried to output to
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhz using
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    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, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java, Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

    I have exactly the same problem running on Windows NT 4.0 (SP4) Weblogic 5.1 and
    JDK1.2.2-001.
    java.net.SocketException: ReadFile on fd=1048 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java, Compiled
    Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java, Compiled
    Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Jon Mountjoy wrote:
    Hi Guys,
    Using weblogic 5.1 (downloaded pretty soon after announcement) on windows
    2000 (yes I know not certified there yet) and using jdk1.2.2-001.
    I have a pretty standard setup - a connection pool (5) to a sqlserver
    (remote) machine.
    A pretty standard multithreaded servlet - grabs a connection, does a select,
    calls dbkona to dump output, releases connection.
    It runs fine - browser returns result. When I push 'reload' on browser, say
    10 times very quickly, I get the following errors. It is sometimes a
    combination of these:
    1- Mon May 08 13:34:41 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1912 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled
    Code)
    2- Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem
    accepting connecti on java.net.SocketException: Connection reset by peer:
    JVM_recv in socket input stream read
    Now I can get rid of (1) by switching off native IO!! This also stopped IO
    exceptions that were being raised by the servlet when it tried to output to
    the output stream. (2) persists.
    I have changed nothing else in the properties.
    (1) sounds like I may need to up the number of file descriptors open?
    (2) I don't know. Is my server too loaded? I am running on a 600Mhz using
    64Mb heap for the server with 300Mb swap available...
    Regards,
    Jon
    More substantial excerpts:
    Mon May 08 13:40:42 GMT+00:00 2000:<D> <ListenThread> Problem accepting
    connection
    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, Compiled Code)
    at weblogic.socket.ResettableSocket.getPrefix(ResettableSocket.java,
    Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketT3.claimSocket(JVMSocketT3.java, Compiled Code)
    at weblogic.socket.JVMSocketManager.accept(JVMSocketManager.java, Compiled
    Code)
    at
    weblogic.t3.srvr.ListenThread$RJVMListenRequest.execute(ListenThread.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1980 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1760 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
    Mon May 08 13:35:31 GMT+00:00 2000:<E> <HTTP> Connection failure
    java.net.SocketException: ReadFile on fd=1908 failed with err=64
    at weblogic.socket.NTSocketMuxer.initiateIO(Native Method)
    at weblogic.socket.NTSocketMuxer.read(NTSocketMuxer.java, Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.requeue(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
    Compiled Code)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)

  • Io exception: Connection reset by peer: JVM_recv in socket input stream read

    We are developing a new J2EE app using JDev, OC4J, servlets, and EJBs. We have determined that our firewall is closing database connections that have been idle for 1 hour. This is a security requirement that cannot be changed. When we try to use these idle connections in both stateless and entity beans, we consistently receive this or a similar error message:
    "ServletSACategoryList: Error invoking EJB procedure. Exception: java.sql.SQLException: StatelessSysAdminBean::getCategoryList - Io exception: Connection reset by peer: JVM_recv in socket input stream read "
    Environment:
    Oracle 9iAS 9.0.2.0.0
    Database: Oracle 8.1.7
    JDBC 8.1.7
    JDK 1.3
    JDev 9.0.2.829
    We are using the ejb-location attribute within data-sources.xml for JNDI lookup of the DataSource. Here is what this file looks like:
    <data-sources>
    <data-source
    class="oracle.jdbc.pool.OracleDataSource"
    name="jdbc/OracleDS"
    location="jdbc/OracleCoreDS"
    xa-location="jdbc/xa/OracleXADS"
    ejb-location="jdbc/OraclePoolDS"
    url="jdbc:oracle:thin:@###.###.#.###:1521:dev1"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="????????"
    password="????????"
    max-connections="4"
    wait-timeout="20"
    min-connections="1"
    inactivity-timeout="60"
    connection-retry-interval="1"
    max-connect-attempts="3"
    />
    </data-sources>
    After calling getConnection() on the Connection object in my stateless bean, I have tried checking if the Connection object is null or isClosed(), I have caught any Exception, and looped to try again, but nothing has worked.
    Please respond to [email protected] or directly to this post if you can help in any way.
    Thank you,
    - Rob

    Hi Robert,
    If you don't mind, I can only offer a few suggestions for things
    to try -- I'm afraid I don't have a solution for you. Of-course,
    you may have already tried these things, so please excuse me if
    this is the case.
    Firstly, your "data-sources.xml" file looks "different". Have
    you read the "Data Sources" chapter of the "Oracle9iAS Containers
    for J2EE Services Guide, Release 2 (9.0.2)"? It is accessible
    from here:
    http://otn.oracle.com/docs/products/ias/doc_library/90200doc_otn/web.902/a95879/ds.htm#1004903
    Also, have you tried running OC4J in "debug" mode? This web
    page has more details:
    http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
    I get the impression from the information you have supplied,
    that you may not be explicitly closing your database connections
    in your code. It looks to me like you are obtaining a database
    connection in your session bean, and then keeping it for the
    lifetime of that bean. Is that correct? I think it's better
    to obtain a connection when you need to interact with the database,
    and then close the connection immediately after completing the
    interaction with the database (but that's just my opinion).
    Lastly, if you haven't already discovered them, these web sites
    may also be of help:
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.elephantwalker.com
    Hope this helps you.
    Good Luck,
    Avi.

  • Oracle Blob using Java help (Error: JVM_recv in socket input stream read )

    I am trying to insert a record with Blob column (size of image 'mg.jpg' about 15KB) and I get the runtime error:
    [java] java.sql.SQLException: Io exception: Connection reset by peer: JVM_recv in socket input stream read
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    [java]      at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
    [java]      at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2061)
    [java]      at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
    [java]      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
    [java]      at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
    [java]      at test.ProvisioningParser.TestBlob.main(Unknown Source)
    This is what code looks like: I am not sure what's wrong, any help appreciated. Thanks!
         try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("jdbc:oracle:thin:@VALUED-20606295:1521:dbbook","jvending","jvending");
                   java.util.zip.ZipInputStream zip = new java.util.zip.ZipInputStream(new java.io.FileInputStream(new java.io.File("D:\\work\\mywork\\source\\test\\ProvisioningParser\\test.par"))) ;
                   int len = 0 ;
                   java.util.zip.ZipEntry entry = null;
                   do{
                        entry = zip.getNextEntry();
                        if (entry != null){
                             if (entry.getName().equalsIgnoreCase("mg.jpg")){
                                  len = (int)entry.getSize();
                                  break;
                   }while(entry!=null) ;
                   stmt = con.prepareStatement( "Insert into icon (parid, clientbundleid, id, iconfile ) values ( ?,?,?,?)"
                         stmt.setString(1,"101");
                         stmt.setString(2,"101");
                         stmt.setInt(3,1);                    
                         stmt.setBinaryStream( 4, zip, len);
                   stmt.setQueryTimeout(0);
                   stmt.executeUpdate();
                   con.close();               
              catch(Exception e){
                   e.printStackTrace();
              }Thanks,
    Rashmi

    As a guess what you are doing with that zip stuff is very odd.
    You do realize that it is just going to put some binary data into the blob right? And the methods that is going to use will not necessarily create a 'complete' zip file?
    If you want a zip file then just load the file, dont use the zip classes.
    And if you want part of a zip file, (and want to store the parts as a zip) then extract it from the file and create another zip entity using a byte stream rather than a file.
    Finally I suspect your error with the blob occurs because you do not close the statement. But at any rate you should figure out how to do the blob code independent of the zip stuff.
    And what oracle driver version are you using? Some of the older ones need oracle specific handling for blobs.

  • IOException: Connection reset by peer: JVM_recv in socket input stream read

    hi
    I encountered a problem : a program throw out an exception:java.io.IOException: Io exception:
    Connection reset by peer: JVM_recv in socket input stream read.
    I tried my best to resolve it ,but unfortunately,i didn't know what caused the exception.
    the following is my application environment:
    I have two PC(Win2000os),one is a server which installed oracle9.2.0.2 and jdeveloper9.0.3,the another is a
    client which only intalled jdeveloper9.0.3.Two days ago,i performed a web application on my client with
    jdeveloper,and it includes some JSP and a javabean files.JSP Page finished uploading client xml file to a
    folder on server and the javabean finished loading the xml file into a xmltype column.I can make sure the
    connection is established and the javabean is OK,beacause my some jsp page can successfully use
    <jsp:usebean> tag and use the javabean's some other public interfaces,except the interface that finishs
    loading the xml file into a xmltype(clob) column.
    Then i do many tests!I changed the javabean to a java class incluse a main method beacause it is easy to
    debug.Finally i found the following code caused the exception:
    public CLOB writetoClob( CLOB clob, InputStream is )throws SQLException, IOException {
    InputStreamReader reader = new InputStreamReader( is );
    Writer writer = clob.getCharacterOutputStream( );
    char[] buffer = new char[clob.getChunkSize(  )];
    int charsRead;
    for ( charsRead = reader.read( buffer ); charsRead > -1;charsRead = reader.read( buffer ) ) {
    writer.write( buffer, 0, charsRead );
    writer.close();
    return clob;
    when it runs to writer.close(),the exception is caused!
    Then i copy the java class to the server,it runs ok!
    That is to say ,the same code,the different result!
    But when i run my web application on server with jdeveloper Embedded OC4J Server and a jsp page loaded javabean
    and run to mentioned code ,the same exception occured!
    I checked the application log in event viewer,the descriptions was:
    The data buffer created for the "AppleTalk" service in the "C:\WINNT\system32\atkctrs.dll" library is not
    aligned on an 8-byte boundary. This may cause problems for applications that are trying to read the
    performance data buffer. Contact the manufacturer of this library or service to have this problem corrected or
    to get a newer version of this library.
    I search some some resolution about this exception with web and someone sayed :
    This basically means that a network error occurred while the client was receiving data from the server. But
    what is really happening is that the server actually accepts the connection, processes the request, and sends a
    reply to the client. However, when the server closes the socket, the client believes that the connection has
    been terminated abnormally because the socket implementation sends a TCP reset segment telling the client to
    throw away the data and report an error.
    Sometimes, this problem is caused by not properly closing the input/output streams and the socket connection.
    Make sure you close the input/output streams and socket connection properly. If everything is closed properly,
    however, and the problem persists, you can work around it by adding Thread.sleep(1000) before closing the
    streams and the socket. This technique, however, is not reliable and may not work on all systems.
    In general,the following information is conclution:
    Web application runs error both on client and on server.
    If it was changed to a client java class,it only run ok on server!
    i have done anything that i can do now,i feel depressed very much!
    how can i resolve the problem!
    Any a little help will be appreciated!
    regards!
    Thanks
    Jiawei ZHAO

    How can i solve the problem.
    Thanks in advance!
    Jiawei Zhao

  • Connection reset by peer: JVM_recv in socket input stream read

    Dear All,
    We are facing a very unusual problem. In our application, there is a functionality to transfer files to a FTP server using java FTPClient.
    Now while transferring set of files, few times it throws the error:
    Connection reset by peer: JVM_recv in socket input stream read
    This error comes irregularly.
    Can you suggest the reason for this.
    Regards,
    Akhil

    which platform are you using? which ip stack , ipv4 or ipv6?
    try to set -Djava.net.preferIPv4Stack="true" when startup,
    it will use ipv4 stack instead of default ipv6 on solaris.

  • JVM_recv in socket input stream read (code=10004)

    Whilst trying to get a file listing from an FTP server (by sending FTP commands directly to the server according to RFC959)
    I got..
    JVM_recv in socket input stream read (code=10004)
    What does this mean? Any idea why it is caused, the socket should be open as far as I am concerned - could something external be affecting it?

    Platform/JVM? I'd guess Windows - 10004 looks like WSAEINTR, from WinSock. (Here's some specifics that may help:
    http://support.ipswitch.com/kb/WSK-19980714-EM08.htm )

  • JVM_recv in socket input stream read

    I have Oracle 8.0.5.0 and can connect if I use SQL-Worksheet etc..
    When I try to connect using java I get an error:
    JVM_rec in socket input stream read...
    I'm usind JDK1.2.2 and classes111.zip...
    Strange thing is that on another box with the same setup, everything works....
    Any ideas???

    I don't see any know reproducable bugs on this, but does this reproduce with 9.0.5.2 of JDeveloper? The error simply means that the connection between the database and the jdbc driver got cut before the driver thought it should end.
    Rob
    Team JDev

  • JVM_recv in socket input stream error

    I've opened a socket and I'm able to access the OutputStream. However, when I try to wrap a ObjectInputStream around the socket's InputStream, I get this error:
    SocketException: Connection reset by peer: JVM_recv in socket input stream read.
    What should I be looking for?
    Larry

    Here's the code which appears to be relevant, with some commentary on what happens when it is run. Large portions of (hopefully) irrelevant code have been snipped.
    Client:
    COMMENT: Start a server using RMI. This appears to
    COMMENT: succeed, since a message printed by this
    COMMENT: server does appear.
    try {
    DistLrnRemoteData dlrd =
    (DistLrnRemoteData)Naming.lookup(
    "//"+personHost+
    "/DistanceLearningData");
    dlrd.activatePersonServer(); // Get server going
    catch (Exception e) {
    System.err.println(e);
    COMMENT: This line is NOT printed, so apparently
    COMMENT: there is no Exception.
    System.err.println("Unable to initialize remote Person server");
    e.printStackTrace(System.err);
    Person result = new Person();
    int count = 10;
    boolean opened = false;
    Socket gpsocket = null;
    while (!opened) {
    try {
    COMMENT: The client attempts to open the socket
    COMMENT: here. The server never seems to accept it,
    COMMENT: but this call appears to succeed. There is
    COMMENT: no Exception. The server is running code
    COMMENT: from the class RemoteDataServer, so the
    COMMENT: port should be the same. The testing was
    COMMENT: done with a single host acting as both
    COMMENT: client and server, so there isn't any firewall
    COMMENT: or network outage problem.
    gpsocket = new Socket(personHost,
    RemoteDataServer.personReadPort);
    opened = true;
    catch (IOException ioe) {
    count--;
    if (count <= 0) {
    COMMENT: This line is NOT printed, so apparently there
    COMMENT: is no IOException when the Socket is
    COMMENT: created. Nor does an UnknownHostException
    COMMENT: or SecurityException stop the program.
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    result = null;
    return result;
    try {
    Thread.sleep(1000);
    catch (InterruptedException ie) {
    System.err.println(ie);
    ie.printStackTrace(System.err);
    // Read the serialized object
    try {
    COMMENT: No problem with the next line, which attempts
    COMMENT: to access the OutputStream of the socket.
    MyStringWriter msw = new MyStringWriter(
    gpsocket.getOutputStream());
    COMMENT: The next line causes the message.
    ObjectInputStream ois =
    new ObjectInputStream(gpsocket.getInputStream());
    msw.write(personRealName);
    // Now read the resulting Person.
    try {
    result = (Person)(ois.readObject());
    catch (ClassNotFoundException cnfe) {
    System.err.println(cnfe);
    cnfe.printStackTrace(System.err);
    System.exit(4);
    catch (IOException ioe) {
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    result = null;
    Server:
    public void activateFocusServer() throws java.rmi.RemoteException {
    String [] cmd = new String[2];
    cmd[0] = new String("java");
    cmd[1] = new String("RemoteDataServer");
    try {
    COMMENT: FORTE's Output window shows a message
    COMMENT: from this process
    Process dbserver =
    Runtime.getRuntime().exec(cmd); // Server will self-destruct
    // after a timeout period
    catch (IOException ioe) {
    COMMENT: This message is never printed
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    RemoteDataServer:
    public RemoteDataServer() {
    try {
    ...many different servers started here...
    ServerSocket PersonReadSocket = new ServerSocket(personReadPort);
    PersonReadListener prl = new PersonReadListener(PersonReadSocket);
    prl.start();
    catch (IOException ioe) {
    COMMENT: This message is never printed.
    System.err.println(ioe);
    ioe.printStackTrace(System.err);
    COMMENT: PersonReadListener is an inner class:
    class PersonReadListener extends java.lang.Thread {
    private Thread BaseThread;
    private ServerSocket theSocket;
    /** Creates an object to listen for PersonRead requests
    * @param ss The server socket to listen with
    public PersonReadListener(ServerSocket ss) {
    theSocket = ss;
    /** Initializes the thread to listen for PersonRead requests
    public void start() {
    BaseThread = new Thread(this);
    BaseThread.start();
    /** The code for the server to listen for PersonRead requests
    public void run() {
    while(true) {
    try {
    COMMENT: This code doesn't have access to System.err
    COMMENT: so a file is created to print debugging output
    PrintWriter debug = new PrintWriter(new FileWriter("person.debug"));
    COMMENT: The next line IS printed, so the server gets
    COMMENT: this far.
    debug.println("Waiting for connection for person's name");
    debug.close();
    PersonReadClientConnection someone =
    new PersonReadClientConnection(theSocket.accept());
    COMMENT: If the previous "debug.close" line is
    COMMENT: commented out and the next two lines are
    COMMENT: uncommented, the next line is NOT
    COMMENT: printed, so apparently the accept nevers
    COMMENT: happens! Why does the accept fail, but
    COMMENT: the client's socket creation succeed?
    // debug.println("Accepted a connection");
    // debug.close();
    someone.start();
    catch (IOException ioe) {
    COMMENT: These lines are NOT printed
    System.err.println(ioe);
    ioe.printStackTrace(System.err);

  • Problems Reading SSL  server socket  data stream using readByte()

    Hi I'm trying to read an SSL server socket stream using readByte(). I need to use readByte() because my program acts an LDAP proxy (receives LDAP messages from an LDAP client then passes them onto an actual LDAP server. It works fine with normal LDAP data streams but once an SSL data stream is introduced, readByte just hangs! Here is my code.....
    help!!! anyone?... anyone?
    1. SSL Socket is first read into  " InputStream input"
    public void     run()
              Authorization     auth = new Authorization();
              try     {
                   InputStream     input     =     client.getInputStream();
                   while     (true)
                   {     StandLdapCommand command;
                        try
                             command = new StandLdapCommand(input);
                             Authorization     t = command.get_auth();
                             if (t != null )
                                  auth = t;
                        catch( SocketException e )
                        {     // If socket error, drop the connection
                             Message.Info( "Client connection closed: " + e );
                             close( e );
                             break;
                        catch( EOFException e )
                        {     // If socket error, drop the connection
                             Message.Info( "Client connection close: " + e );
                             close( e );
                             break;
                        catch( Exception e )
                             //Way too many of these to trace them!
                             Message.Error( "Command not processed due to exception");
                             close( e );
                                            break;
                                            //continue;
                        processor.processBefore(auth,     command);
                                    try
                                      Thread.sleep(40); //yield to other threads
                                    catch(InterruptedException ie) {}
              catch     (Exception e)
                   close(e);
    2 Then data is sent to an intermediate function 
    from this statement in the function above:   command = new StandLdapCommand(input);
         public StandLdapCommand(InputStream     in)     throws IOException
              message     =     LDAPMessage.receive(in);
              analyze();
    Then finally, the read function where it hangs at  "int tag = (int)din.readByte(); "
    public static LDAPMessage receive(InputStream is) throws IOException
        *  LDAP Message Format =
        *      1.  LBER_SEQUENCE                           --  1 byte
        *      2.  Length                                  --  variable length     = 3 + 4 + 5 ....
        *      3.  ID                                      --  variable length
        *      4.  LDAP_REQ_msg                            --  1 byte
        *      5.  Message specific structure              --  variable length
        DataInputStream din = new DataInputStream(is);
        int tag = public static LDAPMessage receive(InputStream is) throws IOException
        *  LDAP Message Format =
        *      1.  LBER_SEQUENCE                           --  1 byte
        *      2.  Length                                  --  variable length     = 3 + 4 + 5 ....
        *      3.  ID                                      --  variable length
        *      4.  LDAP_REQ_msg                            --  1 byte
        *      5.  Message specific structure              --  variable length
        DataInputStream din = new DataInputStream(is);
           int tag = (int)din.readByte();      // sequence tag// sequence tag
        ...

    I suspect you are actually getting an Exception and not tracing the cause properly and then doing a sleep and then getting another Exception. Never ever catch an exception without tracing what it actually is somewhere.
    Also I don't know what the sleep is supposed to be for. You will block in readByte() until something comes in, and that should be enough yielding for anybody. The sleep is just literally a waste of time.

  • Parsing XML from Socket input stream

    I create a sax parser to which I send the InputStream from the socket
    But my HandlerBase never gets the events. I get startDocument
    but that is it, I never get any other event.
    The code I have works just like expected when I make the InputStream
    come from a file. The only differeence I see is that when I file is used the
    InputStream is fully consumed while with the socket the InputStream
    is kept open (I MUST KEEP THE SOCKET OPEN ALL THE TIME). If the parser
    does not generate the events unless the InputStream is fully consumed,
    isn't that against the whole idea of SAX (sax event driven) .
    Has anyone been succesfull parsing XML from the InputStream of a socket?
    if yes how?
    I am using JAXP 1.0.1 but I can upgrade to JAXP 1.1.0
    which uses SAX 2.0
    Does anybody know if my needs can be met by JAXP 1.1.0?
    Thanks

    I did the same with client/server model.
    I have client program with SAX parser. Please try if you can make the server side. I was be able to write the program with help from this forum. Please search to see if you can get the forum from which I got help for this program.
    // JAXP packages
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    // JAVA packages
    import java.util.*;
    import java.io.*;
    import java.net.*;
    public class XMLSocketClient {
    final private static int buffSize = 1024*10;
    final private static int PORTNUM = 8888;
         final private static int threadSleepValue = 1000;
    private static void usage() {
    System.err.println("Usage: XMLSocketClient [-v] serverAddr");
    System.err.println(" -v = validation");
    System.exit(1);
    public static void main(String[] args) {
    String address = null;
    boolean validation = false;
    Socket socket = null;
    InputStreamReader isr_socket = null;
    BufferedReader br_socket = null;
    CharArrayReader car = null;
    BufferedReader br_car = null;
    char[] charBuff = new char[buffSize];
    int in_buff = 0;
    * Parse arguments of command options
    for (int i = 0; i < args.length; i++) {
    if (args.equals("-v")) {
    validation = true;
    } else {
    address = args[i];
    // Must be last arg
    if (i != args.length - 1) {
    usage();
    // Initialize the socket and streams
    try {
    socket = new Socket(address, PORTNUM);
    isr_socket = new InputStreamReader(socket.getInputStream());
    br_socket = new BufferedReader(isr_socket, buffSize);
    catch (IOException e) {
    System.err.println("Exception: couldn't create stream socket "
    + e.getMessage());
    System.exit(1);
    * Check whether the buffer has input.
    try {
    while (br_socket.ready() != true) {
                   try {
                        Thread.currentThread().sleep(threadSleepValue);     
                   catch (InterruptedException ie) {
              System.err.println("Interrupted error for sleep: "+ ie.getMessage());
                   System.exit(1);
    catch (IOException e) {
    System.err.println("I/O error for in.read(): "+ e.getMessage());
    System.exit(1);
    try {
    in_buff = br_socket.read(charBuff, 0, buffSize);
    System.out.println("in_buff = " + in_buff);
    System.out.println("charBuff length: " + charBuff.length);
    if (in_buff != -1) {
    System.out.println("End of file");
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    System.exit(1);
    System.out.println("reading XML file:");
    StringBuffer display = new StringBuffer();
    display.append(charBuff, 0, in_buff);
    System.out.println(display.toString());
    * Create BufferedReader from the charBuff
    * in order to put into XML parser.
    car = new CharArrayReader(charBuff, 0, in_buff); // these two lines have to be here.
    br_car = new BufferedReader(car);
    * Create a JAXP SAXParserFactory and configure it
    * This section is standard handling of XML document by SAX XML parser.
    SAXParserFactory spf = SAXParserFactory.newInstance();
    spf.setValidating(validation);
    XMLReader xmlReader = null;
    try {
    // Create a JAXP SAXParser
    SAXParser saxParser = spf.newSAXParser();
    // Get the encapsulated SAX XMLReader
    xmlReader = saxParser.getXMLReader();
    } catch (Exception ex) {
    System.err.println(ex);
    System.exit(1);
    // Set the ContentHandler of the XMLReader
    xmlReader.setContentHandler(new MyXMLHandler());
    // Set an ErrorHandler before parsing
    xmlReader.setErrorHandler(new MyErrorHandler(System.err));
    try {
    * Tell the XMLReader to parse the XML document
    xmlReader.parse(new InputSource(br_car));
    } catch (SAXException se) {
    System.err.println(se.getMessage());
    System.exit(1);
    } catch (IOException ioe) {
    System.err.println(ioe);
    System.exit(1);
    * Clearance of i/o functions after parsing.
    try {
    br_socket.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    try {
    socket.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    try {
    br_car.close();
    } catch (IOException e) {
    System.out.println("Exception: " + e.getMessage());
    * The XML handler used by this program
    class MyXMLHandler extends DefaultHandler {
    // A Hashtable with tag names as keys and Integers as values
    private Hashtable tags;
    // Parser calls this once at the beginning of a document
    public void startDocument() throws SAXException {
    System.out.println("startDocument()");
    tags = new Hashtable();
    // Parser calls this for each element in a document
    public void startElement(String namespaceURI, String localName,
    String rawName, Attributes atts)
    throws SAXException
    String key = localName;
    Object value = tags.get(key);
    System.out.println("startElement()");
    System.out.println("namespaceURI: " + namespaceURI);
    System.out.println("localName: " + localName);
    System.out.println("rawName: " + rawName);
    if (value == null) {
    // Add a new entry
    tags.put(key, new Integer(1));
    } else {
    // Get the current count and increment it
    int count = ((Integer)value).intValue();
    count++;
    tags.put(key, new Integer(count));
    // Parser calls this once after parsing a document
    public void endDocument() throws SAXException {
    Enumeration e = tags.keys();
    System.out.println("endDocument()");
    while (e.hasMoreElements()) {
    String tag = (String)e.nextElement();
    int count = ((Integer)tags.get(tag)).intValue();
    System.out.println("Tag <" + tag + "> occurs " + count
    + " times");
    * Error handler of XML parser to report errors and warnings
    * This is standard handling.
    class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintStream out;
    MyErrorHandler(PrintStream out) {
    this.out = out;
    * Returns a string describing parse exception details
    private String getParseExceptionInfo(SAXParseException spe) {
    String systemId = spe.getSystemId();
    if (systemId == null) {
    systemId = "null";
    String info = "URI=" + systemId +
    " Line=" + spe.getLineNumber() +
    ": " + spe.getMessage();
    return info;
    * The following methods are standard SAX ErrorHandler methods.
    * See SAX documentation for more info.
    public void warning(SAXParseException spe) throws SAXException {
    out.println("Warning: " + getParseExceptionInfo(spe));
    public void error(SAXParseException spe) throws SAXException {
    String message = "Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    public void fatalError(SAXParseException spe) throws SAXException {
    String message = "Fatal Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);

  • Socket input stream

    ok, here it is...
    A socket must recieve bytes,...how can I check if input is empty (doesn't contain any byte)
    e.g:
    while(input byte is available ){
    }

    That code doesn't work because sockets doesn't work like that.
    "how can I check if input is empty "
    You can't.
    You should send a message which means "end of file" and the last number of bytes read. After writing arrays(that you read) to the socket you should send this message to inform the client about EOF.
    And on the client side you should check the "end of file" message in a loop.
    Also when reading from socket stream you read primitive types like int,byte,long with readInt(),readByte(),readLong methods and you read any object with readObject() method of the ObjectInputStream object. So you must cast the objects(that you read from the socket) to a byte array in your example.Like:
    InputStream input=socket.getInputStream();
    ObjectInputStream objIn = new ObjectInputStream(input);
    while{
    byte buffer[]=(byte[])objIn.readObject();
    //Process the buffer
    But I recommend you to write a class which has a byte array, an attribute for the number of bytes read, 2nd attribute stating if EOF is reached and the neccessary methods. The upper one is not a good practice because you must check if the recieved bytes are array or an EOF message with if statements. With the new class you always send the same object from the server and when client recieves the object it should cast the Object to the prior class then client can check if it is EOF or not,...etc

  • Reading an image from input stream

    Hello all,
    I'm familiar with setting up an input stream but I have never actually done it. I'm making a connection to a URL (a JPG image). I would like to read the JPG from the URL using an input stream. With the URL class I was able to open a stream, however, I'm not exactly sure how to read from it.
    I'm aware of the read() method and read(byte[]) methods of inputstream. But how do I actually implement it?
    If I use read(), then bytes come in individually... do I need to combine them at one point? If I read the bytes into an array, how do I determine what size to set the array and how do I convert the byte array into an Image or ImageIcon?
    Please advise.
    R. Alcazar

    Hi,
    See http://java.sun.com/products/jdk/1.2/docs/guide/2d/api-jpeg/
    and especially JPEGCodec.createJPEGDecoder(java.io.InputStream).
    Anyway, you might not want to do it with InputStream. Instead you could try something like this:
    URLConnection con = // get it somehow
    Image i = (Image) con.getContent(new Class[] {Image.class});
    However, If you still want to use the InputStream, here you go with some pseudo code:
    InputStream in = // get the input stream with JPEG data...
    JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
    Image i = dec.decodeAsBufferedImage();
    You can get the InputStream from the URLConnection with getInputStream(). However, I don't remember if the InputStream contained also the HTTP (or what ever protocol the URL specifies) headers. If it contains the headers, then you must rip them of before giving the InputStream to the JPEGCodec...
    If this is the case, try calling the URLConnection.getHeaderFields() method before getInputStream. This might not work though.

Maybe you are looking for

  • Fixed Asset and G/L reconciliation

    Dear All Can anyone help me with how best to reconcile the fixed asset module with the General Ledger. Is there a guideline or process on what reports are best used and how to do this. Many Thanks PRG

  • Open external browser in SAME window

    Hi all. I've seen several posts on a related issue here about how one could open up an external web browser to display content in the browser window. I tested the solution which uses a call to Runtime.getRuntime().exec(...) to execute a new Process a

  • 10g AS: How to run 2 Midtiers in one infrastructure

    We are trying to install two midtiers of Portal 10g (let�s call them internet and intranet) using one and the same infrastructure (infstr1). So far we installed the 10g infstr1 using an existing Database placed on a different server. We also installe

  • Can I use the unlocked Iphone 6 in germany (with german card)?

    I am only for 1 year in the us and I want to buy a new iphone but I am not sure if it would work in germany. i don't really know much about technics but I heard that you use gsm in europe ... can anyone help me ?

  • J2ME SDK 3.0.5 Plugin Causing Problems in IDE

    Hello, After I installed the new JAVA ME Plugin for 3.0.5 SDK and integrated with my Netbeans IDE, I cannot run my other projects that is not JavaME based. It gives an error saying the execution directory is wrong. It complains "work is not a valid d