I am trying to create Multi user chat group from App Server(TOMCAT),I have created a XMPP bot in a servlet.
As per my requirement i have to create a Multiuser Chat group from App server(using xmpp bot on app server),and join user from android app.
Creation of Multi user chat group and joining user from Android(using aSmack)works just fine,when i try to do same thing on appServer(TOMCAT),i am getting error,
At first when I try to create MUC i was getting "Can't create a multi user chat (MUC) room with aSmack library for Android: “packet.DefaultPacketExtension cannot be cast to packet.MUCUser”,
When i searched on SO i found POST in which @FLOW has mention reson for this error which is
org.jivesoftware.smack.packet.DefaultPacketExtension cannot be cast to org.jivesoftware.smackx.packet.MUCUser is usually an indicator that you didn't initialized the static code of aSmack that takes care of registering the Smack providers for the various packet (and packet extension) classes of Smack. For most aSmack versions, simply calling
SmackAndroid.init(Context ctx)
will do the trick.
There is no such method in core Smack package which takes care of registering the Smack providers for the various packet (and packet extension) classes of Smack.
So i have manually configure provide using configure(ProviderManager pm) method on this link
Now after configuring provider everything should be working fine but still i am unable to create MUC group
My code is as below
SmackConfiguration.setPacketReplyTimeout(packetReplyTimeout);
if(service != null)
config = new ConnectionConfiguration(server, port, service);
else
config = new ConnectionConfiguration(server, port);
config.setSASLAuthenticationEnabled(true);
config.setSecurityMode(SecurityMode.disabled);
config.setDebuggerEnabled(true);
connection = new XMPPConnection(config);
connection.connect();
System.out.println("Connected: " + connection.isConnected());
chatManager = connection.getChatManager();
messageListener = new MyMessageListener();
if (connection!=null && connection.isConnected()) {
configure(ProviderManager.getInstance());
connection.login(username, password);
}
MultiUserChat muc = new MultiUserChat(connection, "1234567@conference.localhost");
muc.create("Jonny");
Form form = muc.getConfigurationForm();
Form submitForm = form.createAnswerForm();
for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
FormField field = (FormField) fields.next();
if (!FormField.TYPE_HIDDEN.equals(field.getType())
&& field.getVariable() != null) {
// show("field: " + field.getVariable());
// Sets the default value as the answer
submitForm.setDefaultAnswer(field.getVariable());
}
}
List<String> owners = new ArrayList<String>();
owners.add(xmppManager.getXmppConnection().getUser());
submitForm.setAnswer("muc#roomconfig_roomowners", owners);
//submitForm.setAnswer("muc#roomconfig_roomname", );
submitForm.setAnswer("muc#roomconfig_persistentroom", true);
muc.sendConfigurationForm(submitForm);
muc.join(MucNick);
muc.sendMessage("hello everybody");
muc.addMessageListener(
new PacketListener() {
@Override
public void processPacket(Packet packet) {
message = (Message) packet;
if (message.getBody() != null) {
String fromName = StringUtils.parseBareAddress(message
.getFrom());
System.out.println("andro xmpp client"+ "Text Recieved--" + message.getBody()
+ " from " + fromName );
//messages.add(fromName + ":");
//messages.add(message.getBody());
//infobox.append("message arrieved "+" from::"+message.getFrom()+"__"+message.getBody());
// Add the incoming message to the list view
//Log.i("andro xmpp client","group messages__"+ messages.toString());
}
}
}
);
here is Stack Trace::
Exception in thread "Smack Packet Reader (0)" java.lang.NoSuchMethodError: org.jivesoftware.smack.util.StringUtils.parseDate(Ljava/lang/String;)Ljava/util/Date;
at org.jivesoftware.smackx.provider.DelayInformationProvider.parseExtension(DelayInformationProvider.java:45)
at org.jivesoftware.smack.util.PacketParserUtils.parsePacketExtension(PacketParserUtils.java:768)
at org.jivesoftware.smack.util.PacketParserUtils.parsePresence(PacketParserUtils.java:248)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:232)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:43)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:70)
No response from server.:
at org.jivesoftware.smackx.muc.MultiUserChat.create(MultiUserChat.java:367)
at com.sentiinel.egovern.testcase1.testing2.createMUC(testing2.java:510)
at com.sentiinel.egovern.testcase1.testing2.insertRequest(testing2.java:303)
at com.sentiinel.egovern.testcase1.testing2.doPost(testing2.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.sentiinel.filter.AuthenticationFilter.doFilter(AuthenticationFilter.java:115)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Any help with above problem will be really helpful
Thanks in advance!!!