This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
However, while the browser is 'trying' to get the result (from PHP file) if i 'stop' my HttpServer (Java) the result suddenly appears. I am very sure i close all the streams i opened. Does anyone have any idea?
Put breakpoint on doGet() method and go over your lines in both scenarious - if you request your servlet from web browser and if you request your servlet from php simplexml_load_file() method. See the difference.
So on doing some debugging i realized that the http thread that started executing may have not exited correctly. That may explain the fact that when i shut the java server down explicitly while the 'php' code waits for some response, the response suddenly appears.
While creating the server i am using:-
Using the debugger tool took me to the class ThreadPoolExecutor.class which seems to be the bottleneck; This condition is true (poolSize > corePoolSize || allowCoreThreadTimeOut(=false)) and it starts polling. I think maybe this is causing the problem and if it exited maybe the result would appear. Even if the corePoolSize is more than poolsize it seems to be getting stuck in .
I dont know how it works ok with a browser but hangs when PHP request comes into the picture. Strange...
That is a red herring. What it is telling you is that all your request threads have completed the requests they are working on, and are looking for the next request to come in.
So you know your requests complete. But the data doesn't show. This happens for a number of reasons:
1) You aren't closing the connections you think you are, or are not flushing data as you should be
2) You are sending incomplete data - perhaps missing some close tags in your output.
3) You have some other mis-handled exception which causes your request to end in-appropriately.
Nev Mehta wrote:Was not trying to divert attention on purpose; i just thought this maybe the issue. Also, had no idea we needed to mention the we have cross-posted, will do that next time. Thanks for the help.
Nono, I didn't mean you were trying to divert our attention, sorry if you misunderstood. I meant the part of the code you picked up on was diverting your attention from the real issue.