将Xmpp聊天应用程序与服务器连接时出现异常

时间:2012-07-23 06:30:51

标签: connection xmpp

我的代码是

try {
ConnectionConfiguration connConfig = new ConnectionConfiguration(hostname, portno, "");
                 conn = new XMPPConnection(connConfig);
                conn.connect();
                } 
            catch (XMPPException e)
            {
                throw new ProtocolException(e.toString());
            }

如何解决此问题?

  

07-23 11:54:08.126:W / dalvikvm(19805):VFY:无法解决静态问题   方法3144:Ljavax / swing / SwingUtilities; .invokeLater   (Ljava / lang / Runnable;)V 07-23 11:54:08.126:D / dalvikvm(19805):VFY:   替换操作码0x71在0x0006 07-23 11:54:08.126:D / dalvikvm(19805):   VFY:死代码0x0009-0009 in   Lorg / jivesoftware / smackx /调试器/ EnhancedDebugger; .userHasLogged   (Ljava / lang / String;)V 07-23 11:54:09.507:W / System.err(19805):   java.lang.reflect.InvocationTargetException 07-23 11:54:09.517:   W / System.err(19805):at   java.lang.reflect.Constructor.constructNative(Native Method)07-23   11:54:09.517:W / System.err(19805):at   java.lang.reflect.Constructor.newInstance(Constructor.java:415)07-23   11:54:09.527:W / System.err(19805):at   org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:1027)   07-23 11:54:09.527:W / System.err(19805):at   org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:850)   07-23 11:54:09.547:W / System.err(19805):at   org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:834)   07-23 11:54:09.577:W / System.err(19805):at   org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1276)   07-23 11:54:09.607:W / System.err(19805):at   com.src.protocol.XMPPProtocolManager.connect(XMPPProtocolManager.java:116)   07-23 11:54:09.607:W / System.err(19805):at   com.src.screen.Login.onClick(Login.java:80)07-23 11:54:09.607:   W / System.err(19805):at   android.view.View.performClick(View.java:2532)07-23 11:54:09.607:   W / System.err(19805):at   android.view.View $ PerformClick.run(View.java:9293)07-23 11:54:09.617:   W / System.err(19805):at   android.os.Handler.handleCallback(Handler.java:587)07-23   11:54:09.617:W / System.err(19805):at   android.os.Handler.dispatchMessage(Handler.java:92)07-23   11:54:09.627:W / System.err(19805):at   android.os.Looper.loop(Looper.java:150)07-23 11:54:09.627:   W / System.err(19805):at   android.app.ActivityThread.main(ActivityThread.java:4310)07-23   11:54:09.637:W / System.err(19805):at   java.lang.reflect.Method.invokeNative(Native Method)07-23   11:54:09.637:W / System.err(19805):at   java.lang.reflect.Method.invoke(Method.java:507)07-23 11:54:09.647:   W / System.err(19805):at   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)   07-23 11:54:09.647:W / System.err(19805):at   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)07-23   11:54:09.657:W / System.err(19805):at   dalvik.system.NativeStart.main(Native Method)07-23 11:54:09.657:   W / System.err(19805):引起:java.lang.NoClassDefFoundError:   javax.swing.JTabbedPane 07-23 11:54:09.667:W / System.err(19805):at   org.jivesoftware.smackx.debugger.EnhancedDebugger.createDebug(EnhancedDebugger.java:158)   07-23 11:54:09.667:W / System.err(19805):at   org.jivesoftware.smackx.debugger.EnhancedDebugger。(EnhancedDebugger.java:147)   07-23 11:54:09.667:W / System.err(19805):... 19更多07-23   11:54:09.677:E / [Login.java]:onConnection:(19805):   java.lang.NullPointerException 07-23 11:54:12.190:E / [Login.java]:   login:(19805):java.lang.IllegalStateException:未连接到   服务器

1 个答案:

答案 0 :(得分:2)

如果

,则抛出异常
InvocationTargetException - if the underlying method throws an exception.

因此,如果使用反射API调用的方法抛出异常(例如运行时异常),则反射API会将异常包装到InvocationTargetException中。