Issue with Servlet connecting to Smartfox

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

ramachak
Posts: 2
Joined: 20 Jan 2009, 21:13

Issue with Servlet connecting to Smartfox

Postby ramachak » 12 Feb 2009, 23:19

I have a simple Java servlet that is trying to access an extension. I run this servlet inside the Jetty engine.

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = null;
try {
out = response.getWriter();
response.setContentType( "text/html" );
out.print("<html><head>");

Zone zone = SmartFoxServer.getInstance().getZone("test");
AbstractExtension targetExtension = zone.getExtension("TestExtension");
out.print("AbstractExtension:" + targetExtension);
Object sfs_res = (String) targetExtension.handleInternalRequest("Hello");
out.print("Server Res->" + sfs_res.toString());
}

But I get a null-pointer exception in SmartFoxServer.getInstance(). Line 29 below is the SmartFoxServer.getInstance().getZone("test");

Here is the stacktrace.
java.lang.NullPointerException at com.test..PerfMon.doGet(PerfMon.java:29) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:367) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:712) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:211) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:139) at org.mortbay.jetty.Server.handle(Server.java:285) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:502) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:821) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:208) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:378) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:368) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:442)

What is that I am going wrong. This is very close to the Interoperatability example in the manual, 6.11 Extension Interoperability

Thanks!

Kumar
User avatar
thomers1
Posts: 125
Joined: 13 Aug 2008, 07:36
Contact:

Postby thomers1 » 15 Feb 2009, 18:43

do other servlets running in jetty work?

try implementing a SnoopServlet like this one
http://www.devdaily.com/java/jwarehouse/jakarta-tomcat-3.3.2-src/src/examples/WEB-INF/classes/SnoopServlet.java.shtml

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 32 guests