[weld-issues] [JBoss JIRA] (WELD-1040) Support Java Web Start

Alexandre Gattiker (Updated) (JIRA) jira-events at lists.jboss.org
Mon Jan 9 05:59:09 EST 2012


     [ https://issues.jboss.org/browse/WELD-1040?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexandre Gattiker updated WELD-1040:
-------------------------------------

    Description: 
ClassLoader.getResources("META-INF/beans.xml") returns remote server URLs in the format "http://..."

Weld's FileSystemURLHandler tries to open these URLs as files, which leads to:

java.lang.RuntimeException: Error handling file http:/localhost:8080/weld-webstart-war-0.0.1-SNAPSHOT/webstart/weld-webstart-jar.jar
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:80)
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handle(FileSystemURLHandler.java:58)
	at org.jboss.weld.environment.se.discovery.url.URLScanner.scan(URLScanner.java:102)
	at org.jboss.weld.environment.se.discovery.url.WeldSEUrlDeployment.<init>(WeldSEUrlDeployment.java:39)
	at org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:130)
	at org.jboss.weld.environment.se.Weld.initialize(Weld.java:80)
	at com.example.TestApp.main(TestApp.java:12)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.javaws.Launcher.executeApplication(Launcher.java:1914)
	at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
	at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
	at com.sun.javaws.Launcher.run(Launcher.java:138)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:127)
	at java.util.zip.ZipFile.<init>(ZipFile.java:143)
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:71)
	... 15 more


I am attaching a demo project that also contains a proposed fix, using com.sun.jnlp.JNLPClassLoader#getJarFile(URL) to retrieve the location of the locally cached copy of the JAR. As this is an internal class it is accessed by reflection. The getJarFile method only exists in JRE 6, not in JRE 5.

Add to org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler:

	if (urlPath.startsWith("http:") || urlPath.startsWith("https:")) {

		ClassLoader cl;

		if (Thread.currentThread().getContextClassLoader() != null) {

			cl = Thread.currentThread().getContextClassLoader();

		} else {

			cl = getClass().getClassLoader();

		}

		Method m = cl.getClass().getMethod("getJarFile", URL.class);

		JarFile jarFile = (JarFile) m.invoke(cl, new URL(urlPath));

		urlPath = jarFile.getName();
	}


  was:
ClassLoader.getResources("META-INF/beans.xml") returns remote server URLs in the format "http://..."

Weld's FileSystemURLHandler tries to open these URLs as files, which leads to:

java.lang.RuntimeException: Error handling file http:/localhost:8080/weld-webstart-war-0.0.1-SNAPSHOT/webstart/weld-webstart-jar.jar
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:80)
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handle(FileSystemURLHandler.java:58)
	at org.jboss.weld.environment.se.discovery.url.URLScanner.scan(URLScanner.java:102)
	at org.jboss.weld.environment.se.discovery.url.WeldSEUrlDeployment.<init>(WeldSEUrlDeployment.java:39)
	at org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:130)
	at org.jboss.weld.environment.se.Weld.initialize(Weld.java:80)
	at com.example.TestApp.main(TestApp.java:12)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.javaws.Launcher.executeApplication(Launcher.java:1914)
	at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
	at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
	at com.sun.javaws.Launcher.run(Launcher.java:138)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.util.zip.ZipException: error in opening zip file
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:127)
	at java.util.zip.ZipFile.<init>(ZipFile.java:143)
	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:71)
	... 15 more


I am attaching a demo project that also contains a proposed fix, using com.sun.jnlp.JNLPClassLoader#getJarFile(URL) to retrieve the location of the locally cached copy of the JAR. As this is an internal class it is accessed by reflection. The getJarFile method only exists in JRE 6, not in JRE 5.

Add to org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler:

 if (urlPath.startsWith("http:") || urlPath.startsWith("https:")) {
  ClassLoader cl;
  if (Thread.currentThread().getContextClassLoader() != null) {
	cl = Thread.currentThread().getContextClassLoader();
  } else {
	cl = getClass().getClassLoader();
  }
  // see http://javasourcecode.org/html/open-source/jdk/jdk-6u23/com/sun/jnlp/JNLPClassLoader.java.html
  // public JarFile getJarFile(URL url) throws IOException {
  Method m = cl.getClass().getMethod("getJarFile", URL.class);
  // returns a reference to the local cached copy of the JAR
  JarFile jarFile = (JarFile) m.invoke(cl, new URL(urlPath));
  urlPath = jarFile.getName();
 }


    
> Support Java Web Start
> ----------------------
>
>                 Key: WELD-1040
>                 URL: https://issues.jboss.org/browse/WELD-1040
>             Project: Weld
>          Issue Type: Bug
>          Components: Java SE Support
>    Affects Versions: 1.1.4.Final, 1.1.5.Final
>            Reporter: Alexandre Gattiker
>         Attachments: weld-webstart-bug.zip
>
>
> ClassLoader.getResources("META-INF/beans.xml") returns remote server URLs in the format "http://..."
> Weld's FileSystemURLHandler tries to open these URLs as files, which leads to:
> java.lang.RuntimeException: Error handling file http:/localhost:8080/weld-webstart-war-0.0.1-SNAPSHOT/webstart/weld-webstart-jar.jar
> 	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:80)
> 	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handle(FileSystemURLHandler.java:58)
> 	at org.jboss.weld.environment.se.discovery.url.URLScanner.scan(URLScanner.java:102)
> 	at org.jboss.weld.environment.se.discovery.url.WeldSEUrlDeployment.<init>(WeldSEUrlDeployment.java:39)
> 	at org.jboss.weld.environment.se.Weld.createDeployment(Weld.java:130)
> 	at org.jboss.weld.environment.se.Weld.initialize(Weld.java:80)
> 	at com.example.TestApp.main(TestApp.java:12)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:597)
> 	at com.sun.javaws.Launcher.executeApplication(Launcher.java:1914)
> 	at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
> 	at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
> 	at com.sun.javaws.Launcher.run(Launcher.java:138)
> 	at java.lang.Thread.run(Thread.java:680)
> Caused by: java.util.zip.ZipException: error in opening zip file
> 	at java.util.zip.ZipFile.open(Native Method)
> 	at java.util.zip.ZipFile.<init>(ZipFile.java:127)
> 	at java.util.zip.ZipFile.<init>(ZipFile.java:143)
> 	at org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler.handleArchiveByFile(FileSystemURLHandler.java:71)
> 	... 15 more
> I am attaching a demo project that also contains a proposed fix, using com.sun.jnlp.JNLPClassLoader#getJarFile(URL) to retrieve the location of the locally cached copy of the JAR. As this is an internal class it is accessed by reflection. The getJarFile method only exists in JRE 6, not in JRE 5.
> Add to org.jboss.weld.environment.se.discovery.url.FileSystemURLHandler:
> 	if (urlPath.startsWith("http:") || urlPath.startsWith("https:")) {
> 		ClassLoader cl;
> 		if (Thread.currentThread().getContextClassLoader() != null) {
> 			cl = Thread.currentThread().getContextClassLoader();
> 		} else {
> 			cl = getClass().getClassLoader();
> 		}
> 		Method m = cl.getClass().getMethod("getJarFile", URL.class);
> 		JarFile jarFile = (JarFile) m.invoke(cl, new URL(urlPath));
> 		urlPath = jarFile.getName();
> 	}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the weld-issues mailing list