Hi Tom,
I filed
https://glassfish.dev.java.net/issues/show_bug.cgi?id=713 per
your suggestion.
I am attaching some code that shows JarInputStream seems to be covering
all our cases.
You can unzip it into a directory of your choice and run:
/'java -classpath .:testdata/a.ear pkg.URLTest'/
enter b.jar to see how it behaves when a jar url that points to file
b.jar embedded in a.ear.
enter testdata/b.jar to see how it behaves when a file url that points
to file b.jar located in a directory.
enter testdata/b_jar to see how it behaves when a file url that points
to directory where contents of b.jar have been exploded.
Thanks,
Sahoo
Tom Ware wrote:
> Hi Sahoo,
>
> I think this merits further investigation. Does JarInputStream even
> cover all our cases? We have found that in some deployments on
> non-compliant servers the URL we get converts to neither a File nor a
> JarInputStream and we have to do some guessing when we look for
> orm.xml. I have not had a chance to assess whether there is a chance
> that in a compliant server (one where unlisted classes should be
> included) that we will get a URL that corresponds neither to a
> Directory nor a Jar file.
>
> It is probably worth entering a bug so this can be investigated.
>
> -Tom
>
> Sanjeeb Kumar Sahoo wrote:
>
>> Hi Tom,
>>
>> The javadocs of PersistenceUnitInfo#getPersistenceUnitRootUrl()
>> http://java.sun.com/javaee/5/docs/api/javax/persistence/spi/PersistenceUnitInfo.html#getPersistenceUnitRootUrl()
>> allows a container to return a URL that does not use file protocol. I
>> think we don't correctly process such URL in our code. Currently, the
>> code
>> https://glassfish.dev.java.net/source/browse/glassfish/entity-persistence/src/java/oracle/toplink/essentials/ejb/cmp3/persistence/PersistenceUnitProcessor.java?rev=1.15&only_with_tag=HEAD&view=auto&content-type=text/vnd.viewcvs-markup
>> in
>> oracle.toplink.essentials.ejb.cmp3.persistence.PersistenceUnitProcessor#getClassNamesFromURL
>> passes the URI returned by URL#toURI() to create a File object. Will
>> it work when the URL is not a file: URL?
>> I think, in such a case, we should use URL#openStream() to create a
>> JarInputStream and read from there. What do you think?
>>
>> Thanks,
>> Sahoo
>>
>>
>