Web2py Modjy & Glassfish

74 views
Skip to first unread message

Andrew

unread,
Nov 11, 2008, 12:37:55 PM11/11/08
to web2py Web Framework
I'm trying to get Web2Py working in glassfish via the new Jython 2.5
beta (www.jython.org) and was following the same approach that Frank
outlines here: http://fwierzbicki.blogspot.com/2008/04/jython-and-django-progress-part-ii.html

I'm stuck at the point where you setup the application.py and was
wondering if A) this approach could even work with web2py the way it
does with django and B) if anyone could assist me with how the
application.py would look?


Any help is greatly appreciated :)


TIA,
Andrew

mdipierro

unread,
Nov 11, 2008, 12:50:43 PM11/11/08
to web2py Web Framework
Absolutely. I am very exited by seeing web2py on jython. That would be
a very big step.

# in Django from your link

import os
from django.core.handlers import wsgi
os.putenv("DJANGO_SETTINGS_MODULE", "mysite.settings")
def handler(environ, start_response):
h = wsgi.WSGIHandler()
return h(environ, start_response)

# in web2py there are no setting

from gluon.main import wsgibase
return wsgibase(environ, start_response)

# make sure the web2py folder is in your python path

let me us know how things progress!

Massimo

On Nov 11, 11:37 am, Andrew <andrew.replo...@gmail.com> wrote:
> I'm trying to get Web2Py working in glassfish via the new Jython 2.5
> beta (www.jython.org) and was following the same approach that Frank
> outlines here:http://fwierzbicki.blogspot.com/2008/04/jython-and-django-progress-pa...

Andrew

unread,
Nov 11, 2008, 1:09:09 PM11/11/08
to web2py Web Framework
Thanks much Massimo!

I'll try it out tonight and report back on how everything works :)

Andrew

Andrew

unread,
Nov 11, 2008, 3:34:59 PM11/11/08
to web2py Web Framework
I'm able to deploy fine but when I try to hit the application I
receive:

Traceback (most recent call last):
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy.py", line 76, in
service
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy_exceptions.py",
line 91, in handle
modjy_exceptions.NoCallable: Error loading jython callable 'handler':
No module named gluon

Initially my layout looked like the following:

c:\temp\webapp
|__WEB-INF
| |__web.xml
| |___lib
| |__modjy.jar
| |__jython-complete.jar
| |__Lib
|__web2py
|__(web2py src structure with gluon etc)
|__application.py


application.py looks like:

import os
from gluon.main import wsgibase

def handler(environ, start_response):
return wsgibase(environ, start_response)


I've tried copying the web2py folder to WEB-INF/lib as well as copying
the contents of the web2py folder to WEB-INF/lib.

I wasn't sure where to set python path but I'm thinking maybe as a
param / init value in the web.xml for the modjy servlet as defined in:
http://modjy.xhaus.com/params.html
I'll give that a shot.

If you see anything out of place here let me know :)

Thanks,
Andrew



On Nov 11, 11:50 am, mdipierro <mdipie...@cs.depaul.edu> wrote:

Andrew

unread,
Nov 11, 2008, 4:29:49 PM11/11/08
to web2py Web Framework
Getting closer. I added the following init-param to my web.xml

<init-param>
<param-name>python.path</param-name>
<param-value>c:\temp\webapp\WEB-INF\lib\Lib;c:\temp\webapp
\web2py</param-value>
</init-param>

and based off of one of deha's post found that Jython has no signal
module so I stole the one from:
http://twistedmatrix.com/trac/attachment/ticket/3413/signal.py

I have my original layout as defined in the post above (ie. no web2py
in WEB-INF/* just in webapp)

Unfortunately now I get:

java.lang.IllegalArgumentException: Unknown signal: QUIT

so I'm going to muck around with the signal.py file since I'm on a
windows platform I figure I'll have to modify the signals
accordingly.

-Andrew

Andrew

unread,
Nov 11, 2008, 5:37:48 PM11/11/08
to web2py Web Framework
*correction in my layout, application.py is in the root of the webapp
folder.
c:\temp\webapp
|__WEB-INF
| |__web.xml
| |___lib
| |__modjy.jar
| |__jython-complete.jar
| |__Lib
|__web2py
| |__(web2py src structure with gluon etc)
|__application.py

still receiving unknown signal and can't find much on the web
regarding this IllegalArgException. Any help or direction is greatly
appreciated :)

Andrew

mdipierro

unread,
Nov 11, 2008, 5:56:38 PM11/11/08
to web2py Web Framework
I did a mistake before because of indentation. The applicaiton.py
should be:

def handler(environ, start_response):
from gluon.main import wsgibase
return wsgibase(environ, start_response)

You may also want to try something even simpler

#from gluon.main import wsgibase
def handler(e,r):
r('200 OK', [('Content-type','text/html')])
return ['<html><body><h1>Hello world</h1></body></html>']

if this works, remove the comment to see if it finds gluon.main in
path.

Massimo

Andrew

unread,
Nov 11, 2008, 6:01:32 PM11/11/08
to web2py Web Framework
Closer still :)

Looked up windows signal.h and found only following signal types are
defined in windows:

#define SIGINT 2 /* interrupt */
#define SIGILL 4 /* illegal instruction - invalid
function image */
#define SIGFPE 8 /* floating point exception */
#define SIGSEGV 11 /* segment violation */
#define SIGTERM 15 /* Software termination signal from
kill */
#define SIGBREAK 21 /* Ctrl-Break sequence */
#define SIGABRT 22 /* abnormal termination triggered by
abort call */

So I modified my signal.py accordingly and commented out unused signal
definitions. Now I'm stuck at an error I don't quite understand and
will probably need someone familiar with Java to assist.

Traceback (most recent call last):
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy.py", line 72, in
service
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy.py", line 89, in
dispatch_to_application
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy_wsgi.py", line 141,
in set_wsgi_environment
File "c:\temp\webapp\WEB-INF\lib\modjy.jar\modjy_wsgi.py", line 115,
in set_wsgi_streams
TypeError: coercing to Unicode: need string, 'javainstance' type found

This threw me off as I didn't expect to run across any errors in modjy
since other people seem to be using it with glassfish / django. Does
anyone know what this means and if it is possibly a configuration err
on my part? Or is this more possibly a compatibility issue between the
newer modjy and glassfish v3 prelude?

Thanks,
Andrew


On Nov 11, 4:37 pm, Andrew <andrew.replo...@gmail.com> wrote:

Andrew

unread,
Nov 12, 2008, 1:39:44 PM11/12/08
to web2py Web Framework
I followed up with Alan on modjy and he informed me that he has an
issue filed in jython 2.5beta that is causing this error.
http://bugs.jython.org/issue1171

Thanks Alan =]

For now I'll just wait it out until a later release of jython 2.5 =].

Thank you too Frank, if you see this, for all your hard work on
Jython!

Andrew
Reply all
Reply to author
Forward
0 new messages