在使用Ant建表和初始化数据库时出现一个问题org.dom4j.DocumentException: www.hibernate.org Nested exception: www.hiberna
build.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2009 AsiaSoft. All rights reserved.
Creation date: 2009-06-12
Author: Alex Zhang
-->
<project name="ecrmYM" default="all" basedir="." xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- ===================== Global Property Definitions =========================== -->
<property file="ivy.properties" />
<property file="build.properties" />
<property environment="env"/>
<property name="jdk.home" value="${env.JAVA_HOME}" />
<property name="tomcat.home" value="${env.TOMCAT_HOME}" />
<property name="src.home" value="${basedir}/${src.home}" />
<property name="lib.home" value="${basedir}/${lib.home}" />
<property name="res.home" value="${basedir}/${res.home}" />
<property name="web.home" value="${basedir}/${web.home}" />
<property name="docs.home" value="${basedir}/${docs.home}" />
<property name="build.home" value="${basedir}/${build.home}" />
<property name="dist.home" value="${basedir}/${dist.home}" />
<property name="test.home" value="${basedir}/${test.home}" />
<property name="src.java.dir" value="${src.home}/java" />
<property name="res.conf.dir" value="${res.home}/conf" />
<property name="res.i18n.dir" value="${res.home}/i18n" />
<property name="res.sql.dir" value="${res.home}/sql" />
<property name="res.make.dir" value="${res.home}/make" />
<property name="build.classes.dir" value="${build.home}/classes" />
<property name="build.lib.dir" value="${build.home}/lib" />
<property name="build.sql.dir" value="${build.home}/sql" />
<property name="build.docs.dir" value="${build.home}/docs" />
<property name="docs.style.dir" value="${docs.home}/style" />
<property name="test.java.dir" value="${test.home}/java" />
<property name="test.classes.dir" value="${test.home}/classes" />
<property name="test.output.dir" value="${test.home}/output" />
<property name="test.reports.dir" value="${test.home}/reports" />
<!-- ==================== Compilation Control Options ====================
These properties control option settings on the Javac compiler when it
is invoked using the <javac> task.
compile.debug Should compilation include the debug option?
compile.deprecation Should compilation include the deprecation option?
compile.optimize Should compilation include the optimize option?
compile.encoding Define the encoding which the compilation should use.
-->
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="true"/>
<property name="compile.optimize" value="true"/>
<property name="compile.encoding" value="UTF-8"/>
<!-- ===================== Compilation Classpath =========================== -->
<path id="classpath">
<pathelement location="${jdk.home}/lib/dt.jar"/>
<pathelement location="${jdk.home}/lib/tools.jar"/>
<fileset dir="${tomcat.home}">
<include name="lib/**/*.jar"/>
</fileset>
<fileset dir="${lib.home}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${build.classes.dir}"/>
<pathelement location="${res.conf.dir}"/>
<pathelement location="${res.home}"/>
<pathelement location="${res.conf.dir}/jbpm"/>
</path>
<!-- ===================== Build Targets below here =========================== -->
<target name="export-dbschema">
<echo message="Generating the appropriate SQL DDL... Store the result in a file or export it directly to the database." />
<echo message="${build.home}" />
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask">
<classpath refid="classpath" />
</taskdef>
<taskdef name="annotationconfiguration" classname="org.hibernate.tool.ant.AnnotationConfigurationTask">
<classpath refid="classpath" />
</taskdef>
<delete dir="${build.sql.dir}" />
<delete dir="${build.docs.dir}/dbschema" />
<mkdir dir="${build.sql.dir}" />
<mkdir dir="${build.docs.dir}/dbschema" />
<hibernatetool destdir="${build.sql.dir}">
<classpath refid="classpath" />
<annotationconfiguration configurationfile="${basedir}/res/conf/hibernate/hibernate.cfg.xml" />
<hbm2ddl
export="true"
update="false"
drop="true"
create="true"
delimiter=";"
outputfilename="db_table_schema.sql"
format="true"
haltοnerrοr="false">
</hbm2ddl>
<hbm2doc destdir="${build.docs.dir}/dbschema" />
</hibernatetool>
</target>
<!-- For MySQL -->
<target name="initialize-database" depends="export-dbschema">
<echo message="Initializing database... If error occurs,let it be." />
<sql
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/ecrm_ym"
userid="root"
password="root"
src="${res.sql.dir}/database_init.sql"
encoding="UTF-8"
οnerrοr="continue">
<classpath refid="classpath"/>
</sql>
</target>
<target name="initialize-database-datadictionary" depends="export-dbschema">
<echo message="Initializing Data Dictionary" />
<sql
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/ecrm_ym"
userid="root"
password="root"
src="${res.sql.dir}/database_data_dictionary_init.sql"
encoding="UTF-8"
οnerrοr="continue">
<classpath refid="classpath"/>
</sql>
</target>
<target name="all" depends="initialize-database,initialize-database-datadictionary" description="execute the all targets"/>
</project>
hibernate.cfg.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings ** MySQL -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/ecrm_ym</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="hbm2ddl.auto">create</property>
<!-- Database connection settings ** Oracle <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
<property name="connection.username">ecrm</property> <property name="connection.password">ecrm</property> -->
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
<!--<property name="dialect">org.hibernate.dialect.OracleDialect</property> -->
<!-- <mapping package="ym.ecrm.core.domain"/> -->
<mapping class="ym.ecrm.core.domain.systemManagement.User" />
<mapping class="ym.ecrm.core.domain.systemManagement.Role" />
<mapping class="ym.ecrm.core.domain.systemManagement.Resource" />
<mapping class="ym.ecrm.core.domain.systemManagement.Organization" />
<mapping class="ym.ecrm.core.domain.systemManagement.EMailTemplate" />
<mapping class="ym.ecrm.core.domain.systemManagement.DataDictionary" />
<mapping class="ym.ecrm.core.domain.serviceManagement.Feedback" />
<mapping class="ym.ecrm.core.domain.serviceManagement.QA" />
<mapping class="ym.ecrm.core.domain.salesManagement.Contract" />
<mapping class="ym.ecrm.core.domain.salesManagement.Opportunity" />
<mapping class="ym.ecrm.core.domain.salesManagement.OpportunityTrack" />
<mapping class="ym.ecrm.core.domain.productManagement.Production" />
<mapping class="ym.ecrm.core.domain.orderManagement.SaleOrder" />
<mapping class="ym.ecrm.core.domain.orderManagement.SaleOrderDetail" />
<mapping class="ym.ecrm.core.domain.marketPlanManagement.MarketActivity" />
<mapping class="ym.ecrm.core.domain.marketPlanManagement.MarketPlan" />
<mapping class="ym.ecrm.core.domain.marketManagement.IndustryPolicy" />
<mapping class="ym.ecrm.core.domain.marketManagement.DynamicMsn" />
<mapping class="ym.ecrm.core.domain.marketManagement.MarketingIntelligence" />
<mapping class="ym.ecrm.core.domain.marketManagement.MarketResearch" />
<mapping class="ym.ecrm.core.domain.marketManagement.SaleClues" />
<mapping class="ym.ecrm.core.domain.customerManagement.Contacter" />
<mapping class="ym.ecrm.core.domain.customerManagement.Customer" />
<mapping class="ym.ecrm.core.domain.customerManagement.Pcustomer" />
<mapping class="ym.ecrm.core.domain.financialManagement.AccountsPayable" />
<mapping class="ym.ecrm.core.domain.financialManagement.AccountsReceivable" />
<mapping class="ym.ecrm.core.domain.financialManagement.CollectionBill" />
<mapping class="ym.ecrm.core.domain.financialManagement.Collections" />
<mapping class="ym.ecrm.core.domain.financialManagement.Expense" />
<mapping class="ym.ecrm.core.domain.financialManagement.Payments" />
<mapping class="ym.ecrm.core.domain.financialManagement.PaymentVoucher" />
</session-factory>
</hibernate-configuration>
后来我把 <hbm2doc destdir="${build.docs.dir}/dbschema" />注释了<!-- <hbm2doc destdir="${build.docs.dir}/dbschema" />-->就可以运行了。
然后我再把<hbm2doc destdir="${build.docs.dir}/dbschema" />这句还原,看看是不是这个语句的问题,可是这次尽然没有报
org.dom4j.DocumentException: www.hibernate.org Nested exception: www.hiberna
这个错误,不解啊,是Eclipse工具的问题吗?还是其它问题,求高手指点。