Почему при попытке запустить инструменты hibernate в моем build.xml может появиться ошибка «Только из URI antlib можно найти только по URI, но не по URI» - PullRequest
3 голосов
/ 15 апреля 2009

Я пытаюсь запустить инструменты hibernate в сборке муравья, чтобы генерировать ddl из моих аннотаций JPA. Муравей умирает от тега taskdef. Я пробовал с муравьями 1.7, 1.6.5 и 1.6 безрезультатно. Я пробовал как в затмении, так и снаружи. Я попытался включить все баночки hbn в путь hibernate-tools и нет. Обратите внимание, что я основал свой файл сборки на этом посте:

Средства командной строки из JPA в DDL

Я использую Eclipse 3.4 с WTP 3.0.1 и MyEclipse 7.1 в Ubuntu 8.

build.xml:

<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>

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

1 Ответ

4 голосов
/ 16 апреля 2009

В соответствии с документацией задачи typedef (из которых taskdef задача является формой) атрибут name необходим, если вы не указали " атрибуты типа файла или ресурса ".

Я не уверен, что исправление этой проблемы решит вашу проблему, но было бы хорошо, если бы вы могли устранить это как потенциальную причину.

...