ant - "'hibernate.dialect' must be set when no Connection available " error despite having set the dialect -
i have tried run hibernatetool ant task i've been unsuccesfull.help. jars eclipse(3.7.2) hibernate tools plugin(3.4). org.hibernate.hibernateexception: 'hibernate.dialect' must set when no connection available despite having set dialect
here build.xml:
<project> <target name="genero"> <path id="toolslib"> <path location="mylibs/hibernate-tools.jar" /> <path location="mylibs/hibernate3.jar" /> <path location="mylibs/freemarker.jar" /> <path location="mylibs/postgresql-9.0-802.jdbc4.jar" /> <path location="mylibs/dom4j-1.6.1.jar" /> <path location="mylibs/commons-logging-1.0.4.jar" /> <path location="mylibs/slf4j-api-1.5.8.jar" /> <path location="mylibs/slf4j-log4j12-1.5.8.jar" /> <path location="mylibs/log4j-1.2.15.jar" /> <path location="mylibs/cglib-2.2.jar" /> <path location="mylibs/asm.jar" /> <path location="mylibs/commons-collections-3.1.jar" /> <path location="mylibs/slf4j-api-1.5.8.jar" /> </path> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.hibernatetooltask" classpathref="toolslib" /> <hibernatetool> <jdbcconfiguration propertyfile="src/hibernate.cfg.xml" packagename="demo" revengfile="src/hibernate.reveng.xml" /> <hbm2hbmxml destdir="${build.dir}/src" /> <hbm2java jdk5="true" destdir="${build.dir}/src" /> </hibernatetool> </target>
and hibernate.cfg.xml:
<?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> <property name="hibernate.dialect">org.hibernate.dialect.postgresqldialect</property> <property name="hibernate.connection.driver_class">org.postgresql.driver</property> <property name="hibernate.connection.password">blablabla</property> <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/projteste</property> <property name="hibernate.connection.username">postgres</property> </session-factory> </hibernate-configuration>
and stack trace:
apache ant(tm) version 1.8.2 compiled on december 20 2010 buildfile: c:\users\mrtykop\workspace2\testjavahib\build.xml parsing buildfile c:\users\mrtykop\workspace2\testjavahib\build.xml uri = file:/c:/users/mrtykop/workspace2/testjavahib/build.xml project base dir set to: c:\users\mrtykop\workspace2\testjavahib build sequence target(s) `genero' [genero] complete build sequence [genero, ] genero: parsing buildfile jar:file:/e:/jave/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml uri = jar:file:/e:/jave/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml zip file property "build.dir" has not been set property "build.dir" has not been set [hibernatetool] executing hibernate tool jdbc configuration (for reverse engineering) [hibernatetool] 1. task: hbm2hbmxml (generates set of hbm.xml files) [hibernatetool] log4j:warn no appenders found logger (org.hibernate.cfg.environment). [hibernatetool] log4j:warn please initialize log4j system properly. [hibernatetool] exception occurred while running exporter #2:hbm2hbmxml (generates set of hbm.xml files) [hibernatetool] full stack trace run ant -verbose [hibernatetool] org.hibernate.hibernateexception: 'hibernate.dialect' must set when no connection available build failed c:\users\mrtykop\workspace2\testjavahib\build.xml:26: org.hibernate.hibernateexception: 'hibernate.dialect' must set when no connection available @ org.hibernate.tool.ant.hibernatetooltask.reportexception(hibernatetooltask.java:226) @ org.hibernate.tool.ant.hibernatetooltask.execute(hibernatetooltask.java:189) @ org.apache.tools.ant.unknownelement.execute(unknownelement.java:291) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ org.apache.tools.ant.dispatch.dispatchutils.execute(dispatchutils.java:106) @ org.apache.tools.ant.task.perform(task.java:348) @ org.apache.tools.ant.target.execute(target.java:390) @ org.apache.tools.ant.target.performtasks(target.java:411) @ org.apache.tools.ant.project.executesortedtargets(project.java:1399) @ org.apache.tools.ant.project.executetarget(project.java:1368) @ org.apache.tools.ant.helper.defaultexecutor.executetargets(defaultexecutor.java:41) @ org.eclipse.ant.internal.launching.remote.eclipsedefaultexecutor.executetargets(eclipsedefaultexecutor.java:32) @ org.apache.tools.ant.project.executetargets(project.java:1251) @ org.eclipse.ant.internal.launching.remote.internalantrunner.run(internalantrunner.java:424) @ org.eclipse.ant.internal.launching.remote.internalantrunner.main(internalantrunner.java:138) caused by: org.hibernate.hibernateexception: 'hibernate.dialect' must set when no connection available @ org.hibernate.dialect.resolver.dialectfactory.builddialect(dialectfactory.java:107) @ org.hibernate.cfg.settingsfactory.buildsettings(settingsfactory.java:142) @ org.hibernate.cfg.configuration.buildsettingsinternal(configuration.java:2163) @ org.hibernate.cfg.configuration.buildsettings(configuration.java:2155) @ org.hibernate.cfg.jdbcmetadataconfiguration.readfromjdbc(jdbcmetadataconfiguration.java:41) @ org.hibernate.tool.ant.jdbcconfigurationtask.doconfiguration(jdbcconfigurationtask.java:83) @ org.hibernate.tool.ant.configurationtask.getconfiguration(configurationtask.java:55) @ org.hibernate.tool.ant.hibernatetooltask.getconfiguration(hibernatetooltask.java:302) @ org.hibernate.tool.ant.hibernatetooltask.getproperties(hibernatetooltask.java:318) @ org.hibernate.tool.ant.exportertask.configureexporter(exportertask.java:94) @ org.hibernate.tool.ant.exportertask.execute(exportertask.java:39) @ org.hibernate.tool.ant.hibernatetooltask.execute(hibernatetooltask.java:186) ... 16 more
this f-in incredible.a tiny error in reading documentation ruin whole day(s).
had replace propertyfile="src/hibernate.cfg.xml" propertyfile="hibernate.properties".
( specified can use hibernate.cfg file this: configurationfile="src/hibernate.cfg.xml") added jar. new build.xml
<project> <target name="genero"> <path id="toolslib"> <path location="mylibs/hibernate-tools.jar" /> <path location="mylibs/hibernate3.jar" /> <path location="mylibs/freemarker.jar" /> <path location="mylibs/postgresql-9.0-802.jdbc3.jar" /> <path location="mylibs/dom4j-1.6.1.jar" /> <path location="mylibs/commons-logging-1.0.4.jar" /> <path location="mylibs/slf4j-api-1.5.8.jar" /> <path location="mylibs/slf4j-log4j12-1.5.8.jar" /> <path location="mylibs/log4j-1.2.15.jar" /> <path location="mylibs/cglib-2.2.jar" /> <path location="mylibs/asm.jar" /> <path location="mylibs/commons-collections-3.1.jar" /> <path location="mylibs/jtidy-r8-20060801.jar"/> </path> <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.hibernatetooltask" classpathref="toolslib" /> <hibernatetool> <jdbcconfiguration configurationfile="src/hibernate.cfg.xml" revengfile="hibernate.reveng.xml" packagename="demo" /> <hbm2hbmxml destdir="src" /> <hbm2java jdk5="true" destdir="src" /> </hibernatetool> </target> </project>
the reveng.xml file edit hibernatetools plugin
funny how nobody noticed mistake( wonder how many looked @ it)
btw inspiration came post : dialect not getting set in hibernate
Comments
Post a Comment