powered by Jive Software

[Urgent] Cannot add IQHandler to the IQRouter!

Hi, I created a class extending IQHandler, then in my initializePlugin method I have the following code:

listener = new MyIQListener(“My own IQ”);
IQRouter iqRouter = XMPPServer.getInstance().getIQRouter();
iqRouter.addHandler(listener) // this line causes the error

System.out.println(“Plugin correctly initialized”);

Strangely, if the 3rd line is not present everything works correctly and I got the “Plugin correctly initialized” on server console, if I add that line (I add my listener to IQRouter) plugin does not start!!!

I think problem could be in the IQListener constructor…I really do pass the string “My own IQ”, maybe you have to pass some special kind of string?

I’m not aware of any issue that causes the name of the Handler to be relevant. Without the implementation of your specific IQHandler, its hard to tell what’s going wrong. Did you try debugging your code, stepping through each line? Have a look at any of the other IQHandler implementations (Openfire contains a couple). Compare those classes with yours - perhaps something pops out.

On a side note: Perhaps you could consider not using an IQHandler, but a Component instead. The semantics are a bit different, but Components are more generic in nature and often more easy to work with.

Found the problem: I didn’t implement the method getInfo(): it seems this method is used by Openfire to correctly initialize plugin!:slight_smile: