Send a Message from a component to a MUC-Room


i try to write a plugin for Openfire. With this Plugin i want to send Messages to MultiUserChatRooms (MUCRoom).

I have written this lines of code:

Message newMessage = new Message();
MultiUserChatService multiUserChatService = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService("conference");
MUCRoom chatRoom = multiUserChatService.getChatRoom(muc);
//To Jid
JID tojid = chatRoom.getJID();
//From Jid
String fromJid = serviceName+"."+componentManager.getServerName();
componentManager.sendPacket(this, newMessage);

This will send a Message like:

<message type="groupchat" to="muc@conference.test" from="component.test">
  <body>hello world</body>

The Problem is that the message will not send to the Chatroom.

But a Message is send back to my component:

<message type="error" to="component.test" from="muc@conference.test">
  <body>hello world</body>
  <error code="406" type="modify">
    <not-acceptable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>

How do you do it right?

In MUC, a NotAcceptable is raised when the user joining a room is not registered (or registered under a different nick name). Is your room protected? Is the JID of your component a member of the room?


So I change the code so that the Component will add himself as a member if it is not a member:

String fromJid = serviceName + “.” + componentManager.getServerName();

JID createJID = new JID(fromJid);

Collection members = chatRoom.getMembers();

… Check if component is member

if (!notMember) {

chatRoom.addMember(createJID, serviceName, chatRoom.getRole());


  1. I still get the same response. L

The last thing that you/Guus mentioned is that the Component has to join the room.

Therefore I found only one matching method:

joinRoom(String nickname, String password, HistoryRequest historyRequest, LocalMUCUser user, Presence presence)

But I have absolutely no idea what the right arguments are to call this method in particularly the user and the presence.

So I need help another time