Details

    • Steps to Reproduce:
      Hide

      unzip weld-webstart-bug.zip
      cd weld-webstart-bug
      rm weld-webstart-jar/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java #contains fix
      mvn clean install
      cp weld-webstart-war/target/weld-webstart-war-0.0.1-SNAPSHOT.war $JBOSS_HOME/standalone/deployments/
      javaws http://localhost:8080/weld-webstart-war-0.0.1-SNAPSHOT/webstart/weld-webstart.jnlp

      Show
      unzip weld-webstart-bug.zip cd weld-webstart-bug rm weld-webstart-jar/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java #contains fix mvn clean install cp weld-webstart-war/target/weld-webstart-war-0.0.1-SNAPSHOT.war $JBOSS_HOME/standalone/deployments/ javaws http://localhost:8080/weld-webstart-war-0.0.1-SNAPSHOT/webstart/weld-webstart.jnlp

      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();
      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                mbriskar Matej Briskar
                Reporter:
                agattik Alexandre Gattiker
              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: