-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: NoSuchMethodError: PersistentClass.setAbstract(Boolean)
PostPosted: Mon Jan 09, 2006 11:51 am 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
Hibernate version: 3.1 (final), Annotations 3.1 beta 7 (also tried beta 6, 5, and 4 -- and tried to compile from CVS but cannot compile)

Mapping documents:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

        <!-- Database connection settings -->
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.connection.url">jdbc:mysql:///ycomp</property>
        <property name="hibernate.connection.username">yyuser</property>

        <!-- JDBC connection pool (use the built-in) -->
        <property name="connection.pool_size">1</property>

        <!-- SQL dialect -->
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Disable the second-level cache  -->
        <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>
       
        <mapping class="org.aitools.ycomp.Project"/>
       
    </session-factory>


Code between sessionFactory.openSession() and session.close():
None, doesn't get that far -- I get the stack trace below just when I do this:

Code:
        SessionFactory sessionFactory;
       
        // Create the Hibernate SessionFactory right away.
        try
        {
            // Create the SessionFactory from hibernate.cfg.xml
            sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        }
        catch (Throwable ex)
        {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }


Full stack trace of any exception that occurs:
Code:
SEVERE: Exception sending context initialized event to listener instance of class org.aitools.webapp.listener.ServletContextListener
java.lang.ExceptionInInitializerError
   at org.aitools.webapp.listener.ServletContextListener.contextInitialized(ServletContextListener.java:26)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3692)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4127)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1012)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
   at org.apache.catalina.core.StandardService.start(StandardService.java:450)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:680)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:536)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:275)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setAbstract(Ljava/lang/Boolean;)V
   at org.hibernate.cfg.annotations.EntityBinder.bindEntity(EntityBinder.java:141)
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:475)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:266)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:199)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1145)
   at org.aitools.webapp.listener.ServletContextListener.contextInitialized(ServletContextListener.java:20)
   ... 15 more


Name and version of the database you are using: MySQL 4.1.16

The generated SQL (show_sql=true): Doesn't get this far.

Debug level Hibernate log excerpt:
Code:
Hibernate 3.1 rc3
hibernate.properties not found
using CGLIB reflection optimizer
using JDK 1.4 java.sql.Timestamp handling
configuring from resource: /hibernate.cfg.xml
Configuration resource: /hibernate.cfg.xml
trying to locate http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath under org/hibernate/
found http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd in classpath
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.password=password
hibernate.connection.url=jdbc:mysql:///ycomp
hibernate.connection.username=yyuser
connection.pool_size=1
hibernate.dialect=org.hibernate.dialect.MySQLDialect
current_session_context_class=thread
cache.provider_class=org.hibernate.cache.NoCacheProvider
show_sql=true
hbm2ddl.auto=create
null<-org.dom4j.tree.DefaultAttribute@105d88a [Attribute: name class value "org.aitools.ycomp.Project"]
Configured SessionFactory: null
properties: {show_sql=true, java.vendor=Sun Microsystems Inc., catalina.base=/home/noel/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0, hibernate.connection.url=jdbc:mysql:///ycomp, sun.management.compiler=HotSpot Client Compiler, catalina.useNaming=true, hbm2ddl.auto=create, os.name=Linux, sun.boot.class.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/rt.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i18n.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/jsse.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/jce.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/charsets.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/classes, hibernate.current_session_context_class=thread, sun.desktop=gnome, java.vm.specification.vendor=Sun Microsystems Inc., java.runtime.version=1.5.0_05-b05, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, user.name=noel, shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar, tomcat.util.buf.StringCache.byte.enabled=true, current_session_context_class=thread, user.language=en, java.naming.factory.initial=org.apache.naming.java.javaURLContextFactory, sun.boot.library.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386, java.version=1.5.0_05, user.timezone=America/New_York, sun.arch.data.model=32, java.endorsed.dirs=/usr/local/tomcat5/common/endorsed, sun.cpu.isalist=, sun.jnu.encoding=UTF-8, file.encoding.pkg=sun.io, package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans., file.separator=/, java.specification.name=Java Platform API Specification, hibernate.cglib.use_reflection_optimizer=true, java.class.version=49.0, user.country=US, java.home=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre, java.vm.info=mixed mode, sharing, os.version=2.6.14-1.1656_FC4, path.separator=:, java.vm.version=1.5.0_05-b05, hibernate.connection.password=password, java.awt.printerjob=sun.print.PSPrinterJob, sun.io.unicode.encoding=UnicodeLittle, hibernate.connection.username=bm, package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper., java.naming.factory.url.pkgs=org.apache.naming, user.home=/home/noel, java.specification.vendor=Sun Microsystems Inc., hibernate.hbm2ddl.auto=create, java.library.path=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386/client:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/i386:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/../lib/i386:/usr/lib/mozilla-1.7.12, java.vendor.url=http://java.sun.com/, hibernate.connection.driver_class=com.mysql.jdbc.Driver, java.vm.vendor=Sun Microsystems Inc., hibernate.dialect=org.hibernate.dialect.MySQLDialect, common.loader=${catalina.home}/common/classes,${catalina.home}/common/i18n/*.jar,${catalina.home}/common/endorsed/*.jar,${catalina.home}/common/lib/*.jar, java.runtime.name=Java(TM) 2 Runtime Environment, Standard Edition, java.class.path=/usr/local/tomcat5/bin/bootstrap.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/lib/tools.jar, java.vm.specification.name=Java Virtual Machine Specification, java.vm.specification.version=1.0, catalina.home=/usr/local/tomcat5, sun.cpu.endian=little, sun.os.patch.level=unknown, connection.pool_size=1, java.io.tmpdir=/tmp, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar, os.arch=i386, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.ext.dirs=/usr/lib/jvm/java-1.5.0-sun-1.5.0.05/jre/lib/ext, user.dir=/home/noel, line.separator=
, java.vm.name=Java HotSpot(TM) Client VM, cache.provider_class=org.hibernate.cache.NoCacheProvider, file.encoding=UTF-8, java.specification.version=1.5, hibernate.show_sql=true, hibernate.connection.pool_size=1}
Preparing to build session factory with filters : {}
Execute first pass mapping processing
Process hbm files
Process annotated classes
Binding entity from annotated class: java.lang.Class
Binding column TYPE unique false
Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setAbstract(Ljava/lang/Boolean;)V


