首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我尝试在我的build.xml中运行hibernate工具时,为什么我收到错误消息"Only antlib URI can be be located from the URI,not the URI

当我尝试在我的build.xml中运行hibernate工具时,为什么我收到错误消息"Only antlib URI can be be located from the URI,not the URI
EN

Stack Overflow用户
提问于 2009-04-15 17:30:10
回答 1查看 3.6K关注 0票数 3

我正在尝试在ant构建中运行hibernate工具,以便从我的JPA注释生成ddl。Ant会死在taskdef标签上。我已经尝试了ant 1.7、1.6.5和1.6,但都没有用。我在eclipse里和外面都试过了。我已经尝试在hibernate-tools路径中包含所有的hbn jars。请注意,我的构建文件基于这篇文章:

Hibernate JPA to DDL command line tools

我在ubuntu8上运行eclipse3.4和WTP 3.0.1和MyEclipse 7.1。

Build.xml:

代码语言:javascript
复制
<project name="generateddl" default="generate-ddl">

<path id="hibernate-tools">
    <pathelement location="../libraries/hibernate-tools/hibernate-tools.jar" />
    <pathelement location="../libraries/hibernate-tools/bsh-2.0b1.jar" />
    <pathelement location="../libraries/hibernate-tools/freemarker.jar" />
    <pathelement location="../libraries/jtds/jtds-1.2.2.jar" />
    <pathelement location="../libraries/hibernate-tools/jtidy-r8-20060801.jar" />

</path>

<taskdef classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="hibernate-tools"/>

<target name="generate-ddl" description="Export schema to DDL file"> 
<!-- compile model classes before running hibernatetool -->

    <!-- task definition; project.class.path contains all necessary libs 
    <taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask" classpathref="project.class.path" />
    -->

    <hibernatetool destdir="sql"> 

        <!-- check that directory exists -->
        <jpaconfiguration persistenceunit="default" />

        <classpath>

            <dirset dir="WebRoot/WEB-INF/classes">
                <include name="**/*"/>
            </dirset>
        </classpath>

        <hbm2ddl outputfilename="schemaexport.sql" format="true" export="false" drop="true" />
    </hibernatetool>
</target>

代码语言:javascript
复制
Error message (ant -v):

    Apache Ant version 1.7.0 compiled on December 13 2006
Buildfile: /home/joe/workspace/bento/ant-generate-ddl.xml
parsing buildfile /home/joe/workspace/bento/ant-generate-ddl.xml with URI = file:/home/joe/workspace/bento/ant-generate-ddl.xml
Project base dir set to: /home/joe/workspace/bento
[antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found.

BUILD FAILED
/home/joe/workspace/bento/ant-generate-ddl.xml:12: Only antlib URIs can be located from the URI alone,not the URI 
    at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:216)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:357)
    at org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:140)
    at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.parseBuildFile(InternalAntRunner.java:191)
    at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:400)
    at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)

Total time: 195 milliseconds
EN

回答 1

Stack Overflow用户

发布于 2009-04-16 07:03:45

根据typedef task documentation ( taskdef task是其中的一种形式),如果您没有指定“文件或资源类型属性”,则name属性是必需的。

我不确定修复它是否会解决你的问题,但如果你能把它从潜在的原因中消除掉,那就太好了。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/752851

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档