Hi,
I am developing a small servlet which echoes back whatever message is sent to it. the doMessage is getting called but while creating a new request an exception occurs. The exception is
[#|2007-08-18T12:12:30.640+0530|SEVERE|sun-appserver9.1|SipContainer|_ThreadID=23;_ThreadName=pool-3-thread-4;_RequestID=11c4ceaa-4b29-454d-95a3-4645d23339f6;|Exception allocating servlet
java.lang.IllegalStateException: Not allowed to create a request.
at com.ericsson.ssa.sip.SipSessionDialogImpl.createRequest(SipSessionDialogImpl.java:447)
at EchoServlet.doMessage(EchoServlet.java:85)
at javax.servlet.sip.SipServlet.doRequest(SipServlet.java:65)
at javax.servlet.sip.SipServlet.service(SipServlet.java:39)
at com.ericsson.ssa.container.sim.SipServletFacade.service(SipServletFacade.java:76)
at com.ericsson.ssa.container.sim.SipServletWrapper.invokeServlet(SipServletWrapper.java:105)
at com.ericsson.ssa.container.sim.ServletDispatcher.invoke(ServletDispatcher.java:214)
at com.ericsson.ssa.container.sim.ApplicationDispatcher.invokeServletDispatchers(ApplicationDispatcher.java:249)
at com.ericsson.ssa.container.sim.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:203)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:53)
at com.ericsson.ssa.container.sim.ApplicationDispatcher.next(ApplicationDispatcher.java:429)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:61)
at com.ericsson.ssa.sip.SessionManager.next(SessionManager.java:330)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:61)
at com.ericsson.ssa.sip.dns.ResolverManager.next(ResolverManager.java:178)
at com.ericsson.ssa.sip.LayerHelper.next(LayerHelper.java:61)
at com.ericsson.ssa.sip.transaction.TransactionManager.invokeCreatedOrFetchedServerTransaction(TransactionManager.java:185)
at com.ericsson.ssa.sip.transaction.TransactionManager.next(TransactionManager.java:235)
at com.ericsson.ssa.container.LinkBase.processMessage(LinkBase.java:475)
at com.ericsson.ssa.container.LinkBase.handleMessage(LinkBase.java:453)
at com.ericsson.ssa.container.UDPListener.run(UDPListener.java:162)
at com.ericsson.ssa.container.SipContainerThreadPool$MyRunnable.run(SipContainerThreadPool.java:114)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:65)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:168)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
The code is
protected void doMessage(SipServletRequest req) throws IOException, ServletException {
SipURI uri = null;
synchronized (_addresses) {
// Get the previous registered address for the sender.
uri = (SipURI) _addresses.get(req.getFrom().getURI().toString().toLowerCase());
}
if (uri == null) {
// Reject the message if it is not from a registered user.
req.createResponse(SipServletResponse.SC_FORBIDDEN).send();
return;
}
SipURI to = (SipURI)req.getTo().getURI();
// ID for the hashmap is based on user_at_host
StringBuilder id = new StringBuilder(to.getUser());
id.append('@');
id.append(to.getHost());
String key = id.toString();
synchronized( key ) {
// We accept the instant message by returning 200 OK response.
SipServletResponse resp = req.createResponse(SipServletResponse.SC_OK);
resp.send();
SipSession s = resp.getSession();
// Create an echo SIP MESSAGE request with the same content.
SipServletRequest echo = s.createRequest("MESSAGE");
String charset = req.getCharacterEncoding();
if (charset != null) {
echo.setCharacterEncoding(charset);
}
echo.setRequestURI(uri);
echo.setContent(req.getContent(), req.getContentType());
// Send the echo MESSAGE request back to Windows Messenger.
echo.send();
}
}
Plz help me to solve this error.Thanks in advance.
[Message sent by forum member 'abhishekdharwadkar' (abhishekdharwadkar)]
http://forums.java.net/jive/thread.jspa?messageID=231469