You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by JW...@FAMILYDOLLAR.com on 2005/09/30 23:13:46 UTC

[vfs] When using an action - sleep thread, upon second connect, I get Socket write error.

The first time runs fine, other than taking large amounts of my heap (issue
for another thread).

Then on after the sleep time (15 mins) i recieve the error below. The odd
thing is, this works fine on another computer with the exact same libraries
and JRE (1.5.0_04). However when i turn the sleep time on the problem system
to 10 seconds, I do not recieve an error. 

Shouldn't VFS be making a new connection every time the thread runs? It
seems that it is trying to use a cached connection even though i've made
every effort to call fsm.getFilesCache().close() to clear the file cache.

Any help is appreciated.

Exception:
org.apache.commons.vfs.FileSystemException: Could not determine the type of
file "<ftp path omitted for security reasons>".
	at
org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject
.java:1229)
	at
org.apache.commons.vfs.provider.AbstractFileObject.getChildren(AbstractFileO
bject.java:515)
	at
com.familydollar.edi.index.EDIIndexer$IndexThread.processChildren(EDIIndexer
.java:290)
	at
com.familydollar.edi.index.EDIIndexer$IndexThread.run(EDIIndexer.java:266)
Caused by: java.net.SocketException: Connection reset by peer: socket write
error
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(Unknown Source)
	at java.net.SocketOutputStream.write(Unknown Source)
	at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
	at java.io.BufferedOutputStream.flush(Unknown Source)
	at
org.apache.commons.net.telnet.TelnetClient._flushOutputStream(TelnetClient.j
ava:77)
	at
org.apache.commons.net.telnet.TelnetOutputStream.flush(TelnetOutputStream.ja
va:137)
	at java.io.FilterOutputStream.flush(Unknown Source)
	at sun.nio.cs.StreamEncoder$CharsetSE.implFlush(Unknown Source)
	at sun.nio.cs.StreamEncoder.flush(Unknown Source)
	at java.io.OutputStreamWriter.flush(Unknown Source)
	at java.io.BufferedWriter.flush(Unknown Source)
	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:442)
	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:520)
	at org.apache.commons.net.ftp.FTP.port(FTP.java:849)
	at
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:477
)
	at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2390
)
	at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2364
)
	at
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2090)
	at
org.apache.commons.vfs.provider.ftp.FTPClientWrapper.listFiles(FTPClientWrap
per.java:100)
	at
org.apache.commons.vfs.provider.ftp.FtpFileObject.doGetChildren(FtpFileObjec
t.java:122)
	at
org.apache.commons.vfs.provider.ftp.FtpFileObject.getChildFile(FtpFileObject
.java:91)
	at
org.apache.commons.vfs.provider.ftp.FtpFileObject.getInfo(FtpFileObject.java
:167)
	at
org.apache.commons.vfs.provider.ftp.FtpFileObject.doAttach(FtpFileObject.jav
a:156)
	at
org.apache.commons.vfs.provider.AbstractFileObject.attach(AbstractFileObject
.java:1215)
	... 3 more

CODE:

	class IndexThread extends Thread {
		private ArrayList<String> fileNames;
		public IndexThread(){fileNames = new ArrayList<String>();}
		public void run(){
			while(go){
				Calendar c = Calendar.getInstance();
				System.out.println("Indexing Service
Started: " + c.get(Calendar.DAY_OF_MONTH)+ "/"+ c.get(Calendar.MONTH) + "/"
+ c.get(Calendar.YEAR) +" "+c.get(Calendar.HOUR_OF_DAY)+
":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.MILLISECOND));
				FileSystemManager fsm = null;
				try {
					//get a FileSystemManager from the
static class VFS (part of API)
					fsm = VFS.getManager();
					Iterator it =
fileMountPoints.iterator();		
					while(it.hasNext()){
						//get the next file mount
point
						// ex data is
"ftp://jwilliam@password/server/path/to/files"
						String loc =
(String)it.next();
						
						//resolve the URL into a
FileObject...
						remoteFO =
fsm.resolveFile(loc);
						
						//process the files and
folders in this directory
						processChildren(remoteFO,
fsm);
					}
					//close the File Object ( attempt to
clear the cache and free memory )
					remoteFO.close();
				} catch (FileSystemException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}finally{
					if(fsm!= null)
						//an attempt to clear the
cache.. 
						fsm.getFilesCache().close();
				}
				c = Calendar.getInstance();
				System.out.println("Indexing Service Ended:
" + c.get(Calendar.DAY_OF_MONTH)+ "/"+ c.get(Calendar.MONTH) + "/" +
c.get(Calendar.YEAR) +" "+c.get(Calendar.HOUR_OF_DAY)+
":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.MILLISECOND));
				try {
					//sleeping thread... 
	
Thread.sleep(Long.parseLong(props.getProperty("index.sleep")));
				} catch (NumberFormatException e) {

					System.out.println("index.sleep is
missing in index.config");
				} catch (InterruptedException e) {
					//stop the thread upon interruption
					go = false;
				}
			}
		}

Joe Williams
E-Commerce Analyst
Family Dollar

o:(704)849-7512


-----------------------------------------
************************************************************
NOTE:
This e-mail message contains PRIVILEGED and CONFIDENTIAL information
and is intended only for the use of the specific individual or
individuals to which it is addressed. If you are not an intended
recipient of this e-mail, you are hereby notified that any unauthorized
use, dissemination or copying of this e-mail or the information
contained herein or attached hereto is strictly prohibited. If you
receive this e-mail in error, notify the person named above by reply
e-mail and please delete it. Thank you.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [vfs] When using an action - sleep thread, upon second connect, I get Socket write error.

Posted by Mario Ivankovits <ma...@ops.co.at>.
Hi!
>Then on after the sleep time (15 mins) i recieve the error below. The odd
>thing is, this works fine on another computer with the exact same libraries
>and JRE (1.5.0_04). However when i turn the sleep time on the problem system
>to 10 seconds, I do not recieve an error. 
>  
You already use the latest nightly, dont you?

VFS already tries to recreate the connection an try again on any 
IOException.
In older versions of VFS this was on FtpConnectionClosedException only, 
but this wasnt enough.


Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org