NPE in SeamResourceServlet for delivering XML
mobazr Nov 10, 2008 12:05 PMHi,
I'm working on a class in order to deploy it as a SeamResourceServlet. It will be used to provide flash with xml data by receiving xml from the request, computing it and writing the manipulated xml back to the response.
@Scope(ScopeType.APPLICATION)
@Name("flashCommunicationResource")
public class FlashCommunicationResource extends AbstractResource {
//
// attributes
//
@Logger
private static Log logger;
@In(create = true, required = false)
private FlashController flashController;
@Override
public String getResourcePath() {
return "/myresource";
}
@Override
public void getResource(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
new ContextualHttpServletRequest(request) {
@Override
public void process() throws IOException {
doWork(request, response);
}
}.run();
}
private void doWork(HttpServletRequest request, HttpServletResponse response) {
InputStream instream = null;
OutputStream outstream = null;
try {
instream = request.getInputStream();
response.setContentType("text/xml");
outstream = response.getOutputStream();
logger.debug("type=" + type);
flashController.computeXmlInputAndWriteResult(instream, outstream);
outstream.flush();
outstream.close();
instream.close();
}
catch (IOException e) {
...
}
}
}
I checked the outstream by diverting it to System.out which looks perfect. But Seam crashes with the following NPE:
java.lang.NullPointerException
at org.jboss.seam.contexts.Contexts.destroy(Contexts.java:241)
at org.jboss.seam.contexts.Lifecycle.endCall(Lifecycle.java:95)
at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:122)
at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:166)
at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:102)
at ....FlashCommunicationResource_$$_javassist_1.getResource(FlashCommunicationResource_$$_javassist_1.java)
at org.jboss.seam.servlet.SeamResourceServlet.service(SeamResourceServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
....
I'm fairly new to seam. Any ideas?
Thanks allot in advance.
Manuel