powered by Jive Software

How to create persistent MUC?


I’m trying to create persistent MUC room (stored in database).

MultiUserChat muChat = new MultiUserChat(conn, roomJid);


Form form = new Form(Form.TYPE_SUBMIT);

form.setAnswer(“muc#roomconfig_persistentroom”, true);



With that I’ve got an exception:

java.lang.IllegalArgumentException: Field not found for the specified variable name.

at org.jivesoftware.smackx.Form.setAnswer(Form.java:253)

What am I doing wrong?

You need to use the correct answer form which can be obtained by

// Get the the room’s configuration form

Form form = muc.getConfigurationForm();

// Create a new form to submit based on the original form

Form submitForm = form.createAnswerForm();

before using setAnswer()

See also: http://www.igniterealtime.org/builds/smack/docs/latest/documentation/extensions/ muc.html#create

1 Like

To use setAnswer() you have to actually get the form, not create it yourself.

Check the documentation on form usage.

1 Like