JPython servlet problem

Amund Tveit amundt at pvv.org
Tue Mar 14 20:37:16 CET 2000


Hi,

I'm not able to get my jpython servlet to work, when
I try to run it I get an exception (as shown below)

At http://www.python.org/pipermail/jpython-interest/1998-May/000286.html
I found some wrapper-code, but it doesn't say how to use python-based
class-files directly as servlets, which is what I want.

Can anyone help me? Am I doing something stupid? :)

My system config is:
OS:             WinNT 4.0
Servlet-server: Tomcat/djakarta
Web-server:     Apache 1.3.9
Java:           JDK 1.3beta
Python:         JPython 1.1beta4

(To create the servlet class-file I use jpythonc) 

---- Exception error

Error: 500
Internal Servlet Error:

java.lang.NullPointerException
	at java.util.Hashtable.put(Hashtable.java:381)
	at org.python.core.Py.initProperties(Py.java:575)
	at org.python.core.Py.initProxy(Py.java:596)
	at PythonTestName.(PythonTestName.java:131)
	at java.lang.Class.newInstance0(Native Method)
	at java.lang.Class.newInstance(Class.java:241)
	at org.apache.tomcat.core.ServletWrapper.loadServlet(ServletWrapper.java:266)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:337)
	at org.apache.tomcat.core.InvokerServlet.service(InvokerServlet.java:239)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at org.apache.tomcat.core.ServiceInvocationHandler.method(ServletWrapper.java:626)
	at org.apache.tomcat.core.ServletWrapper.handleInvocation(ServletWrapper.java:534)
	at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:378)
	at org.apache.tomcat.core.Context.handleRequest(Context.java:644)
	at org.apache.tomcat.core.ContextManager.service(ContextManager.java:440)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:144)
	at org.apache.tomcat.service.TcpConnectionThread.run(TcpEndpoint.java:304)
	at java.lang.Thread.run(Thread.java:479)

---- Servlet code (PythonTestName.py)

import sys
sys.add_package("javax.servlet.http")

from javax.servlet.http import HttpServlet
from java import io

class PythonTestName(HttpServlet):
    def service(request, response):
        res.setContentType("text/html");
        out = res.getWriter();
        out.println("<html><body>");
        out.println("<h1>JServlet test!</h1>");
        out.println("</body></html>");
-----------------

Thanks,

Amund
---
Amund Tveit        - www.agentus.com
amundt at agentus.com 




More information about the Python-list mailing list