问题
I got this ANT task:
<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>
When I ran the above task, I got this error:
[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
I've traced the error to this line <compilerarg value="-Aeclipselink.persistencexml=${web.dir}/META-INF" compiler="javac1.6" />
. It looks like the parser does not like the compiler's argument value -Aeclipselink.persistencexml
. The above error is reproducible with both JDK 1.6.0.24 and JDK 1.6.0.25. The error is caused by org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process
.
I'm using EclipseLink version 2.2.0.v20110202-r8913 that comes bundled with Glassfish 3.1. I have also tried compile the above task with the standalone EclipseLink libraries version 2.2.0.v20110202-r8913 and got the same error.
Is there a workaround for the above error?
回答1:
To solve the error java.net.URISyntaxException: Illegal character in opaque part at index 2
, I had to move my META-INF to the same directory where ANT's build.xml reside. This is only a workaround.
I have logged a bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=345808. The EclipseLink folks have fixed this bug for EclipseLink version 2.3.0 release.
来源:https://stackoverflow.com/questions/5783991/eclipselink-2-ant-task-error