2011-04-25 62 views
0

我得到這個Ant任務:的EclipseLink 2:ANT任務錯誤

<javac verbose="on" 
    srcdir="${src.dir}" 
    destdir="${build.dir}/${context.path}/classes" 
    debug="${compile.debug}" 
    debuglevel="${javac.debuglevel}" 
    optimize="${compile.optimize}" 
    deprecation="${javac.deprecation}" 
    failonerror="true"> 
    <compilerarg value="-Aeclipselink.persistencexml=${web.dir}/META-INF" compiler="javac1.6" /> 
    <compilerarg line=" -processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor" /> 
    <compilerarg line=" -proc:only" compiler="javac1.6" /> 
    <classpath refid="compile.classpath"/> 
</javac> 

當我運行上面的任務,我得到這個錯誤:

[javac] error: java.lang.IllegalArgumentException 
[javac] An annotation processor threw an uncaught exception. 
[javac] Consult the following stack trace for details. 
[javac] java.lang.RuntimeException: java.lang.IllegalArgumentException 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:407) 
[javac]  at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:625) 
[javac]  at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:554) 
[javac]  at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:699) 
[javac]  at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981) 
[javac]  at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) 
[javac]  at com.sun.tools.javac.main.Main.compile(Main.java:353) 
[javac]  at com.sun.tools.javac.main.Main.compile(Main.java:279) 
[javac]  at com.sun.tools.javac.main.Main.compile(Main.java:270) 
[javac]  at com.sun.tools.javac.Main.compile(Main.java:69) 
[javac]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
[javac]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
[javac]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
[javac]  at java.lang.reflect.Method.invoke(Method.java:597) 
[javac]  at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56) 
[javac]  at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1065) 
[javac]  at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882) 
[javac]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) 
[javac]  at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) 
[javac]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
[javac]  at java.lang.reflect.Method.invoke(Method.java:597) 
[javac]  at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) 
[javac]  at org.apache.tools.ant.Task.perform(Task.java:348) 
[javac]  at org.apache.tools.ant.Target.execute(Target.java:357) 
[javac]  at org.apache.tools.ant.Target.performTasks(Target.java:385) 
[javac]  at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337) 
[javac]  at org.apache.tools.ant.Project.executeTarget(Project.java:1306) 
[javac]  at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 
[javac]  at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32) 
[javac]  at org.apache.tools.ant.Project.executeTargets(Project.java:1189) 
[javac]  at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423) 
[javac]  at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137) 
[javac] Caused by: java.lang.IllegalArgumentException 
[javac]  at java.net.URI.create(URI.java:842) 
[javac]  at com.sun.tools.javac.util.DefaultFileManager.getFileForOutput(DefaultFileManager.java:1029) 
[javac]  at com.sun.tools.javac.processing.JavacFiler.getResource(JavacFiler.java:434) 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.getFileObject(PersistenceUnitReader.java:93) 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.getInputStream(PersistenceUnitReader.java:104) 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.initPersistenceUnits(PersistenceUnitReader.java:169) 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.<init>(PersistenceUnitReader.java:71) 
[javac]  at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:376) 
[javac]  ... 31 more 
[javac] Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 2: D:\Project\website/WebContent/META-INF 
[javac]  at java.net.URI$Parser.fail(URI.java:2809) 
[javac]  at java.net.URI$Parser.checkChars(URI.java:2982) 
[javac]  at java.net.URI$Parser.parse(URI.java:3019) 
[javac]  at java.net.URI.<init>(URI.java:578) 
[javac]  at java.net.URI.create(URI.java:840) 
[javac]  ... 38 more 

我跟蹤誤差這一行<compilerarg value="-Aeclipselink.persistencexml=${web.dir}/META-INF" compiler="javac1.6" />。它看起來像解析器不喜歡編譯器的參數值-Aeclipselink.persistencexml。上述錯誤對於JDK 1.6.0.24和JDK 1.6.0.25都是可重現的。該錯誤是由org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process造成的。

我使用的是與Glassfish 3.1捆綁在一起的EclipseLink版本2.2.0.v20110202-r8913。我也嘗試使用獨立的EclipseLink庫2.2.0.v20110202-r8913編譯上述任務,並得到相同的錯誤。

是否有解決上述錯誤的方法?

+0

嘗試在web.dir中使用正斜槓嗎? – Ethan 2011-04-26 00:35:59

+0

@Ehan:我已經試過了 - 同樣的錯誤。 :) – ChuongPham 2011-04-26 03:18:14

+0

請顯示'$ {web.dir}'的定義! – Tim 2011-04-27 07:07:51

回答

0

要解決錯誤java.net.URISyntaxException: Illegal character in opaque part at index 2,我不得不將我的META-INF移動到ANT的build.xml所在的同一個目錄中。這只是一個解決方法。

我已經在https://bugs.eclipse.org/bugs/show_bug.cgi?id=345808註冊了一個bug。 EclipseLink人員修復了EclipseLink 2.3.0版本的這個錯誤。