添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Download
  • Getting Started
  • Members
  • Projects
  • Bugzilla – Bug 345808 java.net.URISyntaxException: Illegal character in opaque part at index 2 Last modified: 2022-06-09 10:26:00 EDT
    Build Identifier: EclipseLink v2.2.0.v20110202-r8913 bundled with Glassfish 3.1
    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] 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" />.
    I'm using EclipseLink version 2.2.0.v20110202-r8913 that comes bundled with Glassfish 3.1. I have also tried compiling the above ANT task with the standalone EclipseLink libraries version 2.2.0.v20110202-r8913 and got the same error.
    I'm using JDK 1.6.0.24. Development PC is Windows XP Service Pack 3.
    Reproducible: Always
    Steps to Reproduce:
    1. Download and extract EclipseLink v2.2.0.v20110202-r8913 (standalone or bundled version with Glassfish 3.1 server)
    2. Create an ANT javac task with the following parameters:
    <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" />
    3. Build project using ANT (v1.7 or later)
    You should get an error "java.net.URISyntaxException: Illegal character in opaque part at index 2" which can be attributed to this parameter:
    compilerarg value="-Aeclipselink.persistencexml=${web.dir}/META-INF" compiler="javac1.6" />
    For detail information, please see http://old.nabble.com/EclipseLink-2%3A-ANT-Task-Error-to31475388.html topic in EclipseLink forum.
    'any chance this is related to the direction of your slash characters?
    The following has slashes going in multiple directions:
    D:\Project\website/WebContent/META-INF
    I cannot recreate this problem based on your instructions, but do get an error when I use the wrong slash character.  I can imagine the wrong slash character combining with a letter in your path to form a special character and causing an exception like this.
    (In reply to comment #2)
    > 'any chance this is related to the direction of your slash characters?
    My relative path in the build.xml file is specified as "${web.dir}/META-INF" which get translated by ANT as "D:\Project\website/WebContent/META-INF" - I have no control over ANT's path translation or the slashes.
    I ran the following in the command prompt and it seemed fine:
    "C:\Program Files\Java\jdk1.6.0_25\bin\javac" -Aeclipselink.persistencexml=d:\Project\website\WebContent\META-INF\persistence.xml D:\Project\website\src\java\au\com\ckd\model\BookModel.java
    which led me to believe that there's a problem with EclipseLink itself.
    (In reply to comment #5)
    > What happens if you specifiy an explicit path instead of ${web.dir}
    Same error using explicit path. The only way I found it to "work" is moving the META-INF directory to the same level as the ANT's build.xml - which is restrictive - I mean, why can't one have the META-INF directory under WebContent directory?
    I'm baffled by this specific requirement from EclipseLink.
    ok... there's the key (and the reason we ask for packaged test cases)  The file has to be outside of the directory subtree the classes are in.
    The reason for this issue is a limitation in a JDK-provided class specific to the classes provided to use with annotation processing.
    The workaround, of course, is to put a copy of your file in the same directory subtree as you are working in.
    I am updating the code to expand the usecases where we work-around this issue with the JDK classes.  My recreation of the test case passes with this change.
    Reviewed by Guy Pelletier Tested manually using our jpa test build and the following target: <target name="compile-test-comp" depends="config-flat"> <javac srcdir="${eclipselink.jpa.test}/${src.dir}" destdir="${eclipselink.jpa.test}/${classes.dir}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" optimize="${javac.optimize}" source="${javac.version}" target="${javac.version}" deprecation="${javac.deprecation}" failonerror="true"> <compilerarg value="-Aeclipselink.persistencexml=c:/temp/persistence.xml" compiler="javac1.6" /> <compilerarg line=" -processor org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor" /> <compilerarg line=" -proc:only" compiler="javac1.6" /> <include name="org/eclipse/persistence/testing/models/jpa/extensibility/**"/> <classpath> <pathelement path="C:/EclipseLinkView1/eclipselink.jar"/> <path refid="compile.path"/> <pathelement path="C:/EclipseLinkView1/jpa/eclipselink.jpa.test/eclipselink-tests.jar"/> <pathelement path="C:/EclipseLinkView1/foundation/eclipselink.core.test/eclipselink-tests.jar"/> </classpath> </javac> </target>
    (In reply to comment #7)
    > ok... there's the key (and the reason we ask for packaged test cases)  The file
    > has to be outside of the directory subtree the classes are in.
    Sorry, Tom. I'll remember to include test case(s) next time. :)
    > The reason for this issue is a limitation in a JDK-provided class specific to
    > the classes provided to use with annotation processing.
    I guess the changes you have applied will remedy any future issue with the JDK-provided class. Does the JDK development team at Oracle need to know about this issue? I suppose if they rectify the issue at the JDK-level then there won't be a need to fix at the JPA-level - not just for EclipseLink - but for other JPA implementations as well.