Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345808 - java.net.URISyntaxException: Illegal character in opaque part at index 2
Summary: java.net.URISyntaxException: Illegal character in opaque part at index 2
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 328560 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-05-14 08:31 EDT by Chuong Pham CLA
Modified: 2022-06-09 10:26 EDT (History)
4 users (show)

See Also:


Attachments
Fix - larger workaround to limitation in javax.annotation.processing.Filer (911 bytes, patch)
2011-05-26 09:30 EDT, Tom Ware CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chuong Pham CLA 2011-05-14 08:31:05 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.
Comment 1 Chuong Pham CLA 2011-05-14 08:33:14 EDT
I have been stuck on this bug for the last two weeks without a solution in sight. Any help from the EclipseLink team is much appreciated.
Comment 2 Tom Ware CLA 2011-05-20 11:04:11 EDT
'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.
Comment 3 Tom Ware CLA 2011-05-20 11:05:39 EDT
BTW: Using JDK 1.6 and Ant 1.7.1

Pasted your compiler args into a working javac command and changed only the path to the persistence.xml
Comment 4 Chuong Pham CLA 2011-05-22 06:10:05 EDT
(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.
Comment 5 Tom Ware CLA 2011-05-24 08:34:40 EDT
What happens if you specifiy an explicit path instead of ${web.dir}
Comment 6 Chuong Pham CLA 2011-05-26 05:08:08 EDT
(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.
Comment 7 Tom Ware CLA 2011-05-26 09:26:29 EDT
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.
Comment 8 Tom Ware CLA 2011-05-26 09:30:16 EDT
Created attachment 196661 [details]
Fix - larger workaround to limitation in javax.annotation.processing.Filer
Comment 9 Tom Ware CLA 2011-05-26 09:31:38 EDT
Checked in attached 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>
Comment 10 Chuong Pham CLA 2011-05-27 17:58:21 EDT
(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.
Comment 11 Tom Ware CLA 2011-05-30 09:18:43 EDT
The limitation is documented, so I suspect the team is aware.  I guess users of the API just need to work around the limitation.  In this case, we missed an exception that could be thrown when we hit the limitation, and therefore didn't trigger the workaround.
Comment 12 Guy Pelletier CLA 2013-06-18 10:26:46 EDT
*** Bug 328560 has been marked as a duplicate of this bug. ***
Comment 13 Eclipse Webmaster CLA 2022-06-09 10:26:00 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink