-->
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.  [ 8 posts ] 
Author Message
 Post subject: Help with SchemaExport: Cannot find Dialect Class
PostPosted: Mon Aug 01, 2005 5:27 pm 
Newbie

Joined: Mon Aug 01, 2005 5:14 pm
Posts: 4
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


Top
 Profile  
 
 Post subject: That might be another class unavailable
PostPosted: Mon Aug 01, 2005 6:15 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I looked at sources
Code:
try {
         return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
      }
      catch ( ClassNotFoundException cnfe ) {
         throw new HibernateException( "Dialect class not found: " + dialectName );
      }

I think that Dialect class (looks right) cannot find some another class. I suspect something related to logging because Dialect needs
mport org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

which in turn might need log4j


I would suggest patching Hibernate code to print the exact message from exception and changing words to something like this:
Problems loading dialect [TheName] ...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 7:04 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
If you want to see the stack trace, pass -debug to Ant.

Also, it looks like you are not using the new Hibernate 3 Ant task. Check out http://www.hibernate.org/hib_docs/tools/ant/index.html.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 7:06 pm 
Newbie

Joined: Mon Aug 01, 2005 5:14 pm
Posts: 4
Great thanks, I will check out the new Hibernate 3 Ant task.


Top
 Profile  
 
 Post subject: Hibernate 3 task?
PostPosted: Mon Aug 01, 2005 7:57 pm 
Newbie

Joined: Mon Aug 01, 2005 5:14 pm
Posts: 4
Hmm I am a bit confused as to the difference between the Hibernate3 and the Hibernate2 SchemaExport task. In my build.xml (see above) I have hibernate3.jar in my classpath, so doesn't that mean I am using the Hibernate 3 task?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 01, 2005 10:09 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
[schemaexport] - hibernate.properties not found


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 4:15 am 
Newbie

Joined: Mon Aug 01, 2005 7:33 am
Posts: 18
Location: UK
Looks to me like it is just a case of the hibernate.properties file not being found in the root of your output classpath (i.e. bin or classes...) - it seems just that it is not being read correctly at runtime - I think the dialect whinge is a side effect?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 02, 2005 11:32 am 
Newbie

Joined: Mon Aug 01, 2005 5:14 pm
Posts: 4
That's the weird thing. It SAYS it doesn't find hibernate.properties, but it clearly does since that is where I set the hibernate.dialect property, and when I change it, the error message reflects the change.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.