Can''t get the current chatroom from message filter

Hi all

I wrote a plugin that filters the specific outgoing messages.

Once the user enters some key words, then the text of the transcription window will be recoreded.

The below is parts of my plugin.

I’'m sure that the plugin can be installed well.

And the message filter can be activated.

private void installMessageFilter() {

// Retrieve the ChatManager from SparkManager

final String JID = sm.getUsername();

MessageFilter messageFilter = new MessageFilter() {

public void filterOutgoing(final Message message) {

String currentBody = message.getBody();


int answer = JOptionPane.showConfirmDialog(null, “Record the former messages?”, “Record the former messages?”, JOptionPane.YES_NO_OPTION);

if(answer == 0){

ChatRoom room = chatManager.getChatRoom(sm.getJID()).getChatRoom();

And the below is the debugging log:

Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException

at com.jivesoftware.spark.ChatManager.getChatRoom(

at com.jivesoftware.ssm.Ssm$1.filterOutgoing(

at com.jivesoftware.spark.ChatManager.filterOutgoingMessage(

at com.jivesoftware.spark.ui.rooms.ChatRoomImpl.sendMessage(

at com.jivesoftware.spark.ui.rooms.ChatRoomImpl.sendMessage(

at com.jivesoftware.spark.ui.ChatRoom.checkForEnter(

at com.jivesoftware.spark.ui.ChatRoom.access$300(

at com.jivesoftware.spark.ui.ChatRoom$7.keyPressed(

at java.awt.Component.processKeyEvent(

It looks like the problem is going to be happened when I invoke the funcion: getChatRoom()

Please give some adivces.


You should check to see if the chatRoom exists and create a room based on the jid using chatManager.createChatRoom().