| Author |
HttpURLConnection got stack when trying to invoke
|
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
|
|
Hello im trying to perform http get request with HttpURLConnection when tomcat server is starting up the function is located in the servlet init method , but it seams that when it reached to the part it reform the connection the connection got stocked . here is my code:
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
Are you trying to make a request to an application in the same container? If so, you may be in a deadlock situation. App A tries to start firstApp A tries to connect to app B on startupApp B isn't running yetApp A can't finish starting until the init method fishes (but can't because it's waiting for app BApp B and start until app A has started.
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
|
|
Is there any way to over come this ? mybe to some how to run this after the application done loading ?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56224
|
|
|
It would probably help greatly if you told us what you are actually trying to accomplish!
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
There is nothing in the servlet spec for dictating which apps get loaded first. I don't know if any containers provide their own way to do this. I use Tomcat and I know it doesn't. Unless you know that the container that you're using has a way to control the order of app deployment, you should avoid having one app depend on another; especially during startup. You might want to have this initialization take place when a servlet is hit for the first time. If you do this, you should also have a way to gracefully handle a situation where the servlet gets hit before the dependency app has started. Something like an error page that asks the user to try again in a moment. Another option is to run two separate container instances, one for each app. As Bear asked, why are you doing this in the first place?
|
 |
Meir Yan
Ranch Hand
Joined: Apr 27, 2006
Posts: 597
|
|
Hello all and thanks for the reply What im trying to do is to recompile the jsp's before the application loading. I was fallowing this link : http://www.j2eegeek.com/blog/2004/05/03/a-different-twist-on-pre-compiling-jsps/ But instead of loading the jsp's from the web.xml im looping throw all my jsp's
|
 |
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
|
|
I started reading that article and it looks interesting. I'll read the whole thing later today.
|
 |
 |
|
|
subject: HttpURLConnection got stack when trying to invoke
|
|
|