Debugging WebStack apps

12 views
Skip to first unread message

Kevin Glynn

unread,
Sep 25, 2007, 12:07:04 PM9/25/07
to webstack...@googlegroups.com

keving writes:
>
>
> Greetings,
>
> Do you have any tips on debugging applications? I am working with the
> Java Servlet / jython adapter, but often I don't get any feedback
> about errors in my code. For example, if I try to open a file that
> doesn't exist then the processing just seems to end, there is no

Errrr, scrub that example. java.io.File() doesn't check that the file
actually exists. I'll look out for another example, but debugging
tips are very welcome ....

k

Paul Boddie

unread,
Sep 25, 2007, 12:33:10 PM9/25/07
to webstack-discuss

I'm not one for sophisticated debugging solutions, unfortunately, but
perhaps there's something you can do with logging. Many "happy" hours
were spent in previous jobs looking at the Tomcat error log, although
I don't remember the precise details of the plumbing necessary to make
the errors appear in the right place.

I've tried to make the deploy function offer support for handling (or
not handling) errors, although not doing so usually propagates any
exceptions up to the server environment, which is the supplied
PyServlet Java class deployed inside your application server. You
might like to specify handle_errors=0 to the deploy function, if you
aren't doing so already, and see what appears. (I also remember
anxiously looking at the modification times of Tomcat log files,
hoping that something useful would show up eventually.)

Paul

Kevin Glynn

unread,
Sep 25, 2007, 11:26:38 AM9/25/07
to webstack...@googlegroups.com

Greetings,

Do you have any tips on debugging applications? I am working with the
Java Servlet / jython adapter, but often I don't get any feedback
about errors in my code. For example, if I try to open a file that
doesn't exist then the processing just seems to end, there is no

output returned and nothing in the tomcat logs. I think this also
happens with certain python syntax errors, sometimes I get a 'nice'
exception trace back, but sometimes just nothing.

I have tried adding handle_errors=0 to my deploy call but that doesn't
change anything.

thanks
k

Paul Boddie

unread,
Sep 25, 2007, 8:34:15 PM9/25/07
to webstack-discuss
On 25 Sep, 17:26, Kevin Glynn <kevin.gl...@gmail.com> wrote:
>

Sorry about the relatively incoherent answer to your last message.
I've yet to master the administrative functions in Google groups which
told me that it thought the original message was spam, so I didn't get
to "approve" the original message until after I'd answered the follow-
up.

For me with Jython 2.1 and the ancient Tomcat 4.1.31, I do get
tracebacks, even for the most blatant of errors, and I imagine that
there's some kind of setting in Tomcat around showing tracebacks. I'll
take a closer look to see what can be changed.

Anyway, with respect to actually getting Jython and Tomcat to play
together on Ubuntu Feisty (7.04), I've made an alarming discovery
around the urllib and deploy problems previously discussed: even with
the supposedly sufficient jython-gcj package installed, the deployed
Web application won't run (getting the "ImportError: cannot import
name deploy" error); with the jython.org version of Jython, however,
the deployed application runs normally.

I can only imagine that there's something wrong with the way that
Ubuntu have split the Lib directory into Lib and Lib-cpython, and I'm
currently trying to see if there's a way of setting the "python.path"
Java property in the web.xml file (similar to that which is done in
the /usr/bin/jython script).

Paul

Kevin Glynn

unread,
Sep 26, 2007, 10:40:51 AM9/26/07
to webstack...@googlegroups.com

Paul Boddie writes:
>
> On 25 Sep, 17:26, Kevin Glynn <kevin.gl...@gmail.com> wrote:
> >
> > Do you have any tips on debugging applications? I am working with the
> > Java Servlet / jython adapter, but often I don't get any feedback
> > about errors in my code. For example, if I try to open a file that
> > doesn't exist then the processing just seems to end, there is no
> > output returned and nothing in the tomcat logs. I think this also
> > happens with certain python syntax errors, sometimes I get a 'nice'
> > exception trace back, but sometimes just nothing.
> >
> > I have tried adding handle_errors=0 to my deploy call but that doesn't
> > change anything.
>
> Sorry about the relatively incoherent answer to your last message.
> I've yet to master the administrative functions in Google groups which
> told me that it thought the original message was spam, so I didn't get
> to "approve" the original message until after I'd answered the follow-
> up.
>

