Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Load multiple jars with Web Start

Reply
Thread Tools

Load multiple jars with Web Start

 
 
shahsachin@gmail.com
Guest
Posts: n/a
 
      06-09-2005
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(Plugin UIHelper.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

 
Reply With Quote
 
 
 
 
Aidan
Guest
Posts: n/a
 
      06-09-2005
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?

 
Reply With Quote
 
 
 
 
shahsachin@gmail.com
Guest
Posts: n/a
 
      06-09-2005
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

 
Reply With Quote
 
Aidan
Guest
Posts: n/a
 
      06-10-2005
Read this page and it should tell you what's going wrong:

http://www.vamphq.com/resources.html

 
Reply With Quote
 
Smalltalker
Guest
Posts: n/a
 
      06-13-2005
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?

 
Reply With Quote
 
Smalltalker
Guest
Posts: n/a
 
      06-14-2005
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/crossr...ader.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.findC lass(ServiceUIJarClassLoader.java:114)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at
com.mf.tte.workbench.ServiceUIHelper.getServiceUIC lass(ServiceUIHelper.java:132)

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

Thanks
Sachin

 
Reply With Quote
 
Smalltalker
Guest
Posts: n/a
 
      06-14-2005
Fixed it, by using the class loader of the mainapp.jar

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

Thanks Aidan for your responses.

Sachin

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add *.jars to *.jars possible/recommendend? Eclipse setup for this? Ulf Meinhardt Java 2 02-03-2010 04:11 PM
Java web start and jars... tiewknvc9 Java 8 09-23-2006 07:01 PM
Loading image from jars from other jars etc JavaEnquirer Java 2 02-22-2006 03:42 PM
JARs containing JARs alan@engrm.com Java 5 05-19-2005 04:55 PM
exec jars w/dependent jars Ike Java 6 09-24-2004 06:03 PM



Advertisments