Search code examples
javaandroidsmack

How do I avoid HeadlessException when using Smack on a server?


I downloaded the Smack example code to send GCM to Android devices from a server.

When I run it on my dev machine I get a Smack debugging window.

On my server I get this:

Exception in thread "Thread-6" java.lang.IllegalArgumentException: Can't initialize the configured debugger! at org.jivesoftware.smack.Connection.initDebugger(Connection.java:797) at org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:731) at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:611) at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:596) at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1010) at se.wi.poc.brdgms.utils.Android.connect(Android.java:94) at se.wi.poc.brdgms.utils.Android.push(Android.java:50) at se.wi.poc.brdgms.utils.PushUtils.pushToUserInSeparateThread(PushUtils.java:30) at se.wi.poc.brdgms.utils.PushUtils.access$0(PushUtils.java:26) at se.wi.poc.brdgms.utils.PushUtils$1.run(PushUtils.java:20) Caused by: 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) at org.jivesoftware.smack.Connection.initDebugger(Connection.java:792) ... 9 more Caused by: java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:173) at java.awt.Window.(Window.java:547) at java.awt.Frame.(Frame.java:419) at javax.swing.JFrame.(JFrame.java:218) at org.jivesoftware.smack.debugger.LiteDebugger.createDebug(LiteDebugger.java:65) at org.jivesoftware.smack.debugger.LiteDebugger.(LiteDebugger.java:58) ... 14 more

How do I disable the Smack debug window?


Solution

  • After I go

        myConfig = new ConnectionConfiguration(SERVER, PORT);
    

    I have to go

        myConfig.setDebuggerEnabled(false);