You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2010/01/05 14:19:38 UTC

DO NOT REPLY [Bug 48489] New: Tomcat CL doesn't resolve the array classes.

https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

           Summary: Tomcat CL doesn't resolve the array classes.
           Product: Tomcat 6
           Version: 6.0.0
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: kakvicky@yahoo.co.in


Attached is the sample app whose index.jsp would explain the error, call this
jsp 
http://localhost:8080/sampleapp/index.jsp

The TomcatCL does not resolve the array class e.g 
loader.loadClass("[Lsample.SampleClass;")

And here is the fix 

Index: src/share/classes/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
--- src/share/classes/org/apache/catalina/loader/WebappClassLoader.java
(revision 1335)
+++ src/share/classes/org/apache/catalina/loader/WebappClassLoader.java
(working copy)
@@ -902,8 +902,22 @@
                throw new ClassNotFoundException(name);
            }
        } catch (ClassNotFoundException e) {
-            if (log.isTraceEnabled())
-                log.trace("    --> Passing on ClassNotFoundException");
+         if (log.isTraceEnabled())
+         log.trace("We need to check for array class "+name);
+            if( name.charAt(0) == '[' )
+            {
+               clazz = Class.forName(name, true, this);
+               if (log.isTraceEnabled())
+               log.debug("      Returning class " + clazz);
+               if ((log.isTraceEnabled()) && (clazz != null))
+                   log.debug("      Loaded by " + clazz.getClassLoader());
+               return clazz;
+            }
+            else
+            {
+            if (log.isTraceEnabled())
+                log.trace("    --> Passing on ClassNotFoundException");
+            }
            throw e;
        }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #1 from VickyKak <ka...@yahoo.co.in> 2010-01-05 05:21:45 UTC ---
Created an attachment (id=24795)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24795)
Proposed Fix.

I did try the patch here 
http://svn.apache.org/repos/asf/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #6 from VickyKak <ka...@yahoo.co.in> 2010-01-05 08:30:05 UTC ---
(In reply to comment #5)
> couldn't you just use
> 
> -Dsun.lang.ClassLoader.allowArraySyntax=true

I don't see it useful, here is the related bug
http://bugs.sun.com/view_bug.do?bug_id=6434149

The TomcatCL does not resolve the custom class array, this should be done via
system classloader call as 
>>+               clazz = Class.forName(name, true, this);

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #2 from VickyKak <ka...@yahoo.co.in> 2010-01-05 05:23:24 UTC ---
Created an attachment (id=24796)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24796)
sample test application.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #8 from Mark Thomas <ma...@apache.org> 2010-01-05 13:54:40 GMT ---
This is a 'feature' of the underlying JDK rather than a Tomcat bug. The
workarounds already described should be sufficient.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #3 from VickyKak <ka...@yahoo.co.in> 2010-01-05 05:29:48 UTC ---
Created an attachment (id=24797)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=24797)
Bug48489.patch

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #12 from VickyKak <ka...@yahoo.co.in> 2010-01-06 01:15:30 UTC ---
 Bug48489.patch is the required fix.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #4 from VickyKak <ka...@yahoo.co.in> 2010-01-05 05:30:26 UTC ---
 Bug48489.patch is the required fix.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID

--- Comment #11 from Mark Thomas <ma...@apache.org> 2010-01-05 23:44:34 GMT ---
Please use the users list if you need further assistance.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #7 from Kris Schneider <ks...@gmail.com> 2010-01-05 08:41:17 UTC ---
(In reply to comment #6)
> http://bugs.sun.com/view_bug.do?bug_id=6434149

That bug, as well as others, implies that your JSP code is wrong. Instead of
this:

loader.loadClass("[Lsample.SampleClass;")

you should do this:

Class.forName("[Lsample.SampleClass;", false, loader)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

VickyKak <ka...@yahoo.co.in> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #10 from Kris Schneider <ks...@gmail.com> 2010-01-05 20:06:43 UTC ---
(In reply to comment #9)
> Could you please explain in detail why don't you think it is an issue with the
> TomcatCL implementation?

I thought I did that in comment 7. Here's another Sun bug that should help to
illustrate that the problem is with your JSP code:

http://bugs.sun.com/view_bug.do?bug_id=6500212

Read the "Evaluation" section...

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

VickyKak <ka...@yahoo.co.in> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #13 from VickyKak <ka...@yahoo.co.in> 2010-01-06 01:18:25 UTC ---
(In reply to comment #12)
>  Bug48489.patch is the required fix.

Sorry...

If loader.loadClass("[Ljava.lang.String;") works fine then I would expect
loader.loadClass("[Lsample.SampleClass;") too a proper usage.

I don't think loader.loadClass("[Lsample.SampleClass;") is wrong usage, the
TocmatCL should resolve the custom class array also which could internally be
done by delegating to system CL.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

VickyKak <ka...@yahoo.co.in> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #9 from VickyKak <ka...@yahoo.co.in> 2010-01-05 19:50:39 UTC ---
(In reply to comment #8)
> This is a 'feature' of the underlying JDK rather than a Tomcat bug. The
> workarounds already described should be sufficient.

Could you please explain in detail why don't you think it is an issue with the
TomcatCL implementation?
What workaround you are referring to, enabling
-Dsun.lang.ClassLoader.allowArraySyntax=true does not help as I tried it even
though it does not make sense to me.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 48489] Tomcat CL doesn't resolve the array classes.

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48489

--- Comment #5 from Filip Hanik <fh...@apache.org> 2010-01-05 05:54:58 UTC ---
couldn't you just use

-Dsun.lang.ClassLoader.allowArraySyntax=true

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org