论坛首页 Java版 Hibernate

关于ddl2hbm 等工具的配置问题请教:

浏览 2655 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
最后更新时间:2003-11-10
我的buil.xml
[code:1]

  HibernateTools ANT build script.


-->

<project name="HibernateTools" default="dist" basedir=".">

    <!-- Give user a chance to override without editing this file
       (and without typing -D each time it compiles it) -->
    <property file="build.properties"/>
    <property file="${user.home}/.ant.properties"/>

    <!-- Name of project and version, used to create filenames -->
    <property name="Name" value="Hibernate Tools"/>
    <property name="name" value="hibernate-tools"/>
    <property name="version" value="2.0.3"/>

    <!-- set global properties for this build -->
    <property name="src.dir" value="src/java"/>
    <property name="lib.dir" value="lib"/>
    <property name="build.dir" value="build"/>
    <property name="dist.dir" value="target/${name}-${version}"/>
    <property name="doc.dir" value="doc"/>
    <property name="doc.api.dir" value="${doc.dir}/api"/>

    <property name="dist.doc.dir"  value="${dist.dir}/doc"/>
    <property name="dist.api.dir"  value="${dist.dir}/doc/api"/>

    <property name="dist.src.dir" value="${dist.dir}/src"/>
    <property name="dist.lib.dir" value="${dist.dir}/lib"/>
    <property name="jar.name" value="${name}"/>

    <property name="javadoc" value="http://java.sun.com/j2se/1.3/docs/api"/>
    <property name="javac.debug" value="on"/>
    <property name="javac.optimize" value="off"/>

<!-- set Hibernate core related properties -->
<property name="hibernate-core.home" value="G:/hibernate203/hibernate-2.0.3"/>
    <property name="hibernate-core.jar" value="${hibernate-core.home}/hibernate2.jar"/>
<property name="hibernate-core.lib.dir" value="${hibernate-core.home}/lib"/>
<property name="hibernate-core.doc.api" value="${hibernate-core.home}/doc/api"/>

    <path id="lib.class.path">
    <path location="${hibernate-core.jar}"></path>
        <fileset dir="${hibernate-core.lib.dir}">
            <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
        </fileset>
    </path>

    <patternset id="support.files">
        <include name="**/*.dtd"/>
        <include name="**/*.xml"/>
        <include name="**/*.xslt"/>
       
        <!-- exclude everything we don't want in the jar -->
        <exclude name="${build.dir}/**/*"/>
        <exclude name="${doc.dir}/**/*"/>
        <exclude name="classes/**/*"/>
        <exclude name="build.xml"/>
        <exclude name="net/sf/hibernate/tool/hbm2java/test/*"/>
        <exclude name="**/*.properties"/>
        <exclude name="**/*.ccf"/>
        <exclude name="**/*.cfg.xml"/>
        <exclude name="META-INF/ra.xml"/>    
        <exclude name="net/sf/hibernate/test/**/*"/>  
    </patternset>

    <patternset id="source.files">
        <include name="**/*.java"/>
        <include name="**/*.properties"/>
        <include name="**/*.ccf"/>
        <exclude name="net/sf/hibernate/test/**/*"/>
    </patternset>

    <!-- Tasks -->

    <target name="clean" description="Cleans up build and dist directories">
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>

    <target name="init" description="Initialize the build">
        <tstamp>
            <format property="subversion" pattern="yyyy-MM-dd hh:mm:ss"/>
        </tstamp>
        <echo message="Build ${Name}-${version} (${subversion})"/>
        <mkdir dir="${build.dir}"/>
        <copy todir="${build.dir}">
            <fileset dir="${src.dir}">
                <patternset refid="support.files"/>
            </fileset>
            <fileset dir=".">
            <include name="readme.txt"/>
            <include name="lgpl.txt"/>
            </fileset>
        </copy>
    </target>

    <target name="compile" depends="init" description="Compile the Java source code">
        <available
            classname="org.eclipse.core.launcher.Main"
            property="build.compiler"
            value="org.eclipse.jdt.core.JDTCompilerAdapter"
            classpath="${java.class.path}"/>       
        <javac
            srcdir="${src.dir}"
            destdir="${build.dir}"
            classpathref="lib.class.path"
            debug="${javac.debug}"
            optimize="${javac.optimize}"
            excludes="net/sf/hibernate/test/**/*"
            nowarn="on">
        </javac>
    </target>
   
    <target name="copysource" description="Copy sources to dist dir">
        <mkdir dir="${dist.src.dir}"/>
        <copy todir="${dist.src.dir}">
            <fileset dir="${src.dir}">
                <patternset refid="source.files"/>
            </fileset>
            <fileset dir="${src.dir}">
                <patternset refid="support.files"/>
            </fileset>
        </copy>
    </target>

    <target name="copylib" description="Copy jars to lib dir">
        <mkdir dir="${dist.lib.dir}"/>
        <copy todir="${dist.lib.dir}">
            <fileset dir="${lib.dir}">
                <include name="*.jar"/>
                <exclude name="log4j.jar"/>
                <include name="*.txt"/>
            </fileset>
        </copy>
    </target>
   
    <target name="jar" depends="compile" description="Build the distribution .jar file">
        <mkdir dir="${dist.dir}"/>
        <jar jarfile="${dist.dir}/${jar.name}.jar" basedir="${build.dir}"/>
    </target>
   
    <target name="rar" depends="jar" description="Build a JCA distribution .rar file">
        <mkdir dir="jca"/>   
        <jar jarfile="jca/${jar.name}.rar" basedir="${dist.dir}">
      <fileset dir="${dist.dir}">
        <include name="${dist.dir}/${jar.name}.jar" />
      </fileset>
      <fileset dir="${src.dir}">
        <include name="META-INF/ra.xml" />
      </fileset>      
        </jar>
    </target>

    <!-- DOCUMENTATION -->

    <target name="javadoc" description="Compile the Javadoc API documentation to dist dir">
        <mkdir dir="${dist.api.dir}"/>
        <javadoc
       
        sourcepath="G:\hibernate203\hibernate-extensions-2.0.2\tools\src"
        packagenames="net.sf.hibernate.tool.hbm2java,net.sf.hibernate.tool.class2hbm,net.sf.hibernate.tool.ddl2hbm"
        classpathref="lib.class.path"
        destdir="${dist.api.dir}"
        use="true"
        protected="true"
        version="true"
        windowtitle="${Name} API Documentation"
        Overview="${doc.api.dir}/package.html"
        doctitle="${Name} API Documentation"
        stylesheetfile="${hibernate-core.doc.api}/jdstyle.css"
        link="${javadoc}">
       
        </javadoc>
        <!--sourcepath="${src.dir}"-->
       
    </target>

  
