MarvinView javascript not working with local jar?

User 3d9c3fd7f7

25-05-2011 23:28:04

Hi,




I am having trouble
embedding the MarvinView applet in HTML pages using a jar on a local
machine. Take for example the following code:


<html>

<body>


<script type="text/javascript" SRC="marvin/marvin.js"></script>

<script type="text/javascript">

mview_name = "AView";


mview_begin("http://www.chemaxon.com/marvin", 200, 200);

mview_param("mol", "mols/aspirin.csmol");

mview_end();

mview_name = "BView";

mview_begin("http://www.chemaxon.com/marvin", 200, 200, true);

mview_param("mol", "mols/aspirin.csmol");

mview_end();

mview_name = "CView";

mview_begin("marvin", 200, 200);

mview_param("mol", "mols/aspirin.csmol");

mview_end();

mview_name = "DView";

mview_begin("marvin", 200, 200, true);

mview_param("mol", "mols/aspirin.csmol");

mview_end();

</script>

</body> 

</html> 


Outcome:


AView: Successful.

BView: Successful.

CView: Displays a 200 by 200 gray box.

DView: Displays an outlined white box with an error message; clicking it gives the following stack trace:



java.lang.RuntimeException: java.lang.NoClassDefFoundError: chemaxon/marvin/view/swing/ViewPanel

at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)

at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.NoClassDefFoundError: chemaxon/marvin/view/swing/ViewPanel

at java.lang.Class.getDeclaredConstructors0(Native Method)


at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)

at java.lang.Class.getConstructor0(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEventImpl(Unknown Source)

at java.awt.EventQueue.access$000(Unknown Source)

at java.awt.EventQueue$1.run(Unknown Source)

at java.awt.EventQueue$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Caused by: java.lang.ClassNotFoundException: chemaxon.marvin.view.swing.ViewPanel

at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 20 more



(The class "chemaxon/marvin/view/swing/ViewPanel" is in the jar file.)


Notes about the jar itself:


The jar that exists in the marvin directory along
with the marvin.js file and is named jmarvin.jar (the name
appletlaunch.jar has also been used). It has been constructed by
following the descriptions on this page: http://www.chemaxon.com/marvin-archive/5.5.0.1/marvin/help/developer/applets/appletfaq.html#question2 simply unzipping all of the jar files in sjar into a directory and creating the jar file.

Due to a reported untrusted class package error, the unsigner was run on this jar (https://www.chemaxon.com/forum/ftopic65.html).
However this error remains. Additionally, it seems as though this
continues to be an error even if the jar has been removed from the
directory.


I am presently using Ubuntu 10.04
The errors were obtained using Google Chrome 11.0.696.71

Firefox 4.0.1 is having extra trouble even loading the page.


Thank you for your assistance.



ChemAxon 7c2d26e5cf

26-05-2011 14:37:05

Why do you merge the jar files?


Applet resources (jar files) are loading on demand.


Unsigned applet is not supported anymore in Marvin. Applet init processes certain codes that requires trusted context.


If marvin.js generates the applet code, it presets certain applet parameters:


It set the java_arguments applet parameter like this


<param name="java_arguments" value="-Djnlp.packEnabled=true"/> 

It means that Java classloader prefers *.jar.pack.gz files (gz compressed pack200 optimized version of jars) instead of *.jar at downloading resources.
Thus, when *.jar files are unsigned but *.jar.pack.gz files still exist, applet loads resources from *.jar.pack.gz files. If you want removing all signed contents, you have to remove *.jar.pack.gz files too. But, as I mentioned it earlier, removing signing information has no sence any more.


I have tested your example where jar files in the local copy are unsigned (and *.jar.pack.gz files are removed). In this case, those applet instances that referred to the local copy could not be loaded in (because of the lack of signed context).

User 3d9c3fd7f7

27-05-2011 18:49:05

Thanks for the reply.


NOT merging the JARs and NOT touching the signing seems to have solved the problem.