Re: java servlets, jsp and python
I have searched for jython and implemented some examples how to access jython code from java classes (e.g. with the ObjectFactory Pattern). Everything works fine outside the server. But if I create a Dynamic Web Project to access jython code from a java servlet, eclipse cannot find the org.python.util.PythonInterpreter; within my Factory.java I tried to add jython.jar to the class path of the project but it doesn't work. Do I have to configure the tomcat server in a way that it can use jython? On Wed, May 5, 2010 at 6:57 PM, Martin Gainty mgai...@hotmail.com wrote: you can implement a Jython (Python for Java) solution http://www.jython.org/ Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Wed, 5 May 2010 18:50:40 +0200 Subject: java servlets, jsp and python From: silvio.tscha...@googlemail.com To: users@tomcat.apache.org Hi all, I am new to Web-Programming and maybe my question is trivial. I want to build a dynamic webpage and want to use a python script within a java servlet. Is this possible? I thought that it is only possible to run java code within a servlet. Maybe I havn't understood the architecture right. Could anybody explain me how the web-container would call / interact with python? I haven't found this topic in the documentation. Cheers! _ The New Busy is not the old busy. Search, chat and e-mail from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3
set up tomcat for biopython
Hi all, how do I configure tomcat that it finds the biopython libaries? Biopython is not included in jython.jar (which I have moved into the tomcat/lib folder. Biopython installs itself into the python26/lib/side-packages folder. But how can I tell tomcat about this? There is no python.jar neither a biopython.jar file which I could drop into tomcat/lib. While running my Java Servlet which accesses a Jython module, that should access a Biopython class, this class cannot be found. Thanks for your reply!
Re: set up tomcat for biopython
First of all, thanks for your reply! On Tue, May 11, 2010 at 6:33 PM, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Silvio, I'm not familiar with biopython, so... On 5/11/2010 11:36 AM, Silvio Tschapke wrote: how do I configure tomcat that it finds the biopython libaries? Biopython is not included in jython.jar (which I have moved into the tomcat/lib folder. You probably want this JAR file in your webapp's WEB-INF/lib directory, rather than in Tomcat's global lib directory. Biopython installs itself into the python26/lib/side-packages folder. Okay, what files does it put in there? There is no jar file. In the side-packages folder it puts a root folder Bio which includes further folders with .py, .pyo, pyc files. But how can I tell tomcat about this? There is no python.jar neither a biopython.jar file which I could drop into tomcat/lib. So, is biopython a set of binary libraries like .so files? Are you sure that it can be used in general with jython? If so, you probably just have to modify your java.library.path system property. I don't understand this. Do I have to tell Tomcat in a configuration file where it has to search for python or the libraries? Biopython works fine with Python outside my webserver. I am not sure if it works with Jython too. But I thought that Jython works fine with Python and Biopython is a subpackage so there shouldn'b be any problem. But I am not sure. When I write a CGI script which I put into the cgi-bin folder of a http server biopython works fine, because there you have to tell the server where it finds python.exe. While running my Java Servlet which accesses a Jython module, that should access a Biopython class, this class cannot be found. Can you post the stack trace for the CNFE? When I call: http://localhost:8080/Test_jee_with_jython/MyServlet I get a HTTP Status 500 error: Apache Tomcat/6.0.26 - Error report Traceback (most recent call last): File C:/Documents and Settings/silvio/My Documents/eclipse_jee_workspace/Test_jee_with_jython/src/jyimplementation/Calculator.py, line 2, in module from Bio import Entrez ImportError: No module named Bio org.python.core.PyException.fillInStackTrace(PyException.java:70) java.lang.Throwable.init(Throwable.java:181) java.lang.Exception.init(Unknown Source) java.lang.RuntimeException.init(Unknown Source) org.python.core.PyException.init(PyException.java:46) org.python.core.PyException.init(PyException.java:43) org.python.core.PyException.init(PyException.java:61) org.python.core.Py.ImportError(Py.java:264) org.python.core.imp.import_first(imp.java:672) org.python.core.imp.import_name(imp.java:756) org.python.core.imp.importName(imp.java:806) org.python.core.ImportFunction.__call__(__builtin__.java:1232) org.python.core.PyObject.__call__(PyObject.java:367) org.python.core.__builtin__.__import__(__builtin__.java:1202) org.python.core.imp.importFromAs(imp.java:884) org.python.core.imp.importFrom(imp.java:860) org.python.pycode._pyx2.f$0(C:/Documents and Settings/silvio/My Documents/eclipse_jee_workspace/Test_jee_with_jython/src/jyimplementation/Calculator.py:7) org.python.pycode._pyx2.call_function(C:/Documents and Settings/silvio/My Documents/eclipse_jee_workspace/Test_jee_with_jython/src/jyimplementation/Calculator.py) org.python.core.PyTableCode.call(PyTableCode.java:165) org.python.core.PyCode.call(PyCode.java:18) org.python.core.Py.runCode(Py.java:1204) org.python.core.__builtin__.execfile_flags(__builtin__.java:541) org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:190) factory.JythonFactory.getJythonObject(JythonFactory.java:21) main.Main.forwardRequest(Main.java:17) servlets.MyServlet.doGet(MyServlet.java:36) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) If I change the import command in my jython module from from Bio import Entrez to import Bio.Entrez it doesn't work neither. By the way..what means CNFE? :) - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvphvUACgkQ9CaO5/Lv0PAMdACgkk4lhyC8eZkbkrh0x6VULbzu nMcAoKKPg0THwapz6qDBLrp+znmnPSPr =gDVj -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: set up tomcat for biopython
I took a look at jython and actually I am trying to implement a java servlet which calls a python module with help of jython. But I am not sure how and if I can use Biopython inside my jython modules. On Tue, May 11, 2010 at 6:44 PM, Martin Gainty mgai...@hotmail.com wrote: i would start here http://sourceforge.net/projects/jython/files/ feel free to ask any questions hth Martin Gainty __ Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen. Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni. Date: Tue, 11 May 2010 17:36:02 +0200 Subject: set up tomcat for biopython From: silvio.tscha...@googlemail.com To: users@tomcat.apache.org Hi all, how do I configure tomcat that it finds the biopython libaries? Biopython is not included in jython.jar (which I have moved into the tomcat/lib folder. Biopython installs itself into the python26/lib/side-packages folder. But how can I tell tomcat about this? There is no python.jar neither a biopython.jar file which I could drop into tomcat/lib. While running my Java Servlet which accesses a Jython module, that should access a Biopython class, this class cannot be found. Thanks for your reply! _ Hotmail is redefining busy with tools for the New Busy. Get more from your inbox. http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
Re: set up tomcat for biopython
Ok, I will try this. Thanks a lot for your help! On Tue, May 11, 2010 at 7:50 PM, Christopher Schultz ch...@christopherschultz.net wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Silvio, On 5/11/2010 1:09 PM, Silvio Tschapke wrote: On 5/11/2010 11:36 AM, Silvio Tschapke wrote: how do I configure tomcat that it finds the biopython libaries? Biopython is not included in jython.jar (which I have moved into the tomcat/lib folder. You probably want this JAR file in your webapp's WEB-INF/lib directory, rather than in Tomcat's global lib directory. Biopython installs itself into the python26/lib/side-packages folder. Okay, what files does it put in there? There is no jar file. In the side-packages folder it puts a root folder Bio which includes further folders with .py, .pyo, pyc files. Okay, those are Python scripts, compiled/optimized scripts, and compiled scripts. Nothing in there is directly executable, so you probably don't need to mess with your java.library.path setting. I don't understand this. Do I have to tell Tomcat in a configuration file where it has to search for python or the libraries? Biopython works fine with Python outside my webserver. I am not sure if it works with Jython too. But I thought that Jython works fine with Python and Biopython is a subpackage so there shouldn'b be any problem. But I am not sure. You might want to read a bit more about Jython: it does not give you access to the python environment on the local machine. Instead, it is its own environment. Consider reading http://www.jython.org/docs/tutorial/indexprogress.html If Bio uses direct C-library calls instead of Python functions, you're out of luck for the time being. Your first step would be to determine if Bio will work with Jython: I recommend getting in touch with the Jython folks to help you figure out how to get Bio working with Jython. After that's working, it shouldn't be difficult to move everything into Tomcat. Traceback (most recent call last): File C:/Documents and Settings/silvio/My Documents/eclipse_jee_workspace/Test_jee_with_jython/src/jyimplementation/Calculator.py, line 2, in module from Bio import Entrez ImportError: No module named Bio org.python.core.PyException.fillInStackTrace(PyException.java:70) So, somewhere there must be a place where you can configure where Jython looks for modules. [...] org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:190) factory.JythonFactory.getJythonObject(JythonFactory.java:21) main.Main.forwardRequest(Main.java:17) It looks like before you call execfile(), you might want to make some other calls on either the PythonInterpreter object, or the PySystemState object it's using, which seems to have something to do with locating modules. servlets.MyServlet.doGet(MyServlet.java:36) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) If I change the import command in my jython module from from Bio import Entrez to import Bio.Entrez it doesn't work neither. By the way..what means CNFE? :) That's ClassNotFoundException, which is a Java exception. You're not getting that exception, but a different one from the Python interpreter. Don't worry: you gave me what I was looking for. So, it just looks like you need to figure out how to tell Jython that the Bio libraries are under .../lib/side-packages. I think you're going to have to ask the Jython folks. Good luck, - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkvpmNsACgkQ9CaO5/Lv0PAESQCcC4gjP3G9QUM5L7hAnmb1iPlg yOQAnjI8fXrcGPUyl+QJm/DUaf1ocbp+ =v3t/ -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
java servlets, jsp and python
Hi all, I am new to Web-Programming and maybe my question is trivial. I want to build a dynamic webpage and want to use a python script within a java servlet. Is this possible? I thought that it is only possible to run java code within a servlet. Maybe I havn't understood the architecture right. Could anybody explain me how the web-container would call / interact with python? I haven't found this topic in the documentation. Cheers!