<target name="extras" description="Copies miscellaneous files to root dir">
<copy todir="${dist.dir}/bin">
<fileset dir="bin">
<include name="*.bat"/>
</fileset>
</copy>
<copy file="readme.txt" todir="${dist.dir}"/>
<copy file="lgpl.txt" todir="${dist.dir}"/>
<copy file="changelog.txt" todir="${dist.dir}"/>
<copy file="build.xml" todir="${dist.dir}"/>
<replace file="${dist.dir}/build.xml">
<replacetoken><![CDATA[../${name}]]></replacetoken>
<replacevalue><![CDATA[../${name}]]></replacevalue>
</replace>
</target>

<target name="dist" depends="jar,javadoc,copysource,copylib,extras" description="Build everything">
<zip zipfile = "${dist.dir}.zip">
<zipfileset prefix="${name}-${version}" dir="${dist.dir}"/>
</zip>
<tar compression="gzip" tarfile="${dist.dir}.tar.gz">
<tarfileset prefix="${name}-${version}" dir="${dist.dir}"/>
</tar>
</target>

    <target name="info" description="Echoes useful system properties">
        <echo message="java.vm.info=${java.vm.info}"/>
        <echo message="java.vm.name=${java.vm.name}"/>
        <echo message="java.vm.vendor=${java.vm.vendor}"/>
        <echo message="java.vm.version=${java.vm.version}"/>
        <echo message="os.arch=${os.arch}"/>
        <echo message="os.name=${os.name}"/>
        <echo message="os.version=${os.version}"/>
        <echo message="java.home = ${java.home}"/>
        <echo message="java.class.path = ${java.class.path}"/>
        <echo message="build.compiler = ${build.compiler}"/>
        <echo message="file.encoding=${file.encoding}"/>
        <echo message="user.home = ${user.home}"/>
        <echo message="user.language=${user.language}"/>
    </target>
   
    <target name="junit" depends="compile">
        <mkdir dir="test_output"/>
        <junit printsummary="yes" haltonfailure="yes">
            <classpath>
                <fileset dir="${lib.dir}">
                    <include name="**/*.jar"/>
                </fileset>
                <pathelement path="${build.dir}"/>
                <pathelement path="."/>
            </classpath>
            <formatter type="plain"/>
            <formatter type="xml"/>
            <batchtest fork="yes" todir="test_output" haltonfailure="no">
                <fileset dir="${build.dir}">
                    <include name="net/sf/hibernate/test/*Test.class"/>
                    <exclude name="net/sf/hibernate/test/*PerformanceTest.class"/>
                </fileset>
            </batchtest>
        </junit>
    </target>
   
    <target name="junitreport" depends="">
        <junitreport todir="./test_output">
            <fileset dir="test_output">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="./test_output"/>
        </junitreport>
    </target>

