On 29/03/2012 13:11, Farrukh Najmi wrote: > On 03/29/2012 04:13 AM, Pid wrote: >> On 29/03/2012 00:20, Farrukh Najmi wrote: >>> Hi Filip, >>> >>> Thanks for your help. >>> >>> It is an html file that is not in the same webapp. >>> >>> Root URL for webapp: http://localhost:8080/myapp >>> Static resource URL being accessed: >>> http://localhost:8080/static/index.html >>> Directory for static resource: >>> ~/apache-tomcat-7.0.26/webapps/static/index.html >> There's no guarantee that the 'static' application will have started by >> the time the other application is trying to make the request. >> >>> Webapp is loaded using following file: >>> ~/apache-tomcat-7.0.26/conf/Catalina/localhost/myapp.xml >>> >>> <?xml version="1.0" encoding="UTF-8"?> >>> <Context antiJARLocking="true" docBase="/home/najmi/myapp/target/myapp" >>> path="/myapp"/> >> You don't need the path attribute here. >> >>> Stack trace: >>> >>> ERROR [pool-2-thread-1] (HTMLUtility.java:88) - Error accessing url: >>> http://localhost:8080/static/index.html >>> java.net.SocketTimeoutException: Read timed out >>> at java.net.SocketInputStream.socketRead0(Native Method) >>> at java.net.SocketInputStream.read(SocketInputStream.java:129) >>> at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) >>> at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) >>> at java.io.BufferedInputStream.read(BufferedInputStream.java:317) >>> at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687) >>> at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632) >>> at >>> sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072) >>> >> That seems like an unusual design choice. What is your goal? > > > My webapp dynamically loads jars in a specific directory during startup.
Most webapps do this, no? > These jars are for plugins for extension supported by by my webapp. > Is there a better way to do this? Does one of the existing classloader mechanisms not provide a means to achieve this? I'm thinking of the shared loader (see catalina.properties) or the VirtualWebappLoader, (see docs). > Is there any way to start the static app before other webapps? Where does the static app fit into the above? Are you selecting & loading the JARs from an HTTP connection? You *could* take advantage of the multithreading support for deploying applications, & just wait until the static app is available - but I'd try & avoid this approach if possible. See Host.startStopThreads in the docs. p > Thanks for your kind help. > >> >> p >> >> >>> On 03/28/2012 06:58 PM, Filip Hanik (mailing lists) wrote: >>>> Are you trying to read a file in the same webapp or another? >>>> >>>>> -----Original Message----- >>>>> From: Farrukh Najmi [mailto:farr...@wellfleetsoftware.com] >>>>> Sent: Wednesday, March 28, 2012 4:34 PM >>>>> To: users@tomcat.apache.org >>>>> Subject: Accessing static resource during loading of webapp >>>>> >>>>> >>>>> I have a webapp that accesses some static resources during startup of >>>>> the webapp. On Glassfish 3.1.2 this works fine. However on Tomcat >>>>> 7.0.26 >>>>> the webapp ciode gets a read timeout when it tries to do an HTTP GET >>>>> using a URLConnection to a static resource deployed in the same tomcat >>>>> instance. Is there a way to fix this? >>>>> >>> > -- [key:62590808]
signature.asc
Description: OpenPGP digital signature