Looks like the key lines are
Code:
null<-org.dom4j.tree.DefaultAttribute@105d88a [Attribute: name class value "org.aitools.ycomp.Project"]
Configured SessionFactory: null


But I don't know how to interpret them. At first, I tried having a "mapping" element in the hibernate.cfg.xml file for the "org.aitools.ycomp" package, but then I got a complaint about "Package not found or wo package-info.java". I couldn't figure out from the documentation whether I need to create some kind of config file for the package....


Top
 Profile  
 
 Post subject: found problem: AnnotationConfiguration.configure()
PostPosted: Mon Jan 09, 2006 8:41 pm 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
I guess I finally R'ed TFM, discovering this important note in the javadoc for AnnotationConfiguration:

Quote:
For now, only programmatic configuration is available.

Just as a suggestion, maybe it would be helpful, during the time that the configure() method isn't working, to throw an exception or somehow indicate that the method isn't going to work, rather than just silently failing (yes, the "Configured SessionFactory: null" message is sort of a clue, but not quite clear....)

Anyway, if I programmatically configure the AnnotationConfiguration, as in

Code:
            sessionFactory = new AnnotationConfiguration()
                                .setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
                                .setProperty("hibernate.connection.password", "password")
                                .setProperty("hibernate.connection.url", "jdbc:mysql:///ycomp")
                                .setProperty("hibernate.connection.username", "yyuser")
                                .setProperty("connection.pool_size", "1")
                                .setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect")
                                .setProperty("current_session_context_class", "thread")
                                .setProperty("cache.provider_class", "org.hibernate.cache.NoCacheProvider")
                                .setProperty("show_sql", "true")
                                .setProperty("hbm2ddl.auto", "create")
                                .buildSessionFactory();

...then things seem to start working.

I think it would be helpful to note this situation in the Annotations Reference.


Top
 Profile  
 
 Post subject: no, still not working
PostPosted: Tue Jan 10, 2006 10:10 am 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
I was premature in reporting success -- it seems that a problem with my IDE (Eclipse + WTP) was causing deleted files to be retained in the deployed application, so an hbm.xml file I had removed was still being read. When I removed this file (but retained the programmatic config of the AnnotationConfiguration), I again got the same exception.

I can't understand why my SessionFactory is failing to initialize. Can anyone point me in the right direction? This is with one class added to the AnnotationConfiguration, and all properties configured programmatically; same specs as above:

Code:
Hibernate 3.1 rc3
hibernate.properties not found
using CGLIB reflection optimizer
using JDK 1.4 java.sql.Timestamp handling
Preparing to build session factory with filters : {}
Execute first pass mapping processing
Process hbm files
Process annotated classes
Binding entity from annotated class: java.lang.Class
Binding column TYPE unique false
Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.setAbstract(Ljava/lang/Boolean;)V


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 10, 2006 10:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are using a incompatible hibernate core with the annotations.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: oh!
PostPosted: Tue Jan 10, 2006 10:49 am 
Newbie

Joined: Sat Jan 07, 2006 10:33 am
Posts: 18
Location: New York NY
max wrote:
you are using a incompatible hibernate core with the annotations.

Wow, you're right. Thanks. I feel like an idiot. It was staring me right in the face in those debug messages.

B-b-but, but I thought I -- ah, never mind....

OK, crawling back into my hole now.... :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.