Uncommented Bytes

Tuesday, July 22, 2008

Custom servlet in Openfire plugin

I've been working on creating a plugin for our Openfire server, which is currently on version 3.3.3. The Plugin developer guide is a little help, and so are the message boards, but there is still some detail missing.

Situation: I want to have a custom servlet that is available on the same url:port as our admin server. I don't want to have to login to the admin server to reach this url, and the output from this servlet should not be wrapped by the openfire sitemesh template.

First, I registered the servlet in a web-custom.xml, but I could not get my servlet to appear. I had a url like http://localhost:9090/plugins/myplugin/CustomServlet. I couldn't find an answer on the message boards so I pulled down the source and started debugging. Turns out that the PluginServlet class does a toLower on the servlet url. So changing the url pattern from /CustomServlet to /customservlet in the web-custom.xml fixed the problem.

Next, to remove the security for hitting the servlet, I used the information from this post. Adding AuthCheckFilter.addExclude("CustomServlet") to the initializePlugin method fixed it up.

Lastly, as mentioned here and here, adding <meta name='decorator' content='none'/> tells sitemesh to not use the normal openfire template.

Hopefully this info will help me remember this stuff down the line...


  • I would like to try out your custom servlet. I am also developing a plugin and I would like to see how your servlet uses the Plugin API.
    Would be grateful if you can provide me with a sample download that I can try out on Openfire

    By Blogger Ilango, at 13 June, 2010 13:04  

  • It would be nice if you have a sample download available, so that I could test on my Openfire server.

    By Blogger Ilango, at 13 June, 2010 13:05  

  • Sorry, I haven't looked at Openfire in many many months. But you can use any simple Servlet for this example. It doesn't really matter what the servlet does.

    By Blogger Jeff Sheets, at 14 June, 2010 22:33  

Post a Comment

<< Home