You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Silvio Tschapke <si...@googlemail.com> on 2010/05/11 17:36:02 UTC

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

Posted by Felix Schumacher <fe...@internetallee.de>.
Am Dienstag, den 11.05.2010, 17:36 +0200 schrieb Silvio Tschapke:
> 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.
If my google-research is correct, you will have to use a branch of
bioperl which supports jython: http://github.com/kellrott/biopython

If you use this and jython 2.5.1, you will have to set the environment
variable JYTHONPATH=$PATH_WHERE_YOU_CHECKEDOUT_BIOPYTHON

After that you should be able to run jython in command line and do an
>>> import Bio.Entrez
without problems. When you have run that command successfully you could
go further to try and embed jython with that environment variable into a
servlet.

Bye
 Felix

Thanks to Chris for providing the link to the jython tutorial :)
> 
> 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!



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: set up tomcat for biopython

Posted by André Warnier <aw...@ice-sa.com>.
Silvio Tschapke wrote:
> 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.
> 
I do not know anything about jython (or python for that matter), but by 
browsing around I found this, which may give you a clue as to the solution :
http://wiki.python.org/jython/UserGuide#embedding-jython

Sounds like an interesting animal anyway..
If I understand that thing right, this is a just-in-time compiler that 
can compile Python programs and modules as Java bytecode, then run it as 
a servlet.  Amazing what smart people can put together nowadays.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: set up tomcat for biopython

Posted by Silvio Tschapke <si...@googlemail.com>.
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 <mg...@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.tschapke@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

Posted by Martin Gainty <mg...@hotmail.com>.
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.tschapke@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

Posted by André Warnier <aw...@ice-sa.com>.
Silvio Tschapke wrote:
> Ok, I will try this. Thanks a lot for your help!
> 
> On Tue, May 11, 2010 at 7:50 PM, Christopher Schultz <
> chris@christopherschultz.net> wrote:
> 
[...]

>>
>>  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.
>>
+1
That is what the link I sent earlier seems to point to also.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: set up tomcat for biopython

Posted by Silvio Tschapke <si...@googlemail.com>.
Ok, I will try this. Thanks a lot for your help!

On Tue, May 11, 2010 at 7:50 PM, Christopher Schultz <
chris@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: set up tomcat for biopython

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: set up tomcat for biopython

Posted by Silvio Tschapke <si...@googlemail.com>.
First of all, thanks for your reply!

On Tue, May 11, 2010 at 6:33 PM, Christopher Schultz <
chris@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-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: set up tomcat for biopython

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----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?

> 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.

> 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?

- -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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org