</project>
[/code:1]
我的 setenv.bat
[code:1]
@echo off

rem -------------------------------------------------------------------
rem Setup environment for hibernate tools
rem -------------------------------------------------------------------

set JDBC_DRIVER=C:\Progra~1\SQLLIB\java\db2java.zip;C:\mm.mysql-2.0.14\mm.mysql-2.0.14-bin.jar;D:\Program Files\JSQLConnect\JDBC_2.0_Driver\JSQLConnect.jar

set HIBERNATE_HOME=G:\hibernate203\hibernate-2.0.3

set CORELIB=%HIBERNATE_HOME%\lib
set LIB=G:\hibernate203\hibernate-2.0.3\lib
set PROPS=%HIBERNATE_HOME%\src
set CP=%JDBC_DRIVER%;%PROPS%;%HIBERNATE_HOME%\hibernate2.jar;%CORELIB%\commons-logging.jar;%CORELIB%\commons-collections.jar;%CORELIB%\commons-lang.jar;%CORELIB%\cglib.jar;%CORELIB%\dom4j.jar;%CORELIB%\odmg.jar;%CORELIB%\xml-apis.jar;%CORELIB%\xerces.jar;%CORELIB%\xalan.jar;%LIB%\jdom.jar;%LIB%\..\hibernate-tools.jar
[/code:1]
在dos下运行ddl2hbm时的错误是:
[code:1]
Exception inthread "main" java.lang.NoClassDefFounError:Files\JSQLConnect\JDBC_2/0_ Driver\JSQLConnect/jar
[/code:1]
谢谢各位
   
最后更新时间:2003-11-11
:(  问题是不是太简单,以致无人问答,发现几个帖子和我的问题相似,但办法对我不行,或解决方法不明确!我始终弹不出对话框........
         各位都来去匆匆啊!可否歇歇脚!聊来哦...
   
0 请登录后投票
最后更新时间:2003-11-29
我的是可以弹出对话框

[code:1]
D:\j2eebin\hibernate-extensions-2.0.2\tools\bin>ddl2hbm.bat
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at net.sf.hibernate.tool.ddl2hbm.JDBCUtil.<clinit>(JDBCUtil.java:31)
        at net.sf.hibernate.tool.ddl2hbm.Gui.cmdGetTablesActionPerformed(Gui.jav
a:590)
        at net.sf.hibernate.tool.ddl2hbm.Gui.access$100(Gui.java:32)
        at net.sf.hibernate.tool.ddl2hbm.Gui$3.actionPerformed(Gui.java:262)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
86)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1839)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:245)
        at java.awt.Component.processMouseEvent(Component.java:5100)
        at java.awt.Component.processEvent(Component.java:4897)
        at java.awt.Container.processEvent(Container.java:1569)
        at java.awt.Component.dispatchEventImpl(Component.java:3615)
        at java.awt.Container.dispatchEventImpl(Container.java:1627)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
        at java.awt.Container.dispatchEventImpl(Container.java:1613)
        at java.awt.Component.dispatchEvent(Component.java:3477)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:201)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:151)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
[/code:1]

请问这是怎么回事???
   
0 请登录后投票
最后更新时间:2005-11-08
是的 我也遇到类似的问题啦  到底如何解决啊
   
0 请登录后投票
论坛首页 Java版 Hibernate

跳转论坛:
JavaEye推荐