| Home » Eclipse Projects » Equinox » Running multiple instances of servletbridge in a tomcat instance
 Goto Forum:| 
| Running multiple instances of servletbridge in a tomcat instance [message #119918] | Tue, 21 October 2008 14:36  |  | 
| Eclipse User  |  |  |  |  | Hi, 
 I'm having an issue with deploying two war files (say A and B) both of
 which use servletbridge running under a single tomcat instance.
 The scenario is this:
 1. Visit JSF pages in A.
 2. open up a JSF page in B.  I get this error:
 org.apache.jasper.JasperException: org.apache.jasper.JasperException: The
 absolute uri: http://java.sun.com/jsf/core cannot be resolved in either
 web.xml or the jar files deployed with this application
 
 If I run only one of the web apps at a time, then it works fine.  Also, If
 I visit B first and then A, then I get the same error in A.
 
 After debugging, I found out that bundles in A and B having the same ID
 have problems.  What happens is that when Tomcat tries to compile a jsp
 page, it needs to access all the jar files in the webapp's classpath to
 get all the tld declarations.  Jasper uses JarURLConnection to get jar
 files from bundles which gets cached by JarURLConnection.  The URL looks
 like, "bundleentry://<bundle_id>/web/WEB-INF/lib/jsf-impl.jar".
 
 So, for the first web application that gets accessed, everything works
 fine.  Jar files are accessed correctly and downloaded, and tlds are read
 properly.  But when the second web application gets accessed, Tomcat tries
 to access all the jar files in the classpath for the web app, and ends up
 creating a URL that looks like
 "bundleentry://<bundle_id>/web/WEB-INF/lib/jsf-impl.jar" , which looks
 exactly the same as the URL in the first application.
 
 Then, JarURLConnection decides to return the cached jar file for the
 request.  This fails because the cached jar file has already been deleted
 by Tomcat.  Therefore, the compilation of the jsp page fails.  Besides,
 the jar file is from a different web app anyways, so the logic seems wrong
 to me.
 
 FYI, the error itself is from
 org.apache.jasper.compiler.TldLocationsCache#scanJar(JarURLC onnection,
 boolean):364, but basically, JarURLConnection#getJarFile() is returning a
 cached file that doesn't exist, which causes this problem.
 
 
 Is this a bug, or by design?
 
 Thanks,
 
 taki
 |  |  |  |  | 
| Re: Running multiple instances of servletbridge in a tomcat instance [message #119967 is a reply to message #119918] | Tue, 21 October 2008 23:26   |  | 
| Eclipse User  |  |  |  |  | Servletbridge webapps are themselves isolated and in now way restricted from running many instances in the same app server. I've run 30+ instances as
 part of my testing. Can you describe how you've packaged your application.
 Are you trying to use the app servers jsp and faces engine along with the
 servletbridge? AFAIK this approach won't work.
 
 If you're taking the suggested approach of embedding a JSF engine (like
 myfaces) in your servlet bridge application you should be aware that there
 were some as of yet unresolved modularity issues when running and embedding
 a JSF engine in an OSGi environment. I recall the issue was in how
 FactoryFinder shared resources but never dug into it myself. Perhaps you're
 already aware of these problems?? (See a post by Mark Allerton -- August 16,
 2007)
 
 -Simon
 
 "Takahiro Kato" <takahiro.kato@sap.com> wrote in message
 news:65a61e7d455bf3907e5bc2e1e22ffde6$1@www.eclipse.org...
 > Hi,
 >
 > I'm having an issue with deploying two war files (say A and B) both of
 > which use servletbridge running under a single tomcat instance.
 > The scenario is this:
 > 1. Visit JSF pages in A.
 > 2. open up a JSF page in B.  I get this error:
 > org.apache.jasper.JasperException: org.apache.jasper.JasperException: The
 > absolute uri: http://java.sun.com/jsf/core cannot be resolved in either
 > web.xml or the jar files deployed with this application
 >
 > If I run only one of the web apps at a time, then it works fine.  Also, If
 > I visit B first and then A, then I get the same error in A.
 >
 > After debugging, I found out that bundles in A and B having the same ID
 > have problems.  What happens is that when Tomcat tries to compile a jsp
 > page, it needs to access all the jar files in the webapp's classpath to
 > get all the tld declarations.  Jasper uses JarURLConnection to get jar
 > files from bundles which gets cached by JarURLConnection.  The URL looks
 > like, "bundleentry://<bundle_id>/web/WEB-INF/lib/jsf-impl.jar".
 >
 > So, for the first web application that gets accessed, everything works
 > fine.  Jar files are accessed correctly and downloaded, and tlds are read
 > properly.  But when the second web application gets accessed, Tomcat tries
 > to access all the jar files in the classpath for the web app, and ends up
 > creating a URL that looks like
 > "bundleentry://<bundle_id>/web/WEB-INF/lib/jsf-impl.jar" , which looks
 > exactly the same as the URL in the first application.
 >
 > Then, JarURLConnection decides to return the cached jar file for the
 > request.  This fails because the cached jar file has already been deleted
 > by Tomcat.  Therefore, the compilation of the jsp page fails.  Besides,
 > the jar file is from a different web app anyways, so the logic seems wrong
 > to me.
 >
 > FYI, the error itself is from
 >  org.apache.jasper.compiler.TldLocationsCache#scanJar(JarURLC onnection,
 > boolean):364, but basically, JarURLConnection#getJarFile() is returning a
 > cached file that doesn't exist, which causes this problem.
 >
 >
 > Is this a bug, or by design?
 >
 > Thanks,
 >
 > taki
 >
 |  |  |  |  | 
