The problem I am getting is that Hibernate cannot find the Oracle9Dialect when running SchemaExport. I placed the Hibernate3.jar file (which contains org.hibernate.dialect.Oracle9Dialect) in the lib/ directory. I think I've set the paths correctly within Ant, so I'm lost as to why I am still getting this error.
My build.xml looks like this:
Code:
<?xml version="1.0" ?>
<!DOCTYPE project [
<!ENTITY properties SYSTEM "lib\axis-1_2RC3\xmls\properties.xml">
<!ENTITY paths SYSTEM "lib\axis-1_2RC3\xmls\path_refs.xml">
<!ENTITY taskdefs SYSTEM "lib\axis-1_2RC3\xmls\taskdefs.xml">
<!ENTITY taskdefs_post_compile SYSTEM "lib\axis-1_2RC3\xmls\taskdefs_post_compile.xml">
<!ENTITY targets SYSTEM "lib\axis-1_2RC3\xmls\targets.xml">
]>
<project name="EMPIRAD" default="jar">
<property file="build.properties"/>
&properties;
&paths;
&taskdefs;
&taskdefs_post_compile;
&targets;
<patternset id="java.libs" includes="**/*.jar,**/*.zip" />
<path id="mylibs" >
<fileset dir="${lib.dir}">
<patternset refid="java.libs" />
</fileset>
</path>
<path id="hibernate.schemaexport.classpath">
<path>
<pathelement location="${lib.dir}/hibernate3.jar"/>
<fileset dir="${lib.dir}" >
<include name="**/*.jar" />
</fileset >
<pathelement path="${build.dir}" />
</path>
</path>
<target name="init" description="Create the build, dist and gen directories">
<mkdir dir="${dist.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${gen.dir}" />
</target>
<target name="gen" description="WSDL the NOAA to generate classes" depends="init">
<echo message="Running WSDL2Java Emitters"/>
<wsdl2java url="${wsdl.dir}\ndfdXML.wsdl"
output="${gen.dir}"
deployscope="session"
serverSide="yes"
skeletonDeploy="yes"
noimports="no"
verbose="no">
<mapping namespace="urn:NoaaIrad" package="lockheed.empirad"/>
</wsdl2java>
</target>
<target name="compile" description="compile the source code" depends="init, gen">
<!-- Compile the generated code -->
<echo message="Compiling generated code"/>
<javac srcdir="${gen.dir}" destdir="${build.dir}" debug="${debug}">
<classpath>
<pathelement location="${build.lib}/${name}.jar"/>
<pathelement location="${build.lib}/${jaxrpc}.jar"/>
<pathelement location="${build.lib}/${saaj}.jar"/>
<path refid="classpath"/>
</classpath>
</javac>
<!-- Compile our source code -->
<echo message="Compiling our code"/>
<javac srcdir="${src.dir}" destdir="${build.dir}" debug="${debug}" classpathref="mylibs">
<include name="**/*.java" />
</javac>
<!-- Compile our test code -->
<echo message="Compiling test code"/>
<javac srcdir="${test.dir}" destdir="${build.dir}" debug="${debug}" classpathref="mylibs">
<include name="**/*.java" />
</javac>
<!-- copy all properties files into build -->
<!-- PN from locale properties -->
<copy todir="${build.dir}">
<fileset dir="${src.dir}" >
<include name="**/*.xml" />
<include name="**/*.properties" />
</fileset>
</copy>
<copy todir="${build.dir}">
<fileset dir="${bin.dir}" >
<include name="**/*.xml" />
</fileset>
</copy>
</target>
<target name="jar" depends="init, gen, compile" description="Make jar file from build">
<!-- Make jar file from ${build.dir} into ${dist.dir} -->
<jar jarfile="${dist.dir}/${proj.name}-${proj.version}.jar"
basedir="${build.dir}" />
</target>
<target name="schemaexport" depends="compile" description="Export the hibernate classes into a sql schema">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="hibernate.schemaexport.classpath"/>
<schemaexport
properties="${proj.home}/hibernate.properties"
config="${bin.dir}/hibernate.cfg.xml"
output="scripts/schema-export.sql"
quiet="no"
text="no"
drop="no"
delimiter=";">
</schemaexport>
</target>
</project>
My hibernate.properties looks like this (it is in the root directory):
Code:
hibernate.connection.driver_class = oracle.jdbc.driver.OracleDriver
hibernate.connection.url = jdbc:oracle:thin:@ boo@boo.com:boo
hibernate.connection.username = boo
hibernate.connection.password = boo
hibernate.dialect = org.hibernate.dialect.Oracle9Dialect
My hibernate.cfg.xml file looks like this (it is in the bin/ directory):
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">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<mapping resource="com/lockheed/empirad/server/hibernate/Accessimpactelementtype.hbm.xml"></mapping>
<mapping resource="com/lockheed/empirad/server/hibernate/Ewaforecastsite.hbm.xml"></mapping><mapping resource="com/lockheed/empirad/server/hibernate/Nonoperationalwindow.hbm.xml" />
<mapping resource="com/lockheed/empirad/server/hibernate/Prediction.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Sensor.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Site.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Siteaccessimpactelement.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Siteaieactualsnapshot.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Siteaiepredictionsnapshot.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Sitenonoperationalwindow.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Sitesnapshot.hbm.xml" /><mapping resource="com/lockheed/empirad/server/hibernate/Snapshot.hbm.xml" />
</session-factory>
</hibernate-configuration>
Hibernate version: 3.0
Mapping documents:
Full stack trace of any exception that occurs:
schemaexport:
[schemaexport] - Hibernate 3.0.5
[schemaexport] - hibernate.properties not found
[schemaexport] - using CGLIB reflection optimizer
[schemaexport] - using JDK 1.4 java.sql.Timestamp handling
[schemaexport] - configuring from file: hibernate.cfg.xml
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Accessimpactelementtype.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Accessimpactelementtype -> ACCESSIMPACTELEMENTTYPE
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Ewaforecastsite.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Ewaforecastsite -> EWAFORECASTSITE
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Nonoperationalwindow.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Nonoperationalwindow -> NONOPERATIONALWINDOW
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Prediction.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Prediction -> PREDICTION
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Sensor.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Sensor -> SENSOR
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Site.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Site -> SITE
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Siteaccessimpactelement.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Siteaccessimpactelement -> SITEACCESSIMPACTELEMENT
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Siteaieactualsnapshot.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Siteaieactualsnapshot -> SITEAIEACTUALSNAPSHOT
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Siteaiepredictionsnapshot.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Siteaiepredictionsnapshot -> SITEAIEPREDICTIONSNAPSHOT
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Sitenonoperationalwindow.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Sitenonoperationalwindow -> SITENONOPERATIONALWINDOW
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Sitesnapshot.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Sitesnapshot -> SITESNAPSHOT
[schemaexport] - Mapping resource: com/lockheed/empirad/server/hibernate/Snapshot.hbm.xml
[schemaexport] - Mapping class: com.lockheed.empirad.server.hibernate.C_Snapshot -> SNAPSHOT
[schemaexport] - Configured SessionFactory: null
BUILD FAILED
[
b]D:\data\shenjm\workspace\EmpIrad2\build.xml:112: Schema text failed: Dialect class not found: org.hibernate.dialect.Oracle9Dialect[/b]
Total time: 30 seconds
Name and version of the database you are using: Oracle 10g