rubenlagus / TelegramBotsExample

A simple to use library to create Telegram Bots in Java
GNU General Public License v3.0
484 stars 229 forks source link

How to disable WebHook? #20

Closed mcicolella closed 7 years ago

mcicolella commented 8 years ago

Hi all, I'm using your echo sample but I have a problem. I set maven parameters in my pom.xml and changed to "false" the boolean var "useWebHook" in BuildVars.java. It compiles without errors but at runtime the following exception is raised java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/NoopHostnameVerifier at org.telegram.telegrambots.TelegramBotsApi.setWebhook(TelegramBotsApi.java:98) at org.telegram.telegrambots.TelegramBotsApi.setWebhook(TelegramBotsApi.java:152) at org.telegram.telegrambots.TelegramBotsApi.registerBot(TelegramBotsApi.java:129)

Thanks

rubenlagus commented 8 years ago

Hi @mcicolella.

it is necessary to call to setWebhook with an empty url to ensure that no webhook is running. Otherwise, if a webhook was configured before, getUpdates method will fail.

Maybe you changed something in the pom file that caused a missing library?

mcicolella commented 8 years ago

Hi @rubenlagus thanks for your reply!

My code is available at https://github.com/mcicolella/freedomotic/tree/telegram/plugins/devices/telegram-bot

Mit0x2 commented 8 years ago

Hi @mcicolella , maybe you should try updating your TelegramBots version. You are still using 2.1 in your repo. Maybe your issue has been resolved already? Cheers

mcicolella commented 8 years ago

Hi @rubenlagus I updated the TelegramBots version but the issue hasn't been resolved. Now the exception is referred to another class Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/http/conn/ssl/NoopHostnameVerifier at org.telegram.telegrambots.bots.AbsSender.(AbsSender.java:83) at org.telegram.telegrambots.bots.TelegramLongPollingBot.(TelegramLongPollingBot.java:9) at org.telegram.updateshandlers.FreedomoticBotHandlers.(FreedomoticBotHandlers.java:34) at com.freedomotic.plugins.devices.telegrambot.TelegramBot.onStart(TelegramBot.java:93) at com.freedomotic.api.Protocol$1.run(Protocol.java:136) at org.apache.shiro.subject.support.SubjectRunnable.doRun(SubjectRunnable.java:120) at org.apache.shiro.subject.support.SubjectRunnable.run(SubjectRunnable.java:108) at com.freedomotic.api.Protocol.start(Protocol.java:154) at com.freedomotic.jfrontend.PluginJList$1.mouseClicked(PluginJList.java:91) Thanks

Mit0x2 commented 8 years ago

Hi @mcicolella , could you please check your maven dependency setup for the project? Looks like there is a version conflict for the Apache HttpClient. TelegramBots uses version 4.5.2 so if you have a lower version polled by your parent POM or another Dependency it might cause such problems.

Cheers

mcicolella commented 8 years ago

Hi @Mit0x2 , your tip fixed the problem. Thanks to all

Mit0x2 commented 8 years ago

Hi @mcicolella , glad I could help. Please make sure to close your issue once its fixed. Cheers