Stripes ActionResolver doesn't work with JNLPClassLoader in Jetty 6.1
---------------------------------------------------------------------
Key: STS-389
URL: http://mc4j.org/jira/browse/STS-389
Project: Stripes
Issue Type: Improvement
Components: ActionBean Dispatching
Affects Versions: Release 1.4.3
Environment: MacOSX; Windows XP with JDK 6.0
Reporter: Sean Doyle
Assigned To: Tim Fennell
When attempting to load Stripes from inside Jetty which was in turn loaded via
JNLP (Java Web Start) ResolverUtil generates errors of the following form:
INFO [javawsApplicationMain] (Log.java:166) - Checking URL
'/DDL/app/jsp-api.jar' for instances of
net.sourceforge.stripes.action.ActionBean
ERROR [javawsApplicationMain] (Log.java:144) - Could not search jar file
'/DDL/app/jsp-api.jar' for implementations of
net.sourceforge.stripes.action.ActionBeandue to an IOException:
/DDL/app/jsp-api.jar (No such file or directory)
[This is true of all jar files on the path]
The main issue is that loadImplementationsInJar expects the location to be a
file reference which is not available via the JNLPClassLoader. Instead - files
are accessed in the cache via the URL.,
A proposed fix follows (I know that this is all getting upgraded for 1.5 and
will be cleaner than this):
In loadImplementationsFromContextClassloader - add the following logic:
// Only process the URL if it matches one of our filter strings
if ( matchesAny(path, locationFilters) ) {
log.info("Checking URL '", path, "' for instances of ",
parentType.getName());
if (location.isDirectory()) {
loadImplementationsInDirectory(parentType, null,
location);
}
else {
if (path.indexOf("http")== -1)
loadImplementationsInJar(parentType, null,
path);
else
loadImplementationsInJNLPJar(parentType, null,
url);
}
}
and the new method loadImplementionsInJNLPJar is
private void loadImplementationsInJNLPJar(Class<? extends T> parentType,
InputStream inputStream,
URL url) {
try {
JarEntry entry;
HttpURLConnection httpConnection = (HttpURLConnection)
url.openConnection();
httpConnection.setDoOutput (true);
httpConnection.setRequestMethod ("GET");
httpConnection.connect();
if (inputStream == null) inputStream =
httpConnection.getInputStream();
int code = httpConnection.getResponseCode ( ) ;
if ( (code >= 200) && (code < 300 )) {
JarInputStream jarStream = new JarInputStream(inputStream);
while ( (entry = jarStream.getNextJarEntry() ) != null) {
String name = entry.getName();
if (!entry.isDirectory() && name.endsWith(".class")) {
if (matchesAny(name, this.packageFilters)) {
addIfAssignableTo(parentType, name);
}
}
}
}
else{
log.error("Unable to search url " + url + " for implementations
of " +
parentType.getName() + " due to http status
code " + code +
httpConnection.getResponseMessage());
}
}
catch (IOException ioe) {
log.error("Could not search url '", url, "' for implementations of
",
parentType.getName(), "due to an IOException: ",
ioe.getMessage());
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development