在服务器上使用Smack时如何避免HeadlessException?

时间:2014-05-22 10:37:43

标签: java android smack

我下载了Smack示例代码,用于从服务器将GCM发送到Android设备。

当我在我的开发机器上运行时,我得到一个Smack调试窗口。

在我的服务器上,我得到了这个:

  

线程中的异常"线程-6" java.lang.IllegalArgumentException:无法初始化配置的调试器!           在org.jivesoftware.smack.Connection.initDebugger(Connection.java:797)           在org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:731)           在org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:611)           在org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:596)           在org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1010)           在se.wi.poc.brdgms.utils.Android.connect(Android.java:94)           在se.wi.poc.brdgms.utils.Android.push(Android.java:50)           在se.wi.poc.brdgms.utils.PushUtils.pushToUserInSeparateThread(PushUtils.java:30)           在se.wi.poc.brdgms.utils.PushUtils.access $ 0(PushUtils.java:26)           在se.wi.poc.brdgms.utils.PushUtils $ 1.run(PushUtils.java:20)   引起:java.lang.reflect.InvocationTargetException           at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)           at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)           at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)           at java.lang.reflect.Constructor.newInstance(Constructor.java:534)           在org.jivesoftware.smack.Connection.initDebugger(Connection.java:792)           ......还有9个   引起:java.awt.HeadlessException           at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173)           在java.awt.Window。(Window.java:547)           在java.awt.Frame。(Frame.java:419)           在javax.swing.JFrame。(JFrame.java:218)           在org.jivesoftware.smack.debugger.LiteDebugger.createDebug(LiteDebugger.java:65)           在org.jivesoftware.smack.debugger.LiteDebugger。(LiteDebugger.java:58)           ......还有14个

如何禁用Smack调试窗口?

1 个答案:

答案 0 :(得分:2)

我走后

    myConfig = new ConnectionConfiguration(SERVER, PORT);

我得走了

    myConfig.setDebuggerEnabled(false);