Tomcat+XMPPServer.getInstance();

Hi…

I’'m trying understand how to use the following code line:

//////////////////////////////////////////////////////////////////////////////

XMPPServer server = XMPPServer.getInstance();

//////////////////////////////////////////////////////////////////////////////

if i start messenger using messenger.exe in Windows, is it possible to get this instance in a servlet running under Tomcat using the code line above?

Thanks

Alex

Hi Alex,

No, that line will create a seperate instance of the XMPPServer inside your servlet. Maybe if you describe what you’'re trying to do someone can offer a solution to you.

Thanks,

Ryan

Hi Ryan,

First, thanks for your reply…

I’'d like to know how to use the messenger API in a servlet[/b] running on tomcat:

I’‘ve managed to launch the messenger using a standalone java classes, but I didn’'t manage to do it in a servlet.

In fact, the aim would be to manage users session directly, (changing their password at each connection…) in my web application using the messenger API (XMPPServer object for example…)

When I try to do : XMPPSrever server = new XMPPServer() : it works correctly in standalone, but it throws exception when I do it in a servlet : the admin console cannot start and I obtain a ClassCastException on a logger class (I dont understand : see my post of july 23 about this ClassCastException : i’'ve pasted the stackstrace with some details…)

I’‘ve spent 3 days looking for an answer on the forum, and everywhere, but no success : i don’'t understand where this error may come from and how to solve it…

Please, Ryan, if you could help me, that would be so cool…

Please help me

PS: sorry for my poor english: I’'m from Paris (France)…

How can I do?

Thanks in advance…

Alex

Hi,

In order to use JM in your context, you have a few options.

  1. run JM standalone and use SMACK api to send messages to JM from your web application. This will allow/limit you to functionality of a XMPP client.

  2. run JM in Tomcat. You will have make a “war” deployable release of JM. This is not available out of the box so you will have to build it yourself using JM ant build script. The ant target is called war. Have a look at this thread from dev forum:

http://www.jivesoftware.org/forums/thread.jspa?messageID=100307&#100307 it goes into some detail on running JM in tomcat.

Option 2 is closer to what you want, so I would try getting that to work first. After that you are in new ground.

Things to note are, the set of JM classes are designed to work on a single JVM, this is why you cannot connect to the standalone JM using the JM classes. If you want to create your own web front end, and make a deployable WAR you will have to replicate/replace the startup details as outlined in the thread above.

Hope that helps,

Conor.

Hi Conor,

Thanks for your reply, I think it will be very helpfull…

I’‘m a Java developper and I’'m working with Ant and Eclipse everyday in my job, then I think I should manage to build and package the JM in a war to do what I hope to do in my personal project…

I’‘ll try your method today and I’'ll give you feedback and informations as soon as I can…

Thanks again for your help…

Alex

@see thread: http://www.jivesoftware.org/forums/thread.jspa?threadID=15265&tstart=0