Image Generation Using Marvin Beans

    The examples below demonstrate how to integrate the Marvin Beans API into JSP pages to generate images from molecule sources.

    We provide only tryout for each example.

    System Requirement

    Since the examples are JSP examples, you need a web server that implements Java Server Pages technology. We recommend Apache Tomcat to use. Tomcat needs a Sun's JDK to compile and run the JSP code. Since Marvin Beans API requires at least Java 1.5, the JDK that Tomcat uses has to be 1.5 or later version.

    On the client-side, you need only a web browser to access the webserver and open the JSP pages. In a few examples, MarvinSketch or MarvinView applets are also referred to as draw queries or display results. To be able to run an applet, you need a Java-capable browser (most of the browser support it) and a Java Plugin. Read more about it in the System requirement of MarvinView/Sketch applet: System requirements.

    Examples load the applet from the Chemaxon site. Of course, you can modify your local copy of JSP examples to get an applet from your site.

    Installation

    1. Install Apache Tomcat. (Of course, the examples also run under other servlet servers. In this document we demonstrate installation with a 4.1 version of Apache Tomcat under Linux that we placed into the /opt/apache-tomcat directory.) Refers to its manual on how to do it.

    2. Download the Marvin Beans package and extract it somewhere. (You can use also the JChem package since it also includes the Marvin Beans API.)

    3. Copy all jar files (files with .jar extension) of the lib directory of Marvin Beans (or JChem) package into the shared/lib directory of Tomcat.

      cd $HOME/marvinbeans/lib
      cp *.jar /opt/apache-tomcat/shared/lib/
    4. Create the marvin directory where default JSP examples are situated under your Tomcat: webapps/examples/jsp/marvin.

      cd /opt/apache-tomcat/webapps/examples/jsp
      mkdir marvin
    5. Copy all files from the examples/beans/image-generation directory of Marvin Beans to the previously created directory (webapps/examples/jsp/marvin/).

      cp $HOME/marvinbeans/examples/beans/image-generation/* /opt/apache-tomcat/webapps/examples/jsp/marvin/
    6. Modify show_image3.jsp and show_image4.jsp to refer to that directory in the path to caffeine.smi. In this case, the new path is /opt/apache-tomcat/webapps/examples/jsp/marvin/caffeine.smi.

    7. Start Tomcat (or restart it if it is already running).

    The installation is completed. To test everything works fine, open the following URL in your web browser.

    http://localhost:8080/examples/jsp/marvin/show_image1.html

    If you would like to access it from a different machine, substitute the localhost domain with the IP address or domain name of the webserver.

    Troubleshoot

    If the example does not display when you open the above URL in the browser, the problem may be in the configuration. Probably, you have copied jars into the wrong directory. Check the error log of Tomcat: logs/catalina.out. In this case, you will find the following error message there:

    Error compiling file: /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java [javac] Compiling 1 source file /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:9: package chemaxon.formats does not exist import chemaxon.formats.MolImporter; ^ /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:10: package chemaxon.struc does not exist import chemaxon.struc.Molecule; ^ /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:67: cannot find symbol symbol : class Molecule location: class org.apache.jsp.generate_image_jsp Molecule mol = null; ^ /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:71: cannot find symbol symbol : class MolImporter location: class org.apache.jsp.generate_image_jsp MolImporter mi = new MolImporter(f,""); ^ /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:71: cannot find symbol symbol : class MolImporter location: class org.apache.jsp.generate_image_jsp MolImporter mi = new MolImporter(f,""); ^ /opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java:75: cannot find symbol symbol : variable MolImporter location: class org.apache.jsp.generate_image_jsp mol = MolImporter.importMol(molstring); ^ 6 errors Info: Compile: javaFileName=/opt/apache-tomcat/work/Standalone/localhost/examples/jsp/marvin/generate_image_jsp.java classpath=/opt/apache-tomcat/webapps/examples/WEB-INF/classes/:/opt/apache-tomcat/webapps/examples/WEB-INF/classes/:/opt/apache-tomcat/shared/classes/:/opt/apache-tomcat/common/classes/:/opt/apache-tomcat/common/lib/ant-launcher.jar:/opt/apache-tomcat/common/lib/jasper-runtime.jar:/opt/apache-tomcat/common/lib/commons-collections-3.2.jar:/opt/apache-tomcat/common/lib/jasper-compiler.jar:/opt/apache-tomcat/common/lib/ant.jar:/opt/apache-tomcat/common/lib/naming-factory.jar:/opt/apache-tomcat/common/lib/commons-logging-api-1.1.1.jar:/opt/apache-tomcat/common/lib/servlet.jar:/opt/apache-tomcat/common/lib/naming-resources.jar:/opt/apache-tomcat/common/lib/naming-common.jar cp=/opt/apache-tomcat/webapps/examples/WEB-INF/classes cp=/opt/apache-tomcat/webapps/examples/WEB-INF/classes cp=/opt/apache-tomcat/shared/classes cp=/opt/apache-tomcat/common/classes cp=/opt/apache-tomcat/common/lib/ant-launcher.jar cp=/opt/apache-tomcat/common/lib/jasper-runtime.jar cp=/opt/apache-tomcat/common/lib/commons-collections-3.2.jar cp=/opt/apache-tomcat/common/lib/jasper-compiler.jar cp=/opt/apache-tomcat/common/lib/ant.jar cp=/opt/apache-tomcat/common/lib/naming-factory.jar cp=/opt/apache-tomcat/common/lib/commons-logging-api-1.1.1.jar cp=/opt/apache-tomcat/common/lib/servlet.jar cp=/opt/apache-tomcat/common/lib/naming-resources.jar cp=/opt/apache-tomcat/common/lib/naming-common.jar work dir=/opt/apache-tomcat/work/Standalone/localhost/examples srcDir=/opt/apache-tomcat/work/Standalone/localhost/examples include=jsp/marvin/generate_image_jsp.java Exception compiling Compile failed; see the compiler error output for details.

    Check the shared/lib folder of your Tomcat whether Marvin Beans jars are available there. If not, complete it. If yes, please consult with the manual of the Tomcat why it can not load classes from these JARs.

    Please also see File Formats.