如何解决错误“java.lang.IllegalArgumentException:无法初始化配置的调试器!”咂舌

Posted

技术标签:

【中文标题】如何解决错误“java.lang.IllegalArgumentException:无法初始化配置的调试器!”咂舌【英文标题】:How to resolve error "java.lang.IllegalArgumentException: Can't initialize the configured debugger!" in smack 【发布时间】:2013-12-13 10:17:27 【问题描述】:

我想将 smack api 和 gtalk 服务器用于 IM。 我的代码在我从本地系统运行时有效。

    import java.io.Console;
    import java.util.Collection;
    import java.util.List;

    import javax.net.ssl.SSLSocketFactory;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;

    import org.jivesoftware.smack.Chat;
    import org.jivesoftware.smackx.*;
    import org.jivesoftware.smack.ConnectionConfiguration;
    import org.jivesoftware.smack.MessageListener;
    import org.jivesoftware.smack.Roster;
    import org.jivesoftware.smack.RosterEntry;
    import org.jivesoftware.smack.XMPPConnection;
    import org.jivesoftware.smack.XMPPException;
    import org.jivesoftware.smack.packet.Message;
    import org.jivesoftware.smack.debugger.SmackDebugger;
    import org.jivesoftware.smack.filter.PacketFilter;
    import org.jivesoftware.smack.packet.Presence;


public class runcollectorAction extends Action implements MessageListener

public static String username = "pqr";
public static String password ="mypwd";
XMPPConnection connection = new XMPPConnection("gmail.com");

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, HttpServletResponse response)
        throws Exception 

    XMPPConnection.DEBUG_ENABLED = true;
    System.out.println("okzzzz");
    String realtime=request.getParameter("collector");

    if(realtime!=null)
        boolean connectionStatus = connectToServer();
        displayUserList();
        if (connectionStatus)

            sendMessage(realtime,"abc@gmail.com");

        

    System.out.println("Realtime  : "+ realtime);
    
    return mapping.findForward("success");



public void sendMessage(String message, String to) throws   XMPPException

    System.out.println("Message is ... " + message);
    Chat chat = connection.getChatManager().createChat(to, this);
    chat.sendMessage(message);


@Override
public void processMessage(Chat chat, Message message) 
    // TODO Auto-generated method stub
    if ( message.getType() == Message.Type.chat)
        System.out.println(chat.getParticipant() + "says: " + message.getBody());

    

        

public boolean connectToServer() throws XMPPException
    try 

        ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com",5222,"gmail.com");

        config.setCompressionEnabled(true);
        //config.setSASLAuthenticationEnabled(false);
        connection = new XMPPConnection(config);

        connection.connect();
        Thread.sleep(31000);
        System.out.println("connected to ... " + connection.getHost() );

        connection.login(username, password);

        System.out.println("authenticated .... " + connection.isAuthenticated());

    
    catch (Exception e)
        e.printStackTrace();
        System.out.println("Error occured while connecting to server");
    
    return true;
    //return connection.isConnected();



/**
 * Function to display user list
 */
public void displayUserList()

Roster roster = connection.getRoster();
roster.setSubscriptionMode(Roster.SubscriptionMode.manual);
Collection<RosterEntry> entries = roster.getEntries();

System.out.println("\n\n" + entries.size() + " buddy(ies):");
for(RosterEntry r:entries)
    
        System.out.println(r.getUser());
        Presence presence = roster.getPresence(r.getUser());
        System.out.println(r.getUser()+ " user is "+ presence.getMode());
    


但是当我使用 git 将相同的代码推送到服务器(实时)而不进行任何更改时,它会出现以下错误。

java.lang.IllegalArgumentException: Can't initialize the configured debugger!
    at org.jivesoftware.smack.Connection.initDebugger(Connection.java:774)
    at org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:679)
    at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:543)
    at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection.java:527)
    at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:953)

它还给出错误 - “未连接到服务器”

如何解决这些错误??

【问题讨论】:

我也遇到过这个问题。你有没有弄明白? 【参考方案1】:

这可能对你有帮助。

Nsmack api 是我的类,这就是我使用它的对象的原因。 在给定的代码中,只有以下语句很重要-

XMPPConnection.DEBUG_ENABLED = false;
config.setCompressionEnabled(true);
config.setSASLAuthenticationEnabled(false);


private void connectionInit() throws XMPPException, IOException 
    // TODO Auto-generated method stub
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("... in main function .......");
    XMPPConnection.DEBUG_ENABLED = false;
    mySmackObj = new NSmackAPI();
    boolean status = mySmackObj.connectTOGTalk();
    boolean initial_status = true;
    mySmackObj.displayUserList();
    System.out.println("-----");

    String talkTo=RunMTNew.customer+"web@"+server;
    System.out.println(talkTo);
    System.out.println("-----");
    System.out.println("All messages will be sent to " + talkTo);
    System.out.println("Enter your message in the console:");
    System.out.println("-----\n");
    mySmackObj.sendMessage("Hi..are you there", talkTo);
  try
      while(!(smsg=br.readLine()).equals(null))
          mySmackObj.sendMessage(smsg, talkTo);
      
  
  catch(Exception e)
      System.out.println("sending failed");
      e.printStackTrace();
  



boolean connectTOGTalk() throws XMPPException

    try 


        ConnectionConfiguration config = new ConnectionConfiguration(server, 5222, server);
        config.setCompressionEnabled(true);
        config.setSASLAuthenticationEnabled(false);
        connection = new XMPPConnection(config);
        connection.connect();
        System.out.println("Username is "+username);
        System.out.println("Connected to " + connection.getHost());
        connection.login(username,password);
        System.out.println(connection.isAuthenticated());
        
    catch (Exception e) 
        e.printStackTrace();
    
    if(connection.isConnected())
        return true;
    
    else 
        return false;
    

【讨论】:

在上述解决方案中不起作用。还有什么办法解决吗?【参考方案2】:

将此添加到我的配置中解决了我的问题

myConfig.setDebuggerEnabled(true);

【讨论】:

我得到了同样的问题,因为添加了上面的行。如果我设置config.setDebuggerEnabled 那么它工作正常。但我想在我的连接上启用调试模块。

以上是关于如何解决错误“java.lang.IllegalArgumentException:无法初始化配置的调试器!”咂舌的主要内容,如果未能解决你的问题,请参考以下文章

0713-6.2.0-HBase的Thrift Server启动问题

请求 io.undertow.servlet.spec.HttpServletRequestImpl 不是原始的或包装器

如何解决颤振中的 build.gradle 错误。如何解决此错误“评估项目 ':app' 时出现问题。> 格式错误的 \uxxxx 编码。”

c#Ajax 的错误,应该如何解决?

"SQL SERVER,错误:207" 如何解决

如何解决“错误:输入中的语法错误(1)。”