| Re: Running multiple instances of servletbridge in a tomcat instance [message #120017 is a reply to message #119967] | Wed, 22 October 2008 18:54   |  | 
| Eclipse User  |  |  |  |  | Hi Simon, 
 Thanks for the reply.
 
 Yes, I'm aware of the JSF issue, but I'm taking a different approach.
 
 Basically, I'm taking multiple war files to deployed under two webapps
 each of which uses servlet bridge.  So, each of my webapp contains
 multiple "used-to-be webapps" within it.  The structure of a used-to-be
 war file bundle looks like this:
 
 web/
 web/myjsp.jsp
 ...
 web/WEB-INF
 web/WEB-INF/lib
 web/WEB-INF/lib/jsf-impl.jar
 ...
 META-INF
 META-INF/MANIFEST.MF
 
 As you can see, I didn't create a separate bundle for JSF.  JSF jars are
 contained within each bundle that needs to use JSF.  I have serveral
 bundles that look like this within a war file, and i have two of those war
 files.
 
 Let's say I have war files A and B, and A contains bundle a, b, and c, and
 B has d and e.  all the bundles in A and B have the same structure as the
 "war file bundle" as explained above.  That means that each bundle
 contains its own jsf-impl.jar file.
 
 When A and B are deployed in a tomcat, OSGi starts up in both web apps,
 and assign IDs to bundles.  For example, in A, a will have an ID of 1, b
 will have an ID of 2 etc.  In B, d will have an ID of 1 as it's a totally
 separate OSGi instance from that of A.
 
 However, the interesting thing is that, when those bundles are read to get
 tlds as I described in the original post, jsf-impl.jar, for example, are
 considered the same by URLConnection object created by the jasper
 compiler.  It seems that it happens because the URL to jar files in a (in
 A with ID of 1) and d (in B with ID of 1) look exactly the same.  For
 example, the URL to the jsf-impl.jar in a and d both would look like
 "bundleentry://1/web/WEB-INF/lib/jsf-impl.jar.
 
 This is a problem as the contents of jar files in different web apps can
 be shared unintentionally.  (in my case, though, the cached jar file
 downloaded using URLConnection has been deleted by the time the second web
 app tries to retrieve to use it -- hence the tld not found error)
 
 IMHO, the keys to reproduce this issue are:
 1. two "war file bundles" deployed under different webapps need to have
 exactly the same structures so that the URL path to a jar file would look
 exactly the same.
 2. the war file bundles must contain the same jar files.  again, this is
 necessary as the URL path to it must look the same.
 
 3. the war file bundles that satisfy above must have the same bundle ID.
 
 
 Please let me know if I'm not clear.
 
 
 thanks,
 
 taki
 |  |  |  |  | 
| Re: Running multiple instances of servletbridge in a tomcat instance [message #120043 is a reply to message #120017] | Wed, 22 October 2008 21:35   |  | 
| Eclipse User  |  |  |  |  | Thanks Taki, 
 Would it be possible for you to open a bug and construct an example that I
 could try on my machine. I think you do have something here.
 
 I'm at a loss why the cached result of the URLConnection is being re-used
 across frameworks. We use a special URLStreamHandlerFactory to figure out
 which framework is the owner of a particular bundleentry (or any other type
 of) URL. There could conceivably be a bug in there but off the top of my
 head all I can think of is that somewhere in the URLClassLoader chain the
 implementation is somehow doing some caching of the result. In particular
 I'd be suspicious of how the jar URLHandler caches jar files loaded from
 non-file URLConnections. You've identified that there might be an issue with
 bundleentry URLs with the same external form but operating in different
 framework instances. We might be able to make a change to guarantee
 uniqueness cross framework in the same VM but we would need have a
 legitimate testcase to justify this sort of a change.
 
 -Simon
 
 "Takahiro Kato" <takahiro.kato@sap.com> wrote in message
 news:2f7a19b388725fbb2c5d97d3707351a2$1@www.eclipse.org...
 > Hi Simon,
 >
 > Thanks for the reply.
 >
 > Yes, I'm aware of the JSF issue, but I'm taking a different approach.
 >
 > Basically, I'm taking multiple war files to deployed under two webapps
 > each of which uses servlet bridge.  So, each of my webapp contains
 > multiple "used-to-be webapps" within it.  The structure of a used-to-be
 > war file bundle looks like this:
 >
 > web/
 > web/myjsp.jsp
 > ..
 > web/WEB-INF
 > web/WEB-INF/lib
 > web/WEB-INF/lib/jsf-impl.jar
 > ..
 > META-INF
 > META-INF/MANIFEST.MF
 >
 > As you can see, I didn't create a separate bundle for JSF.  JSF jars are
 > contained within each bundle that needs to use JSF.  I have serveral
 > bundles that look like this within a war file, and i have two of those war
 > files.
 >
 > Let's say I have war files A and B, and A contains bundle a, b, and c, and
 > B has d and e.  all the bundles in A and B have the same structure as the
 > "war file bundle" as explained above.  That means that each bundle
 > contains its own jsf-impl.jar file.
 >
 > When A and B are deployed in a tomcat, OSGi starts up in both web apps,
 > and assign IDs to bundles.  For example, in A, a will have an ID of 1, b
 > will have an ID of 2 etc.  In B, d will have an ID of 1 as it's a totally
 > separate OSGi instance from that of A.
 >
 > However, the interesting thing is that, when those bundles are read to get
 > tlds as I described in the original post, jsf-impl.jar, for example, are
 > considered the same by URLConnection object created by the jasper
 > compiler.  It seems that it happens because the URL to jar files in a (in
 > A with ID of 1) and d (in B with ID of 1) look exactly the same.  For
 > example, the URL to the jsf-impl.jar in a and d both would look like
 > "bundleentry://1/web/WEB-INF/lib/jsf-impl.jar.
 >
 > This is a problem as the contents of jar files in different web apps can
 > be shared unintentionally.  (in my case, though, the cached jar file
 > downloaded using URLConnection has been deleted by the time the second web
 > app tries to retrieve to use it -- hence the tld not found error)
 >
 > IMHO, the keys to reproduce this issue are:
 > 1. two "war file bundles" deployed under different webapps need to have
 > exactly the same structures so that the URL path to a jar file would look
 > exactly the same.
 > 2. the war file bundles must contain the same jar files.  again, this is
 > necessary as the URL path to it must look the same.
 >
 > 3. the war file bundles that satisfy above must have the same bundle ID.
 >
 >
 > Please let me know if I'm not clear.
 >
 >
 > thanks,
 >
 > taki
 >
 >
 |  |  |  |  |  | 
 
 
 Current Time: Fri Oct 31 16:41:28 EDT 2025 
 Powered by FUDForum . Page generated in 0.04198 seconds |