[
http://jira.jboss.com/jira/browse/JBCOMMON-29?page=comments#action_12369149 ]
klaasjan elzinga commented on JBCOMMON-29:
------------------------------------------
I downloaded the source and found the following: In FileProtocolArchiveBrowserFactory a
File object is created from an URL by doing a File f = new File(url.getPath());
If this is changed to File f = new File(url.getURI().getPath()) the url escaping is done.
The url delivered is the url of a jar file which can be anything on a file system. I used
the following pgm to investigate this:
// get URL from classpath...
ClassLoader loader = Main.class.getClassLoader();
Enumeration<URL> urls = loader.getSystemResources("");
URL theURL = null;
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
System.out.println("avail uri: " + url);
theURL = url;
}
if (theURL == null) {
System.out.println("the URL is null.");
return;
}
System.out.println("URL: " + theURL);
System.out.println("url.getPath(): " + theURL.getPath());
System.out.println("url.getFile(): " + theURL.getFile());
System.out.println("url.toURI().getPath(): " +
theURL.toURI().getPath());
File f = new File(theURL.getPath());
System.out.println("f(url.getPath()): " + f);
System.out.println("f(url.getPath()): " + f.getPath());
System.out.println("f(url.getPath()): " + f.getName());
System.out.println("f(url.getPath() exists): " + f.exists());
System.out.println("f(url.getPath() readble): " + f.canRead());
File f2 = new File(theURL.toURI().getPath());
System.out.println("f(url.touri().getPath(): " + f2);
System.out.println("f(url.touri().getPath(): " + f2.getPath());
System.out.println("f(url.touri().getPath()): " + f2.getName());
System.out.println("f(url.touri().getPath() exists): " + f2.exists());
System.out.println("f(url.tourigetPath() readble): " + f2.canRead());
This outputs (if run on directory c:/TIS FIIBLoadTool as java -cp test.jar;.
org.kje.Main):
avail uri: file:/C:/TIS%20FIIBLoadTool-3.0.2.SNAPSHOT/
URL: file:/C:/TIS%20FIIBLoadTool-3.0.2.SNAPSHOT/
url.getPath(): /C:/TIS%20FIIBLoadTool-3.0.2.SNAPSHOT/
url.getFile(): /C:/TIS%20FIIBLoadTool-3.0.2.SNAPSHOT/
url.toURI().getPath(): /C:/TIS FIIBLoadTool-3.0.2.SNAPSHOT/
f(url.getPath()): C:\TIS%20FIIBLoadTool-3.0.2.SNAPSHOT
f(url.getPath()): C:\TIS%20FIIBLoadTool-3.0.2.SNAPSHOT
f(url.getPath()): TIS%20FIIBLoadTool-3.0.2.SNAPSHOT
f(url.getPath() exists): false
f(url.getPath() readble): false
f(url.touri().getPath(): C:\TIS FIIBLoadTool-3.0.2.SNAPSHOT
f(url.touri().getPath(): C:\TIS FIIBLoadTool-3.0.2.SNAPSHOT
f(url.touri().getPath()): TIS FIIBLoadTool-3.0.2.SNAPSHOT
So the url.toURI.getPath() works as the url.getPath() does not.
Unable to read in jarfile if application installed to location with
spaces in directory name
--------------------------------------------------------------------------------------------
Key: JBCOMMON-29
URL:
http://jira.jboss.com/jira/browse/JBCOMMON-29
Project: JBoss Common
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: core
Affects Versions: 2.0.4.GA
Environment: windows XP sun-jre, happens also in core-2.2.0.GA
Reporter: klaasjan elzinga
Assigned To: Dimitris Andreadis
I get an exception if the application is installed to a directory containing a space. I I
rename the directory to a name without a space, the application runs perfectly.
Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error creating bean with name
'entityManagerFactory' defined in class path resource
[loadtool/applicationContext.xml]: Invocation of init method failed; nested exception is
java.lang.RuntimeException: error trying to scan <jar-file>:
file:/C:/TIS%20FIIBLoadTool-3.0.2.SN
APSHOT/TISFIIBLoadTool-3.0.2.SNAPSHOT-jar-with-dependencies.jar
Caused by: java.lang.RuntimeException: error trying to scan <jar-file>:
file:/C:/TIS%20FIIBLoadTool-3.0.2.SNAPSHOT/TISFIIBLoadTool-3.0.2.SNAPSHOT-jar-with-dependencies.jar
at
org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:635)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:350)
at
org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
at
org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:218)
at
org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:251)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1201)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1171)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
...
at loadtool.Main.main(Main.java:40)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException:
C:\TIS%20FIIBLoadTool-3.0.2.SNAPSHOT\TISFIIBLoadTool-3.0.2.SNAPSHOT-jar-with-dependencies.jar
(The system cannot find th
e path specified)
at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:74)
at
org.jboss.util.file.FileProtocolArchiveBrowserFactory.create(FileProtocolArchiveBrowserFactory.java:48)
at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:57)
at
org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:626)
... 29 more
Caused by: java.io.FileNotFoundException:
C:\TIS%20FIIBLoadTool-3.0.2.SNAPSHOT\TISFIIBLoadTool-3.0.2.SNAPSHOT-jar-with-dependencies.jar
(The system cannot find the path specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:114)
at java.util.jar.JarFile.<init>(JarFile.java:133)
at java.util.jar.JarFile.<init>(JarFile.java:97)
at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:69)
... 32 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira