I found the issue, mode arg must be provided, e.g.

f = open('name', 'rt')

it's not optional as in Python

Don't know yet about the try/except issue.


On 08/28/2013 05:26 PM, Fernando wrote:
Hi again,

while trying to narrow down the utf-8 problem I described in another post, I tried to open a file containing non-ascii characters (linux, tomcat, jython, pyservlet).

However, I've been unable to do something as simple as

f = open('words.txt')

I've put the file in the same folder of the pylet and also on /home/tomcat. I also tried to use full path but nothing works.

I'm getting a long backtrace but no really useful information as to the source of the issue.

javax.servlet.ServletException: Servlet execution threw an exception

java.lang.NoClassDefFoundError: org/python/core/PyFile$Closer
	org.python.core.PyFile.file___init__(PyFile.java:151)
	org.python.core.PyFile$exposed___new__.createOfType(Unknown Source)
	org.python.core.PyOverridableNew.new_impl(PyOverridableNew.java:12)
	org.python.core.PyType.invokeNew(PyType.java:466)
	org.python.core.PyType.type___call__(PyType.java:1558)
	org.python.core.PyType.__call__(PyType.java:1548)
	org.python.core.OpenFunction.__call__(__builtin__.java:1564)
	org.python.core.PyObject.__call__(PyObject.java:387)
	org.python.core.PyObject.__call__(PyObject.java:391)
	org.python.pycode._pyx27.doPost$3(/work//tomcat/webapps/jythondemo/JythonServlet1.py:34)
	org.python.pycode._pyx27.call_function(/work/tomcat/webapps/jythondemo/JythonServlet1.py)

I also tried to put the statement within a try/except to track the error, but again a long backtrace. All I can see legible but not really understandable for me is:

javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/python/antlr/PythonParser$try_stmt_return
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/python/antlr/PythonParser$try_stmt_return

Why can't I open a file??

Regards,
Fernando


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk


_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users