JBoss-Jetty 3.0.x fails to startup with latest version of Xe
ssotangkur2 Mar 23, 2004 7:20 PMThis is the same issue as the one described here:
http://junlu.com/msg/38980.html
Basically, if your path to jbossweb.sar contains a space like C:\Program Files\jboss\server\default\deploy\jbossweb.sar then Xerce's XMLEntityManager.setupCurrentEntity() will call expandSystemId() on the filename and convert all spaces to '%20'. This eventually causes the server to fail startup because it cannot find the webdefault.xml file.
[org.apache.xerces.impl.XMLEntityManager]
public String setupCurrentEntity(String name, XMLInputSource xmlInputSource, boolean literal, boolean isExternal)
throws IOException, XNIException {
...
String expandedSystemId = expandSystemId(literalSystemId, baseSystemId, fStrictURI);
...
When retrieving this file, the call to open the file gets delegated to JBoss's FileURLConnection class, which is instantiated with a url.
URL location = new URL(expandedSystemId); URLConnection connect = location.openConnection(); stream = connect.getInputStream();
When it tries to get the inputStream, FileURLConnection will throw an error when it tries to see if the file exists. Thats because the underlying class is a regular java.io.File with a slightly modified filename, although it still has the '%20' in lieu of the space. This '%20' is causing file.exists() to return false.
[org.jboss.net.protocol.file.FileURLConnection]
public void connect() throws IOException
{
if (connected)
return;
if (!file.exists())
{
throw new FileNotFoundException(file.getPath());
}
connected = true;
}
So we need to either fix the call to expandSystemId() to not urlencode the spaces or fix FileURLConnection to unencode the '%20'.
As a temporary fix I modified the constructer for FileURLConnection to decode the '%20'.
public static final String HTML_SPACE = "%20";
public FileURLConnection(final URL url)
throws MalformedURLException, IOException
{
super(url);
String filename = url.getFile().replace('/', File.separatorChar).replace('|', ':');
// Remove '%20' from filenames and replace with space ' '
int idx = filename.indexOf(HTML_SPACE);
StringBuffer sb = new StringBuffer();
while(idx > 0) {
sb.append(filename.substring(0, idx));
sb.append(' ');
filename = filename.substring(idx + HTML_SPACE.length(), filename.length());
idx = filename.indexOf(HTML_SPACE);
}
sb.append(filename);
file = new File(sb.toString());
doOutput = false;
}