如何解决线程中的异常:”main” java.lang.NoSuchFieldError:INSTANCE

huangapple 未分类评论53阅读模式
英文:

how to solve Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE

问题

我正在尝试将我的 Telegram 机器人和 Telegram 机器人 API 连接到我的项目中,但在运行时遇到了以下错误:

在主线程中的异常 "main" java.lang.NoSuchFieldError: INSTANCE
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
	at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:977)
	at org.telegram.telegrambots.facilities.TelegramHttpClientBuilder.build(TelegramHttpClientBuilder.java:31)
	at org.telegram.telegrambots.bots.DefaultAbsSender.<init>(DefaultAbsSender.java:79)
	at org.telegram.telegrambots.bots.TelegramLongPollingBot.<init>(TelegramLongPollingBot.java:20)
	at org.telegram.telegrambots.bots.TelegramLongPollingBot.<init>(TelegramLongPollingBot.java:16)

有人知道如何修复这个错误吗?

以下是我的测试代码:

public static void main(String []args) {
    ApiContextInitializer.init();
    TelegramBotsApi botsApi = new TelegramBotsApi();
    try {
        botsApi.registerBot(new Bot());
    } catch (TelegramApiRequestException e) {
        e.printStackTrace();
    }
}

我尝试移除多余的 httpclient 库,但没有起作用。有人可以告诉我如何修复这个错误吗?

英文:

i am trying to connect my telegram bot and telegram bot api to my project and when i run i face to this error

Exception in thread &quot;main&quot; java.lang.NoSuchFieldError: INSTANCE
	at org.apache.http.conn.ssl.SSLConnectionSocketFactory.&lt;clinit&gt;(SSLConnectionSocketFactory.java:151)
	at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:977)
	at org.telegram.telegrambots.facilities.TelegramHttpClientBuilder.build(TelegramHttpClientBuilder.java:31)
	at org.telegram.telegrambots.bots.DefaultAbsSender.&lt;init&gt;(DefaultAbsSender.java:79)
	at org.telegram.telegrambots.bots.TelegramLongPollingBot.&lt;init&gt;(TelegramLongPollingBot.java:20)
	at org.telegram.telegrambots.bots.TelegramLongPollingBot.&lt;init&gt;(TelegramLongPollingBot.java:16)

any one know how can i fix it?

this i s my test code

public static void main(String []args) {
        ApiContextInitializer.init();
        TelegramBotsApi botsApi= new TelegramBotsApi();
        try {
            botsApi.registerBot(new Bot());
        } catch (TelegramApiRequestException e) {
            e.printStackTrace();
        }
    }

i trying to remove extra httpclient librarys and it not work. any one can tell me how fix this error?

huangapple
  • 本文由 发表于 2020年4月10日 02:10:27
  • 转载请务必保留本文链接:https://java.coder-hub.com/61127536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定