Skip to main content

SocketException anomaluos behaviour

2 replies [Last post]
andmus82
Offline
Joined: 2009-06-01
Points: 0

Hi, my Sbb tries to connect to a server. If SocketException is thrown more times, my onPost method throws a NullPointerException. My code is the following:

while(count");
pw.flush();
count++;
}
if(count>max_att){
pw.write("service unavailable");
pw.flush();
}
}

response.flushBuffer();
}

The stack trace:

13:26:18,545 INFO [STDOUT] Exception: cannot connect with: google.it on port1
13:26:39,559 INFO [STDOUT] Exception: cannot connect with: google.it on port1
13:26:39,559 ERROR [EventRouterImpl] Failure while routing event; second phase. DeferredEvent [EventTypeID[net.java.slee.resource.http.events.incoming.request.POST#net.java.slee#1.0], #29]
java.lang.NullPointerException
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:737)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:299)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:963)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:95)
at panig.panigSbb.onPOSTEvent(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mobicents.slee.runtime.sbbentity.SbbEntity.invokeEventHandler(SbbEntity.java:871)
at org.mobicents.slee.runtime.EventRouterImpl.routeQueuedEvent(EventRouterImpl.java:892)
at org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:64)
at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:121)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
13:26:39,560 INFO [EventRouterImpl] Caught RuntimeException in invoking SLEE originated invocation
java.lang.NullPointerException
at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:737)
at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)
at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:299)
at org.apache.coyote.http11.Http11Processor.action(Http11Processor.java:963)
at org.apache.coyote.Response.action(Response.java:183)
at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:288)
at org.apache.catalina.connector.CoyoteWriter.flush(CoyoteWriter.java:95)
at panig.panigSbb.onPOSTEvent(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mobicents.slee.runtime.sbbentity.SbbEntity.invokeEventHandler(SbbEntity.java:871)
at org.mobicents.slee.runtime.EventRouterImpl.routeQueuedEvent(EventRouterImpl.java:892)
at org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:64)
at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:121)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Any suggest?
Andrea

Message was edited by: andmus82

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexandrem
Offline
Joined: 2005-10-19
Points: 0

Where and how is pw initialized? You should debug to see where that NPE comes from, I'm guessing it's the pw (PrintWriter).

Also, it's bad to create socket's in your SBB, that should be made in a resource adaptor, according to SLEE specs.

Alexandre Mendonca
JBoss R&D

andmus82
Offline
Joined: 2009-06-01
Points: 0

The PrintWriter is initialized before the while:

public void onGETEvent(net.java.slee.resource.http.events.HttpServletRequestEvent event, ActivityContextInterface aci) throws Exception{
HttpServletResponse resp = event.getResponse();
PrintWriter pw = resp.getWriter();
while...
...
}

I created a socket from sbb because i need a telnet connection. Does a telnet RA exist? Do i need to create a RA to solve this issue?
Thanks,
Andrea