File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpURLConnection got stack when trying to invoke

 
Meir Yan
Ranch Hand
Posts: 599
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

  •  
    Meir Yan
    Ranch Hand
    Posts: 599
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 64205
    83
    IntelliJ IDE Java jQuery Mac Mac OS X
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    It would probably help greatly if you told us what you are actually trying to accomplish!
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 599
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 13411
    Firefox Browser Redhat VI Editor
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic