aspose file tools*
The moose likes Servlets and the fly likes HttpURLConnection got stack when trying to invoke Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpURLConnection got stack when trying to invoke " Watch "HttpURLConnection got stack when trying to invoke " New topic
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 first
  • App A tries to connect to app B on startup
  • App B isn't running yet
  • App A can't finish starting until the init method fishes (but can't because it's waiting for app B
  • App 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: 61766
        
      67

    It would probably help greatly if you told us what you are actually trying to accomplish!


    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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

    Originally posted by Meir Yan:
    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


    I started reading that article and it looks interesting.
    I'll read the whole thing later today.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: HttpURLConnection got stack when trying to invoke