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
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
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
MyMainClass.class.getClassLoader().loadClass(name)
Thanks Aidan for your responses.
Sachin