On 03/29/2012 08:47 AM, Pid wrote:
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?
In my experience Most apps load jars that are part of the webapp
explicit dependencies which are loaded by the default classloader.
In my webapp I am using java.util.ServiceLoader class to dynamically
load jars using an HttpUrlConnection to the jar served by the static app
in the tomcat instance.
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).
My solution needs to work in a web container independent manner so it
works on Tomcat, Glassfish etc.).
Using a URLClassLoader with URLs to the jars discovered dynamically by
reading an index.html file is what my app does now.
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?
Yes. My webapp reads a static index.html file and gets URLs for jars
listed in it using href attribute. It then creates a URLClassLoader with
URLs to the jars discovered dynamically and uses that ClassLoader with
the ServiceLoader.load method as follows:
ServiceLoader.load(MyPluginIterface.class, urlClassLoader);
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.
Again, My solution needs to work in a web container independent manner
so it works on Tomcat, Glassfish etc.).
If I do not find a way to do this then the fallback would be to do the
dynamic loading of plugin jars lazily after server startup.
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?
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org