Extending JMSketch Applet in a java class, but giving errors

User 512caa4d13

26-09-2008 10:31:26

I am trying to extend the JMSketch functionality to a java class but it giving following exceptions and warnings...





Sep 26, 2008 3:29:00 PM chemaxon.license.LicenseReader b


WARNING: Reading Java system property is not allowed: null


Sep 26, 2008 3:29:00 PM chemaxon.license.LicenseReader e


WARNING: Reading license.cxl file from user home is not allowed:


Sep 26, 2008 3:29:00 PM chemaxon.license.LicenseReader e


WARNING: Reading licenses.dat file from user home is not allowed:


java.lang.StackOverflowError


at java.util.Hashtable.get(Unknown Source)


at javax.swing.UIDefaults.getFromHashtable(Unknown Source)


at javax.swing.UIDefaults.get(Unknown Source)


at javax.swing.MultiUIDefaults.get(Unknown Source)


at javax.swing.UIDefaults.getColor(Unknown Source)


at javax.swing.UIManager.getColor(Unknown Source)


at javax.swing.LookAndFeel.installColors(Unknown Source)


at javax.swing.LookAndFeel.installColorsAndFont(Unknown Source)


at javax.swing.plaf.basic.BasicPanelUI.installDefaults(Unknown Source)


at javax.swing.plaf.basic.BasicPanelUI.installUI(Unknown Source)


at javax.swing.JComponent.setUI(Unknown Source)


at javax.swing.JPanel.setUI(Unknown Source)


at javax.swing.JPanel.updateUI(Unknown Source)


at javax.swing.JPanel.<init>(Unknown Source)


at javax.swing.JPanel.<init>(Unknown Source)


at javax.swing.JPanel.<init>(Unknown Source)


at javax.swing.JRootPane.createGlassPane(Unknown Source)


at javax.swing.JRootPane.<init>(Unknown Source)


at javax.swing.JApplet.createRootPane(Unknown Source)


at javax.swing.JApplet.<init>(Unknown Source)


at JMSketch.<init>(Unknown Source)


at SampleJMSketch.<init>(SampleJMSketch.java:8)


at SampleJMSketch.<init>(SampleJMSketch.java:10)





The code I have written in my java class is:





public class SampleJMSketch extends JMSketch{





public SampleJMSketch(){


super();


}


SampleJMSketch sampleeditor = new SampleJMSketch();


public void init() {





sampleeditor.start();


}








}





Please help me to get the solution as the class is compiled properly, I have created the jar file for this class and achieved in the HTML page [as working on a web application].





The HTML code is:





<applet name="Marvin_editor" CODE="SampleJMSketch.class" CODEBASE="config/appletjar" ARCHIVE="SampleJMSketch01.jar, jmarvin_unsigned.jar, aloe.jar, MarvinBeans.jar" WIDTH=540 HEIGHT=480>


<strong>Your browser does not support the applet tag.</strong>


</applet>

ChemAxon 7c2d26e5cf

26-09-2008 17:59:14

There are several problems with this code:





1. Using applet jar and MarvinBeans.jar in the same classpath causes conflict by loading classes that causes unexpected errors.





2. You have to know that the unsigned applet has got several shortcommings:


- local settings and system variables are not readable


- file system is not available (Open/Save are disabled)


- copy/paste between Marvin and other applications are disabled


- inchi import/export does not available


- calculator plugin does not work properly


Because of the above reason, usage of unsigned applet is not recommended.





3. You have overdefine the "init()" method of JMSketch that is important for the initalization of the applet.





I am not sure that extension of JMSketch is the best solution for you.


I suggest to describe what you would like to do exactly. It would help me a lot to give you further advices. If you want we can discuss it in email.

User 512caa4d13

01-10-2008 06:27:39

Regret for replying late.





I got your point about the conflict between MarvinBeans.jar, a desktop support API and jmarvin.jar, a web support API. I will remove the MarvinBeans.jar from the class path to avoid the conflict.





As you mentioned for the description about the application I am adding the same here below:





In our web application whatever stuff a user, scientist, is doing that will be saved in database which will be available to him worldwide. For example while researching on a chemical compound he drawn a molecule on the editor made some manipulations on it and then saved it in database. This stuff will be available for him whenever he wants. Now when we are displaying the compound on browser it will actually be the name of the compound which may be a link. On clicking this link he can download the compound/mole file to local machine and can manipulate it. But as we are providing a web application, we want to give him online editor where he can open the file, manipulate it and save it on the same server location or database.





