Handling SIP and HTTP requests in the same server

93 views
Skip to first unread message

Chris Lauwers

unread,
Apr 22, 2013, 4:51:15 PM4/22/13
to cipang...@googlegroups.com
I'm building a server that handles both SIP and HTTP requests. I assume I'll need to instantiate both a SipServer object and a (Jetty) Server object. Is that possible? Are there any code examples that show how to do this correctly?

thanks,

Chris

Nicolas

unread,
Apr 23, 2013, 3:10:56 AM4/23/13
to cipang...@googlegroups.com
Chris,
This is possible, this is the case when Cipango distribution is used.

You could do it with the following code snippet:

SipServer sipServer = new SipServer();
Server server = new Server();
sipServer.setServer(server); // This will add sipServer as a Jetty
server bean

// TODO configure server and sip server

server.start(); // As SipServer is a bean, starting server will also
start sip server

Regards,
Nicolas

Le 22/04/2013 22:51, Chris Lauwers a �crit :

Chris Lauwers

unread,
Apr 23, 2013, 2:19:05 PM4/23/13
to cipang...@googlegroups.com
That seems to work, thanks.

However, I now have the following problem:

I create a new SipAppContext as follows:

sipContext = new SipAppContext();

which results in the following exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/Descriptor
at org.cipango.server.sipapp.SipAppContext.<init>(SipAppContext.java:163)
at com.ubicity.platform.Ubicity.<init>(Ubicity.java:59)
at com.ubicity.platform.Ubicity.main(Ubicity.java:90)

The offending code in the SipAppContext constructor seems to be:

_metaData = new MetaData();

However, since I'm using embedded Jetty, I don't have a webapp descriptor anywhere. Any suggestions for how to get around this?

Thanks,

Chris

-----Original Message-----
From: cipang...@googlegroups.com [mailto:cipang...@googlegroups.com] On Behalf Of Nicolas
Sent: Tuesday, April 23, 2013 12:11 AM
To: cipang...@googlegroups.com
Subject: Re: [cipango-users] Handling SIP and HTTP requests in the same server

Chris,
This is possible, this is the case when Cipango distribution is used.

You could do it with the following code snippet:

SipServer sipServer = new SipServer();
Server server = new Server();
sipServer.setServer(server); // This will add sipServer as a Jetty server bean

// TODO configure server and sip server

server.start(); // As SipServer is a bean, starting server will also start sip server

Regards,
Nicolas

Le 22/04/2013 22:51, Chris Lauwers a écrit :
> I'm building a server that handles both SIP and HTTP requests. I assume I'll need to instantiate both a SipServer object and a (Jetty) Server object. Is that possible? Are there any code examples that show how to do this correctly?
>
> thanks,
>
> Chris
>

--
You received this message because you are subscribed to the Google Groups "cipango-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cipango-user...@googlegroups.com.
To post to this group, send email to cipang...@googlegroups.com.
Visit this group at http://groups.google.com/group/cipango-users?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Chris Lauwers

unread,
Apr 23, 2013, 4:41:28 PM4/23/13
to cipang...@googlegroups.com
After looking at this some more, it appears that the SipAppContext is modeled after the WebAppContext, which assumes a web app deployment descriptor (I believe). However, in our embedded Jetty configuration, we don't use any deployment descriptors. We use a SipServletHolder instead of a WebAppContext to manage servlets, and we configure the SipServletHolder programmatically:

jettyServer = new Server(UBCT_DEFAULT_HTTP_PORT);

// Instantiate and initialize servlet container
context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath(UBCT_DEFAULT_CONTEXT_PATH);
context.setResourceBase(UBCT_DEFAULT_RESOURCE_BASE);

// Add servlets
context.addServlet(org.eclipse.jetty.servlet.DefaultServlet.class, UBCT_DEFAULT_CONTEXT_PATH);
context.addServlet(new ServletHolder(new UbicityServlet()), UBCT_ CONTEXT_PATH);

// Tie everything together
jettyServer.setHandler(context);

Two questions:

1. Is there a SIP equivalent to the ServletContextHandler, or do we need to use a SipAppContext
2. Is there a way to configure the SipAppContext programmatically and avoid the NullPointerException

Many thanks,

Nicolas

unread,
Apr 24, 2013, 2:56:57 AM4/24/13
to cipang...@googlegroups.com
Hi Chris,
There is no equivalent to ServletContextHandler in SIP.
What is the NullPointerException that you received ? In previous mail, it was a
NoClassDefFoundError (I think due to missing dependency
jetty-webapp-9.0.0.v20130308.jar).

Kind regards,
Nicolas

Le 23/04/2013 22:41, Chris Lauwers a �crit :
> Le 22/04/2013 22:51, Chris Lauwers a �crit :

Chris Lauwers

unread,
Apr 24, 2013, 1:12:49 PM4/24/13
to cipang...@googlegroups.com
Thanks Nicolas, adding the jetty-webapp dependency fixed the problem (I misspoke in my second email, I meant to refer to the NoClassDefFoundError).

I'm currently not using maven. We'll plan on adding maven support to avoid these kinds of issues in the future.

Thanks for your help,

Chris

-----Original Message-----
From: cipang...@googlegroups.com [mailto:cipang...@googlegroups.com] On Behalf Of Nicolas
Sent: Tuesday, April 23, 2013 11:57 PM
To: cipang...@googlegroups.com
Subject: Re: [cipango-users] Handling SIP and HTTP requests in the same server

Hi Chris,
There is no equivalent to ServletContextHandler in SIP.
What is the NullPointerException that you received ? In previous mail, it was a NoClassDefFoundError (I think due to missing dependency jetty-webapp-9.0.0.v20130308.jar).

Kind regards,
Nicolas

Reply all
Reply to author
Forward
0 new messages