[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-178) JarVisitor.getVisitor does not treat correctly paths with spaces

Lars Francke (JIRA) noreply at atlassian.com
Tue Nov 20 08:39:59 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/EJB-178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_28896 ] 

Lars Francke commented on EJB-178:
----------------------------------

I am running into the same problem as Alexandrino and I have to say that it is very annoying during development as all my jars are coming from the Maven Repository directory (in the Documents and Settings directory) and I'm unable to start any of my projects this way.

> JarVisitor.getVisitor does not treat correctly paths with spaces
> ----------------------------------------------------------------
>
>                 Key: EJB-178
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-178
>             Project: Hibernate Entity Manager
>          Issue Type: Bug
>          Components: EntityManager
>    Affects Versions: 3.1.0.Beta8
>         Environment: Windows XP Professional; Tomcat 5.5.17.
>            Reporter: Alexandrino Lucas
>   Original Estimate: 15 minutes
>  Remaining Estimate: 15 minutes
>
> I'm using Hibernate Entity Manager with a WAR deployed on Tomcat 5.5.17, and I'm getting the following error:
> 11/05/2006 16:12:43 org.hibernate.ejb.packaging.FileZippedJarVisitor doProcessElements
> WARNING: Unable to find file (ignored): file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/[REST OMITTED]
> java.util.zip.ZipException: Access is denied
> 	at java.util.zip.ZipFile.open(Native Method)
> 	at java.util.zip.ZipFile.<init>(Unknown Source)
> 	at java.util.jar.JarFile.<init>(Unknown Source)
> 	at java.util.jar.JarFile.<init>(Unknown Source)
> 	at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34)
> 	at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208)
> 	at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:201)
> 	at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:183)
> 	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
> 	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
>   [MORE...]
> Two strange things: 1) the directory exists; 2) Hibernate is treating the path as being part of a JAR file. I found the cause of the problem when analysing org.hibernate.ejb.packaging.JarVisitor.getVisitor(URL, Filter[]):
>     File file = new File( jarUrl.getFile() );
>     if ( file.isDirectory() ) {
>         return new ExplodedJarVisitor( jarUrl, filters );
>     }
>     else {
>         return new FileZippedJarVisitor( jarUrl, filters );
>     }
> As my path has some spaces, jarUrl.getFile() returns "/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/[REST OMITTED]", which is not a directory, because of the "%20"'s. The specification of the java.net.URL class says: "The URL class does not itself encode or decode any URL components according to the escaping mechanism defined in RFC2396. It is the responsibility of the caller to encode any fields, which need to be escaped prior to calling URL, and also to decode any escaped fields, that are returned from URL."
> Although I did not have the time to build the project with it, I think that jarUrl.toURI().getPath() would solve the problem. Here is a snippet to prove it:
> import java.io.File;
> import java.net.URL;
> public class Main
> {
>     public static void main(
>         String[] args )
>         throws Exception
>     {
>         URL url = new URL(
>             "file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps" );
>         System.out.println( "url.getFile()" );
>         System.out.println( url.getFile() );
>         System.out.println( new File( url.getFile() ).isDirectory() );
>         System.out.println();
>         System.out.println();
>         System.out.println();
>         System.out.println( "url.toURI().getPath()" );
>         System.out.println( url.toURI().getPath() );
>         System.out.println( new File( url.toURI().getPath() ).isDirectory() );
>     }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list