From: Fausto L. <f....@in...> - 2003-03-21 14:07:38
|
Hi, thanks Ian, ki-jzjkit 1.2 now compiles. I downloaded correctly the jars from the actual CVS repository. I must have made a mess because those jars are not included in the jzjkit sources' zip bundle, maybe intentionally, I don't know. About the socket closed exception. I hacked the ZEndpoint code, adding a try catch block as in the code snippet below, and it seems catching the exception correctly. The application then doesn't print the stack trace, if the call to the function is commented out. I swear I came to the oppose conclusion yesterday, anyway. Maybe someone can double check. What possibly causes the throwing of the exception though, if not a server-side closing ? I don't think there is some forced thread termination, in this case we should get a InterruptedIOException. Maybe a timeout of the socket itself, but I just checked the logging and see the the timeout of the socket is set to 0 ( which probably means no timeout). If a got some time I'll try and clarify this to myself soon ... Let me go to yet another issue very brief though. I found the InformationFragment interface really useful, yet I don't need to use the whole IR package itself, since I just deal with single database query. Any chance that the InformationFragment related classes would be factored out in their own sub package ? Thank you, Fausto ------------------------------------- NOTE: << these lines have been added to the original source file while(running) { try { cat.debug("Waiting for data on input stream....."); BERInputStream bds = new BERInputStream(incoming_data, charset_encoding); PDU_type pdu = null; pdu = (PDU_type)codec.serialize(bds, pdu, false, "PDU"); cat.debug("Notifiy observers"); if ( pdu.which == PDU_type.close_CID ) close_notified=true; decOpCount(); notifyAPDUEvent(pdu); cat.debug("Yield to other threads...."); yield(); } catch ( java.io.InterruptedIOException iioe ) { cat.debug("Processing java.io.InterruptedIOException, shut down association"+" - hostname="+target_hostname); cat.info(iioe.toString()); running=false; } catch ( java.net.SocketException se ) { // Most likely socket closed. if ( cat.isDebugEnabled() ) se.printStackTrace(); cat.info(se.toString()+" - hostname="+target_hostname); running=false; } << catch ( IOException ioe ) << { << System.out.println("ZEndpoint :: Got IOException from the listening socket : "); << if ( cat.isDebugEnabled() ) << //e.printStackTrace(); << System.out.println(ioe.toString()); << cat.info(ioe.toString()+" - hostname="+target_hostname); << running=false; << // System.exit(1); << } catch ( Exception e ) { << System.out.println("ZEndpoint :: Got Generic Exception from the listening socket :"); if ( cat.isDebugEnabled() ) e.printStackTrace(); cat.info(e.toString()+" - hostname="+target_hostname); running=false; } ----- Original Message ----- From: "Ian Ibbotson" <ian...@k-...> To: "Fausto Lelli" <f....@in...> Cc: <Jzj...@li...> Sent: Thursday, March 20, 2003 6:05 PM Subject: Re: [Jzjkit-user] Intermittent IOException: Socket Closed. > Hmm... If you just check out the latest jzkit it should have all the > right jar files, including the jdbm-0.12.jar (And associated license). > The jdbm stuff is only used if you need to search many targets at the > same time (used for results management). I'm adding conditional > compilation into the JZKit 2 release so that the "HSSProvider" is only > compiled when all required classes (jdbm in this case) can be found. > > Are you sure your build environment is OK? The ASNUseful classes are > certainly in the latest a2j project. In a moment of self doubt I checked > the latest a2j out of cvs to look for myself, and also used jar tvf on > the a2jruntime.jar from the head revision of jzkit and the ASNUseful > classes are in there also. ASNUseful used to reside in JZKit but I had > to move it into a2j because (a) it's more sensible and (b) the > OpenRequest project needed the useful types for the ILL toolkit, so I'm > quite certain about the location of those classes. > > It *really* sounds like there is something odd about your jar files... > any chance you could just re-check out the head revision from CVS? > > On to the actual problem tho.... I'm not sure what we actually expect to > happen? If the connection has been closed unexpectedly by the target > then IOException is the right exception? I don't think there will ever > be 2 IOExceptions thrown as such... If there is a "problem" reading the > stream then the read itself will throw an exception, if the call to read > returns -1, then we throw an IOException manually (Because in this call > to read we *expect* there to be more data according to the BER). Does > that sound right? > > Cheers, > e. > > > Fausto Lelli wrote: > > > Hi, > > > > I've been tracking down that "IOException: Socket Closed " too > > and I found a piece of code that seems suspicious to my eyes. > > It is in the BERInputStream class that belongs to the package > > com.k_int.codec.runtime : > > > > public int read(byte abyte()[], int i, int j) > > throws IOException > > { > > int k = in.read(abyte(),i,j); > > if(k==-1) > > throw new IOException("Connection Closed"); > > if(endcoding_info.size() > 0) > > { > > CodecStackInfo codecstackinfo = > > (CodecStackInfo)encoding_info.peek(); > > codecstackinfo.bytes_processed += k; > > } > > return k; > > } > > > > It *might* happen that thera are two IOException thrown, since the > > instance "in" > > is of type BufferedInputStream whose method "read" throws a > > IOException itself. > > Once exception is caught in upper levels, the other propagates up > > to the top of > > the listening thread stack where it is finally printed out as a stack > > trace. > > > > I can't verify these hipotesis since the newest release of a2j does > > not contain > > the package com.k_int.gen.AsnUseful, as the old a2j did, and cannot > > be used together with the jzkit release 1.0. > > The package has been moved to the main jzjkit project, version 1.2 , > > which in turn i can't compile, since I don't know where to find the > > package jdbm.*. > > > > Ok, I said it all, thank you for your consideration. > > Let me know what do you think of all this and how could I proceed .. > > > > Fausto > > > > > > -- > Ian Ibbotson (ian...@k-...) > Knowledge Integration Ltd > Sheffield Science & Technology Parks > Cooper Buildings > Arundel Street > Sheffield > S1 2NS > http://www.k-int.com > > > |