You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Leonard Bouchet <le...@lajoiedelire.ch> on 2000/09/20 01:08:28 UTC

classformaterror

Hi,

I have a classFormatError exception using tomcat and jdk 1.2.2 with this
code:
// source code
    public ResultSet action() {
        Statement stmt = null;
        try {
            stmt = dbConnect.createStatement();
            if(stmt.execute("Select asdf from Reservations")) {
                return stmt.getResultSet();
            }      
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            try {
                if (stmt != null)
                    stmt.close();
                } catch (SQLException e) {
                    e.printStackTrace();
            }
        }
        return null;
    }
// end source code

but if I comment out the 'return stmt.getResultSet();' line, it works fine!

can anyone help me on this?

thanks a lot

-leo

here is the exception code:
java.lang.ClassFormatError: leo001/DBMS (Illegal Variable name "<return>")
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java, Compiled Code)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:392)
    at 
org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.j
ava, Compiled Code)
    at java.lang.ClassLoader.loadClass(ClassLoader.java, Compiled Code)
    at leo001.Facade.<init>(Facade.java:34)
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Class.java, Compiled Code)
    at java.beans.Beans.instantiate(Beans.java:211)
    at java.beans.Beans.instantiate(Beans.java:55)
    at 
_0002findex_0002ejspindex_jsp_47._jspService(_0002findex_0002ejspindex_jsp_4
7.java:66)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at 
org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
va:174)
    at 
org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
    at org.apache.jasper.runtime.JspServlet.service(JspServlet.java,
Compiled Code)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at 
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
    at 
org.apache.tomcat.core.RequestDispatcherImpl.forward(RequestDispatcherImpl.j
ava:163)
    at 
org.apache.tomcat.servlets.DefaultServlet.doGet(DefaultServlet.java:187)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at 
org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java,
Compiled Code)
    at 
org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
    at 
org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection
(Ajp12ConnectionHandler.java:156)
    at 
org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338
)
    at java.lang.Thread.run(Thread.java:479)


Re: classformaterror

Posted by Sandor Spruit <as...@acm.org>.
Leonard,

On Wednesday, September 20, 2000, 1:08:28 AM, you wrote:

Leonard> Hi,

Leonard> I have a classFormatError exception using tomcat and jdk
Leonard> 1.2.2 with this code:

[snip]

Leonard> but if I comment out the 'return stmt.getResultSet();' line,
Leonard> it works fine!

Leonard> can anyone help me on this?

I don't think it has anything to do with the ResultSet thing. I'm
doing something completely different and get the same sort of errors.

ClassFormatExceptions occur as a result of a Class's bytecode getting
corrupted, e.g. because the file is damaged on your disk. They are not
supposed to happen "just like that".

I recently posted a message describing a similar problem, observed
while I was gradually but frequently improving on my code. I now think
it's Tomcat's ClassLoader that's the problem. Or, to be more specific,
Java's class loading mechanism that does not allow re-definition of a
class. You cannot just dispose of a class in a running VM and load a
new definition. You can, however, rely on the VM's garbage collector
cleaning up a class when it is no longer used. Which is exactly what
Tomcat's AdaptiveClassLoader does, as the comments in the sourcecode
mention. So, my guess is that, when your VM's garbage collector does
not clean up a class fast enough, you get ClassFormatExceptions when
you try to load a new definition from disk. What VM are you using ?

Regards,
Sandor
-- 
ir A.G.L. Spruit, Utrecht University, the Netherlands
Institute of information and computing sciences
"There is a bit of magic in everything, and then some
loss to even things out" (from: Lou Reed, "Magic and Loss")