AW: java.lang.ClassFormatError

From: Andreas Bobek (andreas.bobe..ni-rostock.de)
Date: Mon Apr 14 2008 - 10:10:55 EDT

  • Next message: Borut Bolčina: "Re: Replace Objects in a Database?"

    I really don't get it, here is how I can reproduce this error:

    Shop => Servlet
    _Basket => Superclass
    Basket => Subclass

    Basket has no additional declarations.

    Shop creates a new Basket (within doGet...):

    Basket basket = (Basket)
    DataContext.createDataContext().createAndRegisterNewObject(Basket.class);

    _Basket contains this additional method (please don't care of the sense of
    this code, it is here for demonstration only, this code is even never
    called):

            public String test() {
                    String name = ((DbAttribute)
    Configuration.getSharedConfiguration()
            
    .getDomain("na-domain").getMap("Basket").getObjEntity("Basket")
                            .getDbEntity().getPrimaryKey().get(0)).getName();
                    return (getObjectId().getIdSnapshot().get(name).toString());
            }

    Scenario 1: as described above => ClassFormatError (see below)

    Scenario 2: slightly modified the test method in _Basket:

            public String test() {
                    Configuration conf = Configuration.getSharedConfiguration();
                    String name = ((DbAttribute) conf
            
    .getDomain("na-domain").getMap("Basket").getObjEntity("Basket")
                            .getDbEntity().getPrimaryKey().get(0)).getName();
                    return (getObjectId().getIdSnapshot().get(name).toString());
            }

    => it works!

    Scenario 3: remove the creation of the new Basket object in Shop servlet =>
    it works independent of what is desclared in _Basket. I suppose this is
    because the class is never loaded.

    The stack trace:

    java.lang.ClassFormatError: Invalid this class index 2414 in constant pool
    in class file test/cayenne/_Basket
            java.lang.ClassLoader.defineClass1(Native Method)
            java.lang.ClassLoader.defineClass(Unknown Source)
            java.security.SecureClassLoader.defineClass(Unknown Source)
            
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLo
    ader.java:1629)
            
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.jav
    a:850)
            
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
    a:1299)
            
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
    a:1181)
            java.lang.ClassLoader.loadClassInternal(Unknown Source)
            java.lang.ClassLoader.defineClass1(Native Method)
            java.lang.ClassLoader.defineClass(Unknown Source)
            java.security.SecureClassLoader.defineClass(Unknown Source)
            
    org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLo
    ader.java:1629)
            
    org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.jav
    a:850)
            
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
    a:1299)
            
    org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav
    a:1181)
            java.lang.ClassLoader.loadClassInternal(Unknown Source)
            test.Shop.serveEmptyForm(Shop.java:75)
            test.Shop.doGet(Shop.java:47)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    I suppose it is a version issue.
    Tested on three machines, tomcat 5.5, jdk 1.5, cayenne 2.0.4

    Thanks, Andreas.



    This archive was generated by hypermail 2.0.0 : Mon Apr 14 2008 - 10:11:31 EDT