no problem, I didn't notice!

> For me with Jython 2.1 and the ancient Tomcat 4.1.31, I do get
> tracebacks, even for the most blatant of errors, and I imagine that
> there's some kind of setting in Tomcat around showing tracebacks. I'll
> take a closer look to see what can be changed.
>

groan, I tried to create a simple example to reproduce the problem and
I think I have uncovered my foolishness :(. I had wrapped my resource
in a 'LoginRedirectResource' which I then forgot about ...... I need
to add the handle_errors=0 to the deploy call in LoginApp.

Sorry about that, I will let you know if that doesn't fix the
problem. Its a big relief that I now get notified about python syntax
errors :)


> Anyway, with respect to actually getting Jython and Tomcat to play
> together on Ubuntu Feisty (7.04), I've made an alarming discovery
> around the urllib and deploy problems previously discussed: even with
> the supposedly sufficient jython-gcj package installed, the deployed
> Web application won't run (getting the "ImportError: cannot import
> name deploy" error); with the jython.org version of Jython, however,
> the deployed application runs normally.
>

> I can only imagine that there's something wrong with the way that
> Ubuntu have split the Lib directory into Lib and Lib-cpython, and I'm
> currently trying to see if there's a way of setting the "python.path"
> Java property in the web.xml file (similar to that which is done in
> the /usr/bin/jython script).
>

I gave up on the Ubuntu version of jython yesterday, it was just too
frustrating reading the small print in the python docs to see what is
not supported until python 2.2. I have installed 2.2.1rc1, much
better syntax and library support and seems a bit quicker too.

I am on vacation now until next week, let me know if I can do
anything to help when I get back.

k

Paul Boddie

unread,
Sep 26, 2007, 12:27:54 PM9/26/07
to webstack-discuss
On 26 Sep, 16:40, Kevin Glynn <kevin.gl...@gmail.com> wrote:
>
> groan, I tried to create a simple example to reproduce the problem and
> I think I have uncovered my foolishness :(. I had wrapped my resource
> in a 'LoginRedirectResource' which I then forgot about ...... I need
> to add the handle_errors=0 to the deploy call in LoginApp.
>
> Sorry about that, I will let you know if that doesn't fix the
> problem. Its a big relief that I now get notified about python syntax
> errors :)

Perhaps we need to think about solutions which expose configuration
issues of this nature. Generally, I've tried to leave errors and
logging to the underlying infrastructure, but perhaps some more
functionality is needed in WebStack itself.

On the subject of the login infrastructure, I've been trying to bulk
up various components in my other Web programming package, XSLTools,
and although I think the SimpleWithLogin example provides some details
of how you combine a login application with a protected application at
the same location, perhaps the documentation could be more explicit
about such matters. Originally, the SimpleWithLogin example needed a
Login example running alongside in a separate application (which would
be a separate port for BaseHTTPRequestHandler, for example), but the
intention there was to demonstrate multi-server single sign-on, which
isn't really a necessity for most applications.

[...]

> I gave up on the Ubuntu version of jython yesterday, it was just too
> frustrating reading the small print in the python docs to see what is
> not supported until python 2.2. I have installed 2.2.1rc1, much
> better syntax and library support and seems a bit quicker too.

I think Jython 2.1 is good enough, but I just have to work out what
the packagers did to it. I envisage having to change the PyServlet
class and permitting extra paths to be specified in the web.xml file.
Of course, your own code might be happier with 2.2, but the examples
have all been tested with 2.1 on a "vanilla" Jython installation.

