-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Tools Ant error- Could not instantiate dialect
PostPosted: Tue Aug 16, 2005 1:39 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
Trying to migrate from hibernate2 / middlegen to hibernate3.0.5 and hibernate tools (3.0.0.alpha4)

Build.xml contains:

Code:
   <target name="compile-hibernate"
         description="generate .hbm, hibernate.cfg.xml, and POJOs for hibernate">
      <taskdef
         name="hibernatetool"
           classname="org.hibernate.tool.ant.HibernateToolTask"
            classpathref="myclasspath" />
        <hibernatetool destdir="${src}">
            <classpath refid="myclasspath"/>
            <jdbcconfiguration
               propertyFile="j2ee/hibernate.properties"
               />
            <cfg2hbm/>
            <hbm2java/>
        </hibernatetool>
   </target>


j2ee/hibernate.properties contains:
Code:
hibernate.dialect org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.driver_class org.postgresql.Driver
hibernate.connection.url jdbc:postgresql:dbname
hibernate.connection.username user
hibernate.connection.password password
hibernate.query.substitutions yes 'Y', no 'N'


ant -verbose produces the following error:
    org.hibernate.HibernateException: Could not instantiate dialect class
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:84)
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
    at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:374)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:35)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:150)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:74)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    Caused by: java.lang.ClassCastException: org/hibernate/dialect/PostgreSQLDialect incompatible with org/hibernate/dialect/Dialect
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:78)
    at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
    at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:374)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:35)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:150)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:74)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

If I remove the <classpath> line from build.xml, then I get this error instead:
    org.hibernate.exception.GenericJDBCException: Reading from database
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:96)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:37)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:150)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:74)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    Caused by: org.postgresql.util.PSQLException: The column name FKTABLE_CAT not found.
    at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:673)
    at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:475)
    at org.hibernate.cfg.JDBCBinder.processForeignKeys(JDBCBinder.java:1024)
    at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:136)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:91)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:37)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:150)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:74)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:32)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:115)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)


I'm pretty sure the <classpath> tag is right; how do I solve teh "could not instantiate Dialect" error?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 1:47 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
More information: When I build hibernate-tools from CVS, and use the classpath, I get the following error:

    org.hibernate.exception.GenericJDBCException: Exception while reading foreign key meta data
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
    at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:152)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:65)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:688)
    at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:89)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    Caused by: org.postgresql.util.PSQLException: The column name FKTABLE_CAT not found.
    at org.postgresql.jdbc1.AbstractJdbc1ResultSet.findColumn(AbstractJdbc1ResultSet.java:673)
    at org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet.java:475)
    at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:93)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:65)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:688)
    at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:89)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 2:19 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
more info still: Changing JDBCReader.java around line 100 to read:
Code:

            String fkCatalog = exportedKeyRs.getString("FK_TABLE_CAT");
            String fkSchema = exportedKeyRs.getString("FKTABLE_SCHEMA");
            String fkTableName = exportedKeyRs.getString("FKTABLE_NAME");
            String fkColumnName = exportedKeyRs.getString("FKCOLUMN_NAME");
            String pkColumnName = exportedKeyRs.getString("PKCOLUMN_NAME");
            String fkName = exportedKeyRs.getString("FK_NAME");
            short keySeq = exportedKeyRs.getShort("KEY_SEQ");
            


Seems to partly fix the problem (note the column names are slightly different). I'm using postgresql 8.0.3.

Now I get this error:

    java.lang.NoSuchMethodError: org/hibernate/mapping/Table.createForeignKey(Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/List;)Lorg/hibernate/mapping/ForeignKey;
    at org.apache.tools.ant.Project.executeTarget(Project.java:1223)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    Caused by: java.lang.NoSuchMethodError: org/hibernate/mapping/Table.createForeignKey(Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/List;)Lorg/hibernate/mapping/ForeignKey; at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:229)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:66)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:695)
    at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:89)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
    --- Nested Exception ---
    java.lang.NoSuchMethodError: org/hibernate/mapping/Table.createForeignKey(Ljava/lang/String;Ljava/util/List;Ljava/lang/String;Ljava/util/List;)Lorg/hibernate/mapping/ForeignKey;
    at org.hibernate.cfg.reveng.JDBCReader.processForeignKeys(JDBCReader.java:229)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:66)
    at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:695)
    at org.hibernate.cfg.JDBCBinder.readDatabaseSchema(JDBCBinder.java:122)
    at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:89)
    at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:40)
    at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:71)
    at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:50)
    at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:158)
    at org.hibernate.tool.ant.GeneratorTask.configureExporter(GeneratorTask.java:73)
    at org.hibernate.tool.ant.GeneratorTask.execute(GeneratorTask.java:31)
    at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:122)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.Main.runBuild(Main.java:673)
    at org.apache.tools.ant.Main.startAnt(Main.java:188)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 2:37 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
Upgrading to hibernate-3.1 (from CVS) fixed the problem; now I have the org.apache.velocity.tools.generic.log.CommonsLogLogSystem problem (which I suppose there's an answer for somewhere else in teh forum).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 2:44 pm 
Newbie

Joined: Tue Aug 16, 2005 1:27 pm
Posts: 7
Adding velocity-tools-generic-1.1.jar and jtidy-r8-21122004.jar to the classpath makes it work (or at least, it now runs without throwing exceptions; I haven't inspected the output).
.

I had to change JDBCReader.java as described above; how do I report this as a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 3:13 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
seems like postgressql is not jdbc compliant.

From jdbc doc:

* <LI><B>FKTABLE_CAT</B> String => foreign key table catalog (may be <code>null</code>)
* being exported (may be <code>null</code>)


So, FK_TABLE_CAT is wrong and should probably be reported to postgres...

but searching for this I found: http://gborg.postgresql.org/pipermail/p ... 00061.html

which seem to indicate it is fixed in latest version.

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.