You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/03/24 16:57:43 UTC
svn commit: r640451 - in /tomcat/trunk/java/org/apache/catalina/loader:
LocalStrings.properties WebappClassLoader.java
Author: markt
Date: Mon Mar 24 08:57:42 2008
New Revision: 640451
URL: http://svn.apache.org/viewvc?rev=640451&view=rev
Log:
Fix bug 44633. Tell use which class failed to load due to wrong version number.
Modified:
tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties
tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
Modified: tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties?rev=640451&r1=640450&r2=640451&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties Mon Mar 24 08:57:42 2008
@@ -29,6 +29,7 @@
standardLoader.starting=Starting this Loader
standardLoader.stopping=Stopping this Loader
webappClassLoader.stopped=Illegal access: this web application instance has been stopped already. Could not load {0}. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
+webappClassLoader.wrongVersion=Unable to load class {0} due to a bad version number in the .class file.
webappLoader.addRepository=Adding repository {0}
webappLoader.deploy=Deploying class repositories to work directory {0}
webappLoader.jarDeploy=Deploy JAR {0} to {1}
Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=640451&r1=640450&r2=640451&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Mon Mar 24 08:57:42 2008
@@ -1842,9 +1842,14 @@
}
if (entry.loadedClass == null) {
- clazz = defineClass(name, entry.binaryContent, 0,
- entry.binaryContent.length,
- new CodeSource(entry.codeBase, entry.certificates));
+ try {
+ clazz = defineClass(name, entry.binaryContent, 0,
+ entry.binaryContent.length,
+ new CodeSource(entry.codeBase, entry.certificates));
+ } catch (UnsupportedClassVersionError ucve) {
+ throw new UnsupportedClassVersionError(
+ sm.getString("webappClassLoader.wrongVersion", name));
+ }
entry.loadedClass = clazz;
entry.binaryContent = null;
entry.source = null;
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r640451 - in /tomcat/trunk/java/org/apache/catalina/loader:
LocalStrings.properties WebappClassLoader.java
Posted by Rainer Jung <ra...@kippdata.de>.
Mark Thomas schrieb:
> Rainer Jung wrote:
>> when I saw your commit, I asked myself "What's the original error
>> message" because we shouldn't overwrite any other information that's
>> helpful.
> The error message (currently) isn't that helpful but your patch is good
> in that it allows us to make use of the error message it it ever is
> useful. I'll update my proposed patch.
Thanks.
In fact depending on the JVM, there are a couple of messages an ucve can
contain. Not sure, which ones apply in this situation. In the Sun VM
there are at least:
1.6:
- Unsupported major.minor version MAJOR.MINOR
- CLASSNAME : Unsupported major.minor version MAJOR.MINOR
- version numbers of class are not supported
1.5 (yes, it seems to output less info, than 1.6 and 1.4.2):
- Bad version number in .class file
- version numbers of class are not supported
1.4.2:
- Unsupported major.minor version MAJOR.MINOR
- CLASSNAME (Unsupported major.minor version MAJOR.MINOR)
- version numbers of class are not supported
So sometimes there is more info available, and it also may depend on the
VM, because the messages are not standardized (at least not that I'm
aware of). In view of the above messages and their differences for the
different JVM versions, our fix could be seen as a workaround for a JVM
1.5 bug ;)
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r640451 - in /tomcat/trunk/java/org/apache/catalina/loader:
LocalStrings.properties WebappClassLoader.java
Posted by Mark Thomas <ma...@apache.org>.
Rainer Jung wrote:
> when I saw your commit, I asked myself "What's the original error
> message" because we shouldn't overwrite any other information that's
> helpful.
The error message (currently) isn't that helpful but your patch is good in
that it allows us to make use of the error message it it ever is useful.
I'll update my proposed patch.
Thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r640451 - in /tomcat/trunk/java/org/apache/catalina/loader:
LocalStrings.properties WebappClassLoader.java
Posted by Rainer Jung <ra...@kippdata.de>.
Hi Mark,
markt@apache.org schrieb:
> +++ tomcat/trunk/java/org/apache/catalina/loader/LocalStrings.properties Mon Mar 24 08:57:42 2008
> @@ -29,6 +29,7 @@
> standardLoader.starting=Starting this Loader
> standardLoader.stopping=Stopping this Loader
> webappClassLoader.stopped=Illegal access: this web application instance has been stopped already. Could not load {0}. The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
> +webappClassLoader.wrongVersion=Unable to load class {0} due to a bad version number in the .class file.
> webappLoader.addRepository=Adding repository {0}
> webappLoader.deploy=Deploying class repositories to work directory {0}
> webappLoader.jarDeploy=Deploy JAR {0} to {1}
> +++ tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Mon Mar 24 08:57:42 2008
> @@ -1842,9 +1842,14 @@
> }
>
> if (entry.loadedClass == null) {
> - clazz = defineClass(name, entry.binaryContent, 0,
> - entry.binaryContent.length,
> - new CodeSource(entry.codeBase, entry.certificates));
> + try {
> + clazz = defineClass(name, entry.binaryContent, 0,
> + entry.binaryContent.length,
> + new CodeSource(entry.codeBase, entry.certificates));
> + } catch (UnsupportedClassVersionError ucve) {
> + throw new UnsupportedClassVersionError(
> + sm.getString("webappClassLoader.wrongVersion", name));
> + }
> entry.loadedClass = clazz;
> entry.binaryContent = null;
> entry.source = null;
when I saw your commit, I asked myself "What's the original error
message" because we shouldn't overwrite any other information that's
helpful. So I looked it up and finally I end up proposing a modification
to your patch:
webappClassLoader.wrongVersion= (unable to load class {0})
...
throw new UnsupportedClassVersionError(
ucve.getMessage() +
sm.getString("webappClassLoader.wrongVersion", name));
That message enhancement pattern should be more stable, in case there's
anything helpful in the original message, like the version number.
We could even use ucve.getLocalizedMessage() instead of ucve.getMessage().
Regards,
Rainer
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org