title: "'hibernate.dialect' must be set when no Connection available " error despite having set the dialect
body: <p>I have tried to run a hibernatetool Ant task but i've been unsuccesfull.Help. The jars are from my eclipse(3.7.2) hibernate tools plugin(3.4).  I get a org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available  despite having set the dialect</p>
  
  <p>Here is my build.xml:  </p>
  
  <pre><code>&lt;project&gt;
  &lt;target name="genero"&gt;
      &lt;path id="toolslib"&gt;
          &lt;path location="mylibs/hibernate-tools.jar" /&gt;
          &lt;path location="mylibs/hibernate3.jar" /&gt;
          &lt;path location="mylibs/freemarker.jar" /&gt;
          &lt;path location="mylibs/postgresql-9.0-802.jdbc4.jar" /&gt;
          &lt;path location="mylibs/dom4j-1.6.1.jar" /&gt;
          &lt;path location="mylibs/commons-logging-1.0.4.jar" /&gt;
          &lt;path location="mylibs/slf4j-api-1.5.8.jar" /&gt;
          &lt;path location="mylibs/slf4j-log4j12-1.5.8.jar" /&gt;
          &lt;path location="mylibs/log4j-1.2.15.jar" /&gt;
          &lt;path location="mylibs/cglib-2.2.jar" /&gt;
          &lt;path location="mylibs/asm.jar" /&gt;
          &lt;path location="mylibs/commons-collections-3.1.jar" /&gt;
  
          &lt;path location="mylibs/slf4j-api-1.5.8.jar" /&gt;          
  
  
  
  
      &lt;/path&gt;
  
      &lt;taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="toolslib" /&gt;
  
      &lt;hibernatetool&gt;
          &lt;jdbcconfiguration propertyfile="src/hibernate.cfg.xml" packagename="demo" revengfile="src/hibernate.reveng.xml" /&gt;
  
          &lt;hbm2hbmxml destdir="${build.dir}/src" /&gt;
          &lt;hbm2java jdk5="true" destdir="${build.dir}/src" /&gt;
  
      &lt;/hibernatetool&gt;
  &lt;/target&gt;
  </code></pre>
  
  <p></p>
  
  <p>And my hibernate.cfg.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
      &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.PostgreSQLDialect&lt;/property&gt;
          &lt;property name="hibernate.connection.driver_class"&gt;org.postgresql.Driver&lt;/property&gt;
          &lt;property name="hibernate.connection.password"&gt;blablabla&lt;/property&gt;
          &lt;property name="hibernate.connection.url"&gt;jdbc:postgresql://localhost:5432/projteste&lt;/property&gt;
          &lt;property name="hibernate.connection.username"&gt;postgres&lt;/property&gt;
  
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>And the stack trace:</p>
  
  <pre><code>  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 with URI = file:/C:/Users/mrtykop/workspace2/testjavahib/build.xml
  Project base dir set to: C:\Users\mrtykop\workspace2\testjavahib
  Build sequence for target(s) `genero' is [genero]
  Complete build sequence is [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 with URI = jar:file:/E:/jave/eclipse/plugins/org.apache.ant_1.8.2.v20120109-1030/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
  Property "build.dir" has not been set
  Property "build.dir" has not been set
  [hibernatetool] Executing Hibernate Tool with a JDBC Configuration (for reverse engineering)
  [hibernatetool] 1. task: hbm2hbmxml (Generates a set of hbm.xml files)
  [hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
  [hibernatetool] log4j:WARN Please initialize the log4j system properly.
  [hibernatetool] An exception occurred while running exporter #2:hbm2hbmxml (Generates a set of hbm.xml files)
  [hibernatetool] To get the full stack trace run ant with -verbose
  [hibernatetool] org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
  
  BUILD FAILED
  C:\Users\mrtykop\workspace2\testjavahib\build.xml:26: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
      at org.hibernate.tool.ant.HibernateToolTask.reportException(HibernateToolTask.java:226)
      at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:189)
      at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
      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:597)
      at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
      at org.apache.tools.ant.Task.perform(Task.java:348)
      at org.apache.tools.ant.Target.execute(Target.java:390)
      at org.apache.tools.ant.Target.performTasks(Target.java:411)
      at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
      at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
      at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
      at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
      at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
      at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
      at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)
  Caused by: org.hibernate.HibernateException: 'hibernate.dialect' must be set when no Connection available
      at org.hibernate.dialect.resolver.DialectFactory.buildDialect(DialectFactory.java:107)
      at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:142)
      at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2163)
      at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2155)
      at org.hibernate.cfg.JDBCMetaDataConfiguration.readFromJDBC(JDBCMetaDataConfiguration.java:41)
      at org.hibernate.tool.ant.JDBCConfigurationTask.doConfiguration(JDBCConfigurationTask.java:83)
      at org.hibernate.tool.ant.ConfigurationTask.getConfiguration(ConfigurationTask.java:55)
      at org.hibernate.tool.ant.HibernateToolTask.getConfiguration(HibernateToolTask.java:302)
      at org.hibernate.tool.ant.HibernateToolTask.getProperties(HibernateToolTask.java:318)
      at org.hibernate.tool.ant.ExporterTask.configureExporter(ExporterTask.java:94)
      at org.hibernate.tool.ant.ExporterTask.execute(ExporterTask.java:39)
      at org.hibernate.tool.ant.HibernateToolTask.execute(HibernateToolTask.java:186)
      ... 16 more
  </code></pre>