> I am on vacation now until next week, let me know if I can do
> anything to help when I get back.

Bon voyage! I hope to be busy with plenty of things for your
inspection when you return. ;-)

Paul

Kevin Glynn

unread,
Oct 1, 2007, 5:36:17 PM10/1/07
to webstack...@googlegroups.com

Paul Boddie writes:
>
> On 26 Sep, 16:40, Kevin Glynn <kevin.gl...@gmail.com> wrote:
> >
> > groan, I tried to create a simple example to reproduce the problem and
> > I think I have uncovered my foolishness :(. I had wrapped my resource
> > in a 'LoginRedirectResource' which I then forgot about ...... I need
> > to add the handle_errors=0 to the deploy call in LoginApp.
> >
> > Sorry about that, I will let you know if that doesn't fix the
> > problem. Its a big relief that I now get notified about python syntax
> > errors :)
>
> Perhaps we need to think about solutions which expose configuration
> issues of this nature. Generally, I've tried to leave errors and
> logging to the underlying infrastructure, but perhaps some more
> functionality is needed in WebStack itself.
>

I'm back from vacation :(

I would like to control this behaviour via a config file so that it
can be quickly changed. It would be nice if Webstack could have a
standard solution to save everyone having to do it themselves.

> On the subject of the login infrastructure, I've been trying to bulk
> up various components in my other Web programming package, XSLTools,
> and although I think the SimpleWithLogin example provides some details
> of how you combine a login application with a protected application at
> the same location, perhaps the documentation could be more explicit
> about such matters. Originally, the SimpleWithLogin example needed a
> Login example running alongside in a separate application (which would
> be a separate port for BaseHTTPRequestHandler, for example), but the
> intention there was to demonstrate multi-server single sign-on, which
> isn't really a necessity for most applications.
>

I just included it to see what would happen, and then forgot I had
done it! I haven't given any thought yet into how we should best
handle authentication / authorization issues. I haven't developed
this sort of application before.

I am intending to look at XSLTools too sometime soonish.

>
> Bon voyage! I hope to be busy with plenty of things for your
> inspection when you return. ;-)
>

just let us know when you are ready.

cheers
k

Paul Boddie

unread,
Oct 2, 2007, 5:42:08 AM10/2/07
to webstack-discuss
On 1 Okt, 23:36, Kevin Glynn <kevin.gl...@gmail.com> wrote:
>
> I would like to control this behaviour via a config file so that it
> can be quickly changed. It would be nice if Webstack could have a
> standard solution to save everyone having to do it themselves.

Do you have any suggestions? When I started developing WebStack, my
opinion was that it wasn't too bad to edit the top-level application
file to configure the application - I'd had experience with a range of
different configuration solutions (Apache, Java XML files, Webware's
configuration file directory, etc.) and ended up thinking that having
separate configuration files was overkill for the simple applications
I was writing - but if you have any interesting proposals, I'd like to
hear them.

[Authentication]

> I just included it to see what would happen, and then forgot I had
> done it! I haven't given any thought yet into how we should best
> handle authentication / authorization issues. I haven't developed
> this sort of application before.
>
> I am intending to look at XSLTools too sometime soonish.

Great! Perhaps I should get the underlying XML/XSLT stuff working with
Java-based libraries, too.

On the subject of development on WebStack itself, I had a look into
various Jython issues and hopefully have a few improvements to release
around the Java Servlet support, along with some Webware and Zope-
related fixes and some support for the wsgiref module in Python 2.5.
The Jython stuff on Ubuntu Feisty can be a bit awkward, but I seem to
have some kind of solution for the packaged version of Jython, even
though I'm not totally convinced that the gcj-based runtime is always
behaving itself. I did try using the packaged version of Tomcat 5.5,
but after managing to get it to start once, it decided not to start
ever again after that, so I think some more work is needed before I
can integrate WebStack completely with the system packages.

Paul

Reply all
Reply to author
Forward
0 new messages