I hope you are getting what actually we want to do. If we are giving such online editor then it is obvious that the user may want to drag and drop some other file directly from browser to the editor which is a bit difficult. We can provide the same functionality on right click menu or by any other possible way. Here technically, we are sending a request for marvin editor and as an response executing the applet. In general web application once the response is sent there is no communication within the source of request and the response, but here we want to communicate with applet continuously. Means if user is selecting any other file it should be displayed on the same applet editor and should not open a new one.





Also as we want to give some additional functionalities and for that we want to inherit the Marvin Applet functionalities by extending the JMSketch applet. But as mentioned in the post facing some exceptions. As you mentioned, using applet jar and MarvinBeans.jar in the same class path causes conflict, so I am working on the same.





Using URLConnetction class and ObjetctOutputStream, ObjetctInputStream it possible to communicate from a applet to server [servlet] and send/recieve mol/SMARTS format files.





I am expecting your comments on the scenario mentioned above and your help to find out the solution as facing exception when trying to extend JMSketch applet to my java class.





ChemAxon 7c2d26e5cf

02-10-2008 12:45:50

Hi,


I need time to think it over.


My email address is not public on the forum. But I am going to send you an email to get it.

User 512caa4d13

06-10-2008 09:54:09

Hello All,


Extending the JMSketch applet is now working fine, if you run the applet through Eclipse IDE. But when I have created the jar file of the class where I have inherited JMSketch and put it with the marvin-all jar files ia a codebase location and tried to call it in an HTML page it has given me following exception even after setting the FilePermissions:





java.lang.ExceptionInInitializerError


at JMSketch.<clinit>(Unknown Source)


at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)


at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)


at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)


at java.lang.reflect.Constructor.newInstance(Unknown Source)


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


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


at sun.applet.AppletPanel.createApplet(Unknown Source)


at sun.plugin.AppletViewer.createApplet(Unknown Source)


at sun.applet.AppletPanel.runLoader(Unknown Source)


at sun.applet.AppletPanel.run(Unknown Source)


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


Caused by: java.security.AccessControlException: access denied (java.io.FilePermission C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MoleRnD \config\appletjar\plugins\plugins.properties read)


at java.security.AccessControlContext.checkPermission(Unknown Source)


at java.security.AccessController.checkPermission(Unknown Source)


at java.lang.SecurityManager.checkPermission(Unknown Source)


at java.lang.SecurityManager.checkRead(Unknown Source)


at java.io.File.exists(Unknown Source)


at chemaxon.marvin.util.ExternalFileLoader.a(Unknown Source)


at chemaxon.marvin.util.ExternalFileLoader.<init>(Unknown Source)


at chemaxon.marvin.common.swing.MolPanel.<clinit>(Unknown Source)


... 12 more





There is no such file named plugins.properties under the codebase folder, here as appletjar. The HTML code is:





<applet CODE="SampleJMSketch.class" CODEBASE="config/appletjar/marvin" ARCHIVE="SampleJMSketch.jar" WIDTH=540 HEIGHT=480>





<strong>Your browser does not support the applet tag.</strong>


</applet>

ChemAxon 7c2d26e5cf

06-10-2008 19:37:13

The plugins.properties file has to be located into the xjars sub-directory of the marvin folder.

User 512caa4d13

07-10-2008 05:18:49

Dear Tamas, thank you for your reply.





As you mentioned I found the plugins.prperties file in the xjar folder of marvin-all zip. But the exception mentioned above is for the file in plugins folder located at the same location given in codebase attribute of the HTML applet tag, where all the jar files are placed to run the applet.





It is giving FilePermission exception. I really didn't understand why it is giving such exception as there is no such file located in a folder named "plugins", actually there is no such folder too out side marvin-all.





If the exceptions is really related to plugins.properties then it should have related to the same file in xjar folder.

ChemAxon 7c2d26e5cf

08-10-2008 16:50:02

By investigating the given stack trace, I assume that you loaded applet via file protocol (file:///C:/...), and your main jar is not signed.
Quote:
Caused by: java.security.AccessControlException: access denied (java.io.FilePermission C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MoleRnD \config\appletjar\plugins\plugins.properties read)
Can you confirm this?





We recommend to sign your main jar (jars in Marvin Applets package are already signed) to avoid security exception. The functionality of the applet is limited in non-signed context.