XMPPBootServlet is useless inside an appserver

It is seen that messenger is designed to run inside jetty with a seperate VM. But its not the case for enterprise systems. BootServlet is useless since one cannot undeploy war because it simply doesn’'t shutdown server.

Correct approach is a ServletContextListener as servlet spec says. Here it is:

evrim@evrim ~/workspace/messenger/src/java/org/jivesoftware/messenger $ cat XMPPContextListener.java

package org.jivesoftware.messenger;

import javax.servlet.ServletContextEvent;

import javax.servlet.ServletContextListener;

public class XMPPContextListener implements ServletContextListener {

protected String XMPP_KEY = “XMPP_SERVER”;

public void contextInitialized(ServletContextEvent event) {

XMPPServer server = new XMPPServer();

event.getServletContext().setAttribute(XMPP_KEY, server);

}

public void contextDestroyed(ServletContextEvent event) {

XMPPServer server = (XMPPServer) event.getServletContext().getAttribute(XMPP_KEY);

if (null != server) {

server.stop();

}

}

}[/code]

To enable a context listener (as everybody knows), first disable XMPPBootServlet from web.xml:

[/code]

Ok, this listener uses XMPPServer.stop() method to stop the server but it seems it doesn’'t because it works only if its standalone. Here is the patch for stop() method:

diff

@@ -444,6 +444,18 @@

shutdownThread.setDaemon(true);

shutdownThread.start();

}

  •    } else {
    
  •           /* If stop() is called, you have to close listening socket
    
  •            * no matter what the condition is in order to be able
    
  •            * to be restartable inside a container.
    
  •            *
    
  •            * Shutdownhook thread obviosuly won''t work in appserver
    
  •            * since VM is not closing.
    
  •            *
    
  •            * /evrim_at_core.gen.tr
    
  •            */
    
  •           shutdownServer();
    
  •        stopDate = new Date();
    

}

}[/code]

Unfortunately, I can’‘t put my code into pre tags. Forum is not a correct way to post these patches but i don’'t have any alternative since JIRA is closed to visitors. Shame on you JIVE#2!

Have a nice day.

dont want to sound rude, just thinking if such threads are more fit in Jive Messenger Dev forum?

yes, a moderator may move it to dev-forum. i was unaware of dev-forum while posting it.

Evrim,

Interesting – this seems like it would be a good replacement for XMPPBootServlet in general. Would you agree?

On having JIRA closed – unfortunately, we found this to be necessary so that we could control the reporting of bugs a bit better.

Regards,

Matt

yes, a moderator may move it to dev-forum. i was

unaware of dev-forum while posting it.

Note: I moved the thread obviously.

-Matt

Yes, it’‘ll be better, thnx btw moving thread to dev:) I’'ve also provided jbossprovider for authentication if somebody is interested. It requires jboss specific libraries though:(

I’'ve also provided jbossprovider for authentication

if somebody is interested. It requires jboss specific

libraries though:(

Sounds very interesting! Would you be willing to create a knowledge base document about making Jive Messenger work with JBoss? You could then have the authentication code as an attachment to the kbase document. If this sounds like something you’‘d be interested in, I’'ll grant you permission to post new Knowledge Base documents.

Regards,

Matt

I’'ve filed a new issue: JM-424 for this request.

Regards,

Matt

Hey guys,

The suggested improvement has been incorporated. Thanks.

– Gato

Just wanted to add that in my initial testing on JBoss 4.0.3, the new code works great so far!

Thanks again, Gato!