Load multiple jars with Web Start

Discussion in 'Java' started by shahsachin@gmail.com, Jun 9, 2005.

  1. Guest

    I have an application which I want to start through Java Web Start. Now
    I also have some other plugin jars which are eventually loaded and used
    by the main application. When I run the application stand-alone, it
    works fine and also loads all the plugin jars flawlessly.

    Now comes most annoying part.... I try the same through web start... I
    signed all the jars and on the server the directory structure looks
    like following...

    htdocs/
    mainapp.jar
    mainapp.jnlp
    jars/
    plugin1.jar
    plugin2.jar
    plugin3.jar

    after clicking the jnlp link, the main app loads up fine, but when i
    try to bring up any of the plugins, I get the following exception
    (which works fine if I run the stand alone):

    java.util.zip.ZipException: The system cannot find the path specified
    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 mynamespace.PluginUIHelper.getPluginUIClass(PluginUIHelper.java:64)

    The code snippet from PluginUIHelper.java looks like this:

    ......
    62 if (serviceImpl.toLowerCase().endsWith(".jar")) {
    63 try {
    64 jarFile = new JarFile(serviceImpl);
    65 } catch (IOException e) {
    66 e.printStackTrace();
    67 return null;
    68 }
    69
    70 Manifest manifest = null;
    71
    72 try {
    73 manifest = jarFile.getManifest();
    74 } catch (IOException e) {
    75 e.printStackTrace();
    76 return null;
    77 }
    .......

    So can anyone tell me what might be going wrong here? I had a similar
    issue with the resource files, but it is solved by using
    getClass().getClassLoader().getResource()

    I am not sure if there is a similar way for solving dependent jar files
    too. I will appreciate your help.

    Thank you
    Sachin
     
    , Jun 9, 2005
    #1
    1. Advertising

  2. Aidan Guest

    I doubt it will find it since it's probably looking somewhere on the
    local filesystem for the jar, but the jar is really on your webserver
    and hasn't been downloaded yet. What does your jnlp file look like?
     
    Aidan, Jun 9, 2005
    #2
    1. Advertising

  3. Guest

    Thanks for your reply,

    Here is my jnlp file:

    === Start mainapp.jnlp ===

    <jnlp spec="1.0+"
    codebase="http://myhost/"
    href="mainapp.jnlp"
    >


    <!-- This information is shown to the user while they are loading the
    app -->
    <information>
    <title>Sample App</title>
    <vendor>ACME</vendor>
    <homepage href="http://www.acme.com" />
    <description>Sample application supporting plugins</description>
    </information>
    <offline-allowed/>
    <security>
    <all-permissions/>
    </security>

    <!-- Since 1.4+ is required for java web start to work,
    we can leave this as is
    -->
    <resources>
    <j2se version="1.4+" />
    <jar href="mainapp.jar"/>
    <jar href="jars/plugin1.jar"/>
    <jar href="jars/plugin2.jar"/>
    <jar href="jars/plugin3.jar"/>
    </resources>

    <application-desc main-class="mynamespace.MyMainClass" />
    </jnlp>

    ==== End of File ====

    As I mentioned before, the main app interface comes up fine using the
    web start way. Also all the jars are signed.

    Sachin
     
    , Jun 9, 2005
    #3
  4. Aidan Guest

    Aidan, Jun 10, 2005
    #4
  5. Smalltalker Guest

    Agreed that Rachel has a lot to offer to solve all the resource loader
    related issues. But most of the utilities provided by Rachel needs
    atleast the class name in order to load other resources from the given
    jar. In my case, I first read the MANIFEST file from the plugin jars in
    order to get the main class name for that jar. So the only input
    available for my case is jar file name. I couldn't see anywhere in
    Rachel utilities to load MANIFEST file from a given JAR file name. Is
    there a way around for that?
     
    Smalltalker, Jun 13, 2005
    #5
  6. Smalltalker Guest

    Alright, I solved the issue of loading a jar file and looking for its
    MANIFEST file by putting all the required plugin jars inside the main
    application jar and by using some code from
    http://rachel.sourceforge.net/crossref/rachel/loader/JarResourceLoader.java.html

    Now, another issue is when I try to instantiate the class from the
    plugin jar, it complains about not finding one of the class which is
    there inside the application jar mainapp.jar, I have my custom class
    loader taking care of loading the plug-in jar classes. The exception
    goes like this:

    java.lang.NoClassDefFoundError: com/mf/tte/workbench/ServiceUI
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at
    com.mf.tte.workbench.ServiceUIJarClassLoader.findClass(ServiceUIJarClassLoader.java:114)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at
    com.mf.tte.workbench.ServiceUIHelper.getServiceUIClass(ServiceUIHelper.java:132)

    I saw this posting
    http://forum.java.sun.com/thread.jspa?threadID=607830&messageID=3317360
    but, it is not working for me. Can anyone suggest me a solution?

    Thanks
    Sachin
     
    Smalltalker, Jun 14, 2005
    #6
  7. Smalltalker Guest

    Fixed it, by using the class loader of the mainapp.jar

    MyMainClass.class.getClassLoader().loadClass(name)

    Thanks Aidan for your responses.

    Sachin
     
    Smalltalker, Jun 14, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ike
    Replies:
    6
    Views:
    1,058
    Andrew Thompson
    Sep 24, 2004
  2. Replies:
    5
    Views:
    9,035
  3. JavaEnquirer
    Replies:
    2
    Views:
    522
    JavaEnquirer
    Feb 22, 2006
  4. tiewknvc9

    Java web start and jars...

    tiewknvc9, Sep 21, 2006, in forum: Java
    Replies:
    8
    Views:
    845
    Thufir
    Sep 23, 2006
  5. Ulf Meinhardt
    Replies:
    2
    Views:
    1,405
Loading...

Share This Page