]
David Lloyd moved JBVFS-171 to JBCL-177:
----------------------------------------
Project: JBoss ClassLoader (was: JBoss VFS)
Key: JBCL-177 (was: JBVFS-171)
Affects Version/s: (was: 3.0.0.CR5)
Component/s: VFS
(was: Release)
Security: (was: Public)
ProtectionDomain.getCodeSource().getLocation() returns VFS URL with
trailing slash, subsequently interpreted as path when creating new URL
------------------------------------------------------------------------------------------------------------------------------------------
Key: JBCL-177
URL:
https://issues.jboss.org/browse/JBCL-177
Project: JBoss ClassLoader
Issue Type: Bug
Components: VFS
Environment: Platform doesn't really matter; problem seen with JBoss 6.0.0
Final on Red Hat Enterprise Linux 4 (64-bit) and Windows XP (32-bit).
Reporter: Jon Schuster
Assignee: John Bailey
Labels: codesource, getlocation, vfs
Webapp has a non-jar auxiliary file located in WEB-INF/lib, alongside main application
jar. To load contents of aux file, webapp calls
<currentClass>.getProtectionDomain().getCodeSource().getLocation() to get URL of
main application jar. JBoss returns a VFS URL to the application jar inside the webapp
.war or .ear file, but VFS URL has a slash at the end. Subsequent call to new URL( jarurl,
auxfilename ) results in a new VFS URL with the aux filename appended after the trailing
slash, rather than locating the aux file relative to the application jar.
For example, CodeSource.getLocation() returns this URL:
{{{
vfs:/C:/Development/jboss/jboss-6.0.0.Final/server/default/deploy/testservlet.war/WEB-INF/lib/TestServlet.jar/
}}}
Creating a new URL using "new URL( aboveurl, "testfile.txt" )"
results in this URL:
{{{
vfs:/C:/Development/jboss/jboss-6.0.0.Final/server/default/deploy/testservlet.war/WEB-INF/lib/TestServlet.jar/testfile.txt
}}}
A subsequent attempt to read from the testfile.txt using
URL.openConnection().getInputStream() fails with a FileNotFoundException.
Because of the trailing slash on the VFS URL to the application jar, the context used by
the URL class to construct the new relative URL to the auxiliary file is incorrect, making
the auxiliary file inaccessible.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: