problem with @SipApplicationKey method

54 views
Skip to first unread message

Eric Cheung

unread,
May 15, 2009, 8:18:18 AM5/15/09
to mobicents-public
Hi

We are running into this issue in ECharts for SIP Servlet. E4SS
define the @SAK method in EChartsSipServlet.java. When the
application is loaded, EChartsSipServlet.init() is called and certain
static fields of the class are initialized. However, when an initial
request comes in and @SAK method is called, these fields are not
initialized. For example:

public class EChartsSipServlet extends SipServlet {
private static boolean staticField;

@SipApplicationKey
public static String sipApplicationKey(SipServletRequest req) {
// Access staticField
...
}

public void init(ServletConfig sc) throws ServletException {
...
staticField = true;
...
}
}

From the @SAK method, staticField is not set to true. I suspect the
regular servlet is instantiated in one classloader and init() called
in this classloader, but the @SAK method is called in a second
classloader?

This is observed on apache-tomcat-6.0.14-0905110932.

Thanks
Eric

Jean Deruelle

unread,
May 15, 2009, 8:57:09 AM5/15/09
to mobicent...@googlegroups.com
Hi eric,

I added a non regression test to our testsuite but could not reproduce the problem. See http://code.google.com/p/mobicents/source/detail?r=5993
Would you be kind to provide a sandboxed application reproducing the problem so that I can take a better look at what's going on ?

Thanks in advance
Best regards
Jean

Vladimir Ralev

unread,
May 15, 2009, 9:17:06 AM5/15/09
to mobicent...@googlegroups.com
It's possible that embedded tomcat (in the testsuite) has different CL mechanism than the real tomcat, at least for JBoss and Tomcat it is different.

Jean Deruelle

unread,
May 15, 2009, 11:06:18 AM5/15/09
to mobicent...@googlegroups.com
Indeed. I just tried the application from the testsuite in a standalone tomcat and I reproduced the issue.
You can track it here :
http://code.google.com/p/mobicents/issues/detail?id=700

Jean Deruelle

unread,
May 15, 2009, 11:55:19 AM5/15/09
to mobicent...@googlegroups.com
I committed a fix. Please verify either from trunk or watch for build 368 from http://hudson.jboss.org/hudson/job/MobicentsSipServletsRelease/

Thanks for the bug report
Jean

Jean Deruelle

unread,
May 16, 2009, 2:58:50 AM5/16/09
to mobicent...@googlegroups.com
Binary snapshot containing the fix available here http://hudson.jboss.org/hudson/job/MobicentsSipServletsRelease/368/ for you to test

Eric Cheung

unread,
May 16, 2009, 11:44:54 AM5/16/09
to mobicents-public
Hi Jean, thanks for the quick response on this. I will test this later
today.
Thanks
Eric

Eric Cheung

unread,
May 18, 2009, 4:29:40 AM5/18/09
to mobicents-public
Hi Jean

I see that the classloader behavior is changed from mss-
tomcat-6.0.14-0905110932 to mss-tomcat-6.0.14-0905151758. In the
newer build init() and @SAK are called in the same current and context
classloader. However, I am still having problem. The static set by
init() is not seen by @SAK. I don't understand how that can be.

I will see if I can reproduce the problem with a simple SipServlet
class.

Thanks
Eric

Jean Deruelle

unread,
May 18, 2009, 8:43:27 AM5/18/09
to mobicent...@googlegroups.com
If you can share your application I can try it locally to debug and see what's going on.
I tried with the chat room application located here http://mobicents.googlecode.com/svn/trunk/servers/sip-servlets/sip-servlets-test-suite/applications/chatroom-sip-servlet/ and it works for me. Alternatively can you try the chat room application to see if you see the same problem ? (that might help by comparing the source code to narrow down the issue.)


Thanks in advance
Best regards
Jean

Eric Cheung

unread,
May 20, 2009, 9:15:56 AM5/20/09
to mobicents-public
Hi Jean

I tried your ChatRoomSipServlet.java on my setup and I do not see the
problem. I compared the source with our code (EChartsSipServlet.java)
and could not see any material differences.

The source for our servlet is in
http://echarts.svn.sourceforge.net/viewvc/echarts/trunk/EChartsSipServlet/src/org/echarts/servlet/sip/EChartsSipServlet.java

This is then packaged in a jar, and included in WEB-INF/lib in the
busyRejector application (for source see
http://echarts.svn.sourceforge.net/viewvc/echarts/trunk/EChartsSipServlet/features/busyRejector/)

I am suspect the way EChartsSipServlet is packaged in the war file is
what the difference is. Then I tried a simplified version of
ChatRoomSipServlet.java, but this time packaged in a jar and then
included in a war file. The behavior is different --- the @SAK method
is not even called in this case.

It is strange that this is yet a different behavior, but perhaps this
can offer a clue?

I will attach the war file and source in the next email.

Thanks
Eric

Eric Cheung

unread,
May 20, 2009, 9:20:03 AM5/20/09
to mobicents-public
Here is the war file and the source Java file.

Thanks
Eric
EChartsSipServlet.java
busyRejectorTest.war

Jean Deruelle

unread,
May 20, 2009, 10:33:34 AM5/20/09
to mobicent...@googlegroups.com
OK, I will look into it. Thanks for the extra insight.
Since tomorrow and the day after is a national holiday here in france, I might have some delay in checking it out.

Jean

Jean Deruelle

unread,
May 20, 2009, 11:45:33 AM5/20/09
to mobicent...@googlegroups.com
Issue confirmed : http://code.google.com/p/mobicents/issues/detail?id=712
The Scanner for annotations does not process correctly the annotations located in jars within WEB-INF/lib

Jean Deruelle

unread,
May 20, 2009, 3:18:47 PM5/20/09
to mobicent...@googlegroups.com
OK I fixed it in http://hudson.jboss.org/hudson/view/Mobicents/job/MobicentsSipServletsRelease/373/

Could you retry and verify on your side, both with the custom app you provided in a previous mail (this one works for me) and with the full echarts one ?
The fix will only take care of the processing of sip annotations in jars located WEB-INF/lib so not sure this will completely fix your problem yet but at least this allow for incremental progress in this issue.

Thanks in any case for the excellent reports
Jean

Jean Deruelle

unread,
May 29, 2009, 2:43:25 AM5/29/09
to mobicent...@googlegroups.com
Hi Eric,

Have you been able to try it out ?


Thanks in advance
Best regards
Jean

Eric Cheung

unread,
Jun 8, 2009, 5:47:35 PM6/8/09
to mobicents-public
Hi Jean

Sorry for the delay. I was travelling and then on vacation so stopped
working on this for a while.

Before I went away, I tried out build 373 and ran into
NullPointerException when the app is deployed and scanned for
annotations. It was the same problem that Tom Smith ran into. Thanks
for the investigation that you and Tom did that problem seems to be
resolved.

I have now tested with the latest build 406. The app can now be
deployed successfully. I have also verified that the static fields
set by init() are now read correctly by the @SAK method.

So I think this problem is resolved. Thanks very much for your help.
I can now continue testing the E4SS busyRejector app on MSS.

Thanks
Eric

Eric Cheung

unread,
Jun 8, 2009, 10:42:24 PM6/8/09
to mobicents-public
I am running into the next problem related to the @SipApplicationKey
method. It seems SipServletRequest.getSubscriberURI() method returns
null when called from inside the @SAK method. However, when the
container subsequently calls the doInvite() method, getSubscriberURI()
returns the correct value.

e.g.

@SipApplicationKey
public static String sipApplicationKey(SipServletRequest req) {
URI subscriberURI = req.getSubscriberURI();
// in MSS, this returns null.
returns subscriberURI.toString();
}

public void doInvite(SipServletRequest req) {
URI subscriberURI = req.getSubscriberURI();
// This returns the correct value
...
}

This is a problem because in many cases, the subscriber URI is a good
key to use.

Thanks
Eric

Jean Deruelle

unread,
Jun 9, 2009, 3:15:32 AM6/9/09
to mobicent...@googlegroups.com
Thanks for the update Eric and for the new bug report : http://code.google.com/p/mobicents/issues/detail?id=750

Jean Deruelle

unread,
Jun 9, 2009, 7:01:08 AM6/9/09
to mobicent...@googlegroups.com

Eric Cheung

unread,
Jun 11, 2009, 9:19:19 PM6/11/09
to mobicents-public
Hi Jean

I tested with build 420 and all the issues related to
@SipApplicationKey are resolved now. All my tests against the
busyRejector app pass.

Thanks very much for your help!

Thanks
Eric

Jean Deruelle

unread,
Jun 12, 2009, 1:30:53 AM6/12/09
to mobicent...@googlegroups.com
Excellent !

Thank you very much to you for all the excellent bug reports and extra testing :-)

Jean
Reply all
Reply to author
Forward
0 new messages