githubw2015 / asmack

一个小的例子
https://github.com/githubw2015/asmack
Other
0 stars 0 forks source link

java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2 #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What are you doing to produce the error?

try {
    for (String service: MultiUserChat.getServiceNames(con)) {
    Log.i(TAG, "Service name: " + service);
                    //Get the list of rooms under this service
                    for (HostedRoom room: MultiUserChat.getHostedRooms(con,"")) {
                        Log.i(TAG, "\tName: " + room.getName());
                        Log.i(TAG, "\tRoom JID: " + room.getJid());
                        //Get the detail information on the room 
                        RoomInfo info = MultiUserChat.getRoomInfo(con, room.getJid());
                        Log.i(TAG, "\tDescription: " + info.getDescription());
                        Log.i(TAG, "\tOccupant: " + info.getOccupantsCount());
                        Log.i(TAG, "\tPassword: " + info.isPasswordProtected());
                    }
                }
            } catch (XMPPException e) {
                Log.e(TAG, e.getMessage(),e);
            }

What is the expected output?
Collection of Service name and Room List
What do you see instead? (Please attach a debug enabled logcat)
java.lang.ClassCastException: org.jivesoftware.smack.util.PacketParserUtils$2
    at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryManager.java:655)
    at org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryManager.java:619)
    at org.jivesoftware.smackx.muc.MultiUserChat.getServiceNames(MultiUserChat.java:251)
    at cz.jabbim.android.service.JabbimConnectionService$1.getRoomList(JabbimConnectionService.java:159)
    at cz.jabbim.android.Jabbim.doSelectedItem(Jabbim.java:370)
    at cz.jabbim.android.Jabbim.onOptionsItemSelected(Jabbim.java:350)
    at android.app.Activity.onMenuItemSelected(Activity.java:2195)
    at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
    at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
    at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
    at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
    at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
    at android.view.View$PerformClick.run(View.java:8816)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:123)
    at android.app.ActivityThread.main(ActivityThread.java:4627)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:521)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    at dalvik.system.NativeStart.main(Native Method)

What version of aSmack / Android / Device do you use?
asmack-jse-buddycloud-2010.12.11.jar
What server do you use? Is there a public server to reproduce the problem?

What else might help us to reproduce and hunt down the problem?

Original issue reported on code.google.com by jignesh....@gmail.com on 22 Dec 2010 at 10:57

GoogleCodeExporter commented 8 years ago
I have meet this question,is that a bug?I think...who can help ,thank you..

Original comment by zengqin...@gmail.com on 30 Mar 2011 at 10:07

GoogleCodeExporter commented 8 years ago
is any body can resolve?

Original comment by zengqin...@gmail.com on 31 Mar 2011 at 12:41

GoogleCodeExporter commented 8 years ago
I have meet this question too.

Original comment by todd...@gmail.com on 25 Apr 2011 at 8:58

GoogleCodeExporter commented 8 years ago
I have meet this question too.
----------------------
05-26 08:36:07.208: WARN/dalvikvm(1007): JNI WARNING: JNI method called with 
exception raised
05-26 08:36:07.208: WARN/dalvikvm(1007): in 
Landroid/webkit/WebViewCore;.nativeTouchUp (IIIII)V (NewGlobalRef)
05-26 08:36:07.208: WARN/dalvikvm(1007): Pending exception is:
05-26 08:36:07.218: INFO/dalvikvm(1007): Ljava/lang/ClassCastException;: 
org.jivesoftware.smack.util.PacketParserUtils$2
05-26 08:36:07.218: INFO/dalvikvm(1007): at 
org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryMa
nager.java:655)
05-26 08:36:07.228: INFO/dalvikvm(1007): at 
org.jivesoftware.smackx.ServiceDiscoveryManager.discoverItems(ServiceDiscoveryMa
nager.java:619)
05-26 08:36:07.228: INFO/dalvikvm(1007): at 
org.jivesoftware.smackx.muc.MultiUserChat.getHostedRooms(MultiUserChat.java:282)
05-26 08:36:07.249: INFO/dalvikvm(1007): at 
com.phonegap.plugin.xmpp.ChatRoomTabManager.getJoinedRooms(ChatRoomTabManager.ja
va:35)
05-26 08:36:07.249: INFO/dalvikvm(1007): at 
com.phonegap.plugin.XmppService.getChatRoomList(XmppService.java:128)
05-26 08:36:07.249: INFO/dalvikvm(1007): at 
android.webkit.WebViewCore.nativeTouchUp(Native Method)
05-26 08:36:07.258: INFO/dalvikvm(1007): at 
android.webkit.WebViewCore.nativeTouchUp(Native Method)
05-26 08:36:07.278: INFO/dalvikvm(1007): at 
android.webkit.WebViewCore.access$3300(WebViewCore.java:52)
05-26 08:36:07.278: INFO/dalvikvm(1007): at 
android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1150)
05-26 08:36:07.288: INFO/dalvikvm(1007): at 
android.os.Handler.dispatchMessage(Handler.java:99)
05-26 08:36:07.318: INFO/dalvikvm(1007): at 
android.os.Looper.loop(Looper.java:123)
05-26 08:36:07.318: INFO/dalvikvm(1007): at 
android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:621)
05-26 08:36:07.328: INFO/dalvikvm(1007): at 
java.lang.Thread.run(Thread.java:1096)
05-26 08:36:07.328: INFO/dalvikvm(1007): "WebViewCoreThread" prio=5 tid=7 NATIVE
----------------------------------------------------------------------------
code:
 android  client : asmack
 server:openfire

 public JSONArray getJoinedRooms(String userJID) {
          try {
           Collection<HostedRoom> rooms = MultiUserChat.getHostedRooms(con, "conference.zhongb-tdmcrglk");//static java.util.Collection<HostedRoom>
           /*for(Iterator<HostedRoom> hostedRoomIterator=rooms.iterator();hostedRoomIterator.hasNext();){
                Log.i(">>>", "hostRooms("+")="+hostedRoomIterator.next());
           }*/
               Iterator it = rooms.iterator();
              if(rooms.size() > 0)
              {
                while(it.hasNext())
                    {
                        HostedRoom roomName = (HostedRoom) it.next();
                        MultiUserChat muc = new MultiUserChat(con,roomName.getName());
                        //After creating a new MultiUserChat and before requesting its owners you need to join the room. Use #join(String nickname) or any of the other #joins messages available. We probably need to enhance Smack to throw an IllegalStateException if you try to use a MultiUserChat before actually joining a room.
                        //Collection collection = muc.getOwners(); //error thrown here.
                    }
              }
        } catch (XMPPException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
  JSONArray joinedRoomsList = new JSONArray();
  //----------- .....
       return  joinedRoomsList ;
}

Original comment by liu0198...@gmail.com on 26 May 2011 at 8:49

GoogleCodeExporter commented 8 years ago
I had the same problem and the solution suggested at 
http://community.igniterealtime.org/message/201866#201866 solves the matter.

It has to do with having to add all the ExtensionProviders to the 
ProviderManager explicitly.

Original comment by chimpooc...@gmail.com on 20 Jun 2011 at 9:35