Hello All,

I developed a small crawler application. This is a multi thread application. This application was working fine from last 2.5 days but suddenly all threads blocked.

I checked its status through JConsole and found

Total # of Threads 10

_______________________Thread # 1,2,3,4,5,6,7,9,10 Status_________________________________

Name: Crawler 7
State: BLOCKED on java.io.PrintStream@127afe7 owned by: Crawler 8
Total blocked: 61 Total waited: 9

Stack trace:
java.lang.Throwable.printStackTrace(Throwable.java :461)
java.lang.Throwable.printStackTrace(Throwable.java :451)
PageFetcher.fetch(PageFetcher.java:229)
downloadPage(CrawlerThread.java:78)
CrawlerThread.run(CrawlerThread.java:63)
java.lang.Thread.run(Thread.java:619)


_______________________Thread # 8 Status_________________________________
Name: Crawler 8
State: RUNNABLE
Total blocked: 43 Total waited: 5

Stack trace:
java.io.FileOutputStream.writeBytes(Native Method)
java.io.FileOutputStream.write(FileOutputStream.ja va:260)
java.io.BufferedOutputStream.flushBuffer(BufferedO utputStream.java:65)
java.io.BufferedOutputStream.flush(BufferedOutputS tream.java:123)
- locked java.io.BufferedOutputStream@8d9051
java.io.PrintStream.write(PrintStream.java:432)
- locked java.io.PrintStream@127afe7
sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder. java:202)
sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEnc oder.java:272)
sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder .java:85)
- locked java.io.OutputStreamWriter@1fdb82c
java.io.OutputStreamWriter.flushBuffer(OutputStrea mWriter.java:168)
java.io.PrintStream.write(PrintStream.java:477)
- locked java.io.PrintStream@127afe7
java.io.PrintStream.print(PrintStream.java:619)
java.io.PrintStream.println(PrintStream.java:756)
- locked java.io.PrintStream@127afe7
java.lang.Throwable.printStackTrace(Throwable.java :464)
- locked java.io.PrintStream@127afe7
java.lang.Throwable.printStackTrace(Throwable.java :451)
PageFetcher.fetch(PageFetcher.java:229)
downloadPage(CrawlerThread.java:78)
CrawlerThread.run(CrawlerThread.java:63)
java.lang.Thread.run(Thread.java:619)


Here is the code of PageFetcher which is causing this issue

Java Code:
catch (IOException e) {
			logger.error("Fatal transport error: " + e.getMessage() + " while fetching " + toFetchURL + ")");
			return PageFetchStatus.FatalTransportError;
		} catch (IllegalStateException e) {
			// ignoring exceptions that occur because of not registering https
			// and other schemes
		} catch (Exception e) {
			e.printStackTrace();
			if (e.getMessage() == null) {
				logger.error("Error while fetching " + page.getUrl().getUrl());
			} else {
				logger.error(e.getMessage() + " while fetching " + page.getUrl().getUrl());
			}
		}

At Pagefetcher:229 I have e.printStackTrace();

I am already using log4j for logging. I am not able to understand reason behind this issue as this statement "e.printStatckTrace()" exceuted many time since crawler started but suddenly everything blocked because of this.

Regards, Alex