File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Making a request to Servlet from ServletContextListener:contextInitialized  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Making a request to Servlet from ServletContextListener:contextInitialized  " Watch "Making a request to Servlet from ServletContextListener:contextInitialized  " New topic
Author

Making a request to Servlet from ServletContextListener:contextInitialized

vinodh rmahen
Greenhorn

Joined: Jul 22, 2008
Posts: 14
I am trying to make a request to a servlet using HTTPClient within contextInitialized(ServletContextEvent event) of a ServletContextListener, but I get an exception saying that the web module has not yet been loaded.
I am trying this on IBM WebSphere Application Server 6.0.x

Is there any setting which can be used have the servlet initialized and ready to server requests when the call from contextInitialized(ServletContextEvent event) is made
Or
Is there any restriction in the Servlet Specification which prevents this from happening.

Here is the exception:

[4/30/09 8:13:28:782 EDT] 0000007f WebGroup A SRVE0169I: Loading Web Module: MyListener.
[4/30/09 8:13:28:891 EDT] 0000007f SystemOut O Inside MyListener:contextInitialized()
[4/30/09 8:13:29:110 EDT] 00000082 WebContainer E SRVE0232E: Internal Server Error.
Exception Message: [com.ibm.ws.webcontainer.exception.WebAppNotLoadedException: Failed to load webapp: /MyListener
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:233)
at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:210)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java(Compiled Code))
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java(Compiled Code))
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:288)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:207)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:109)
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
]
[4/30/09 8:13:29:110 EDT] 0000007f HttpMethodBas W Going to buffer response body of large or unknown size. Using getResponseBodyAsStream instead is recommended.
[4/30/09 8:13:29:141 EDT] 0000007f SystemOut O <H1>SRVE0232E: Internal Server Error.
Exception Message: [Failed to load webapp: /MyListener]</H1>
<H3>Failed to load webapp: /MyListener</H3>
IBM WebSphere Application Server
[4/30/09 8:13:29:141 EDT] 0000007f VirtualHost I SRVE0250I: Web Module MyListener has been bound to default_host[*:80,*:10013,*:10010,*:10038,*:10035].
[4/30/09 8:13:29:157 EDT] 0000007f ApplicationMg A WSVR0221I: Application started: MyApp
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
Since calls to context listeners are part of the initialization process, initialization is NOT COMPLETE until all calls to listeners have returned. Therefore there is absolutely no reason to expect this to work.

You need to redesign - back up and try again.

Bill
vinodh rmahen
Greenhorn

Joined: Jul 22, 2008
Posts: 14
Thanks for clarifying.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making a request to Servlet from ServletContextListener:contextInitialized