0

I wrote a robot on my web application and I use the Tomcat server I want to be connected to a telegram robot But I receive the following error on Tomcat Server

ApiContextInitializer.init();
TelegramBotsApi telegramBotsApi = new TelegramBotsApi();
telegramBotsApi.registerBot(new StoreBot() );

.....

public class StoreBot extends    TelegramLongPollingBot{

@Override
public String getBotToken() {
    return "375....";

}

public String getBotUsername() {
    return "da....";
}
public void onUpdateReceived(Update update) {
    if (update.hasMessage() && update.getMessage().hasText()) {
        // Set variables
        String message_text = update.getMessage().getText();
        long chat_id = update.getMessage().getChatId();

        SendMessage  message = new SendMessage() // Create a message object object
                .setChatId(chat_id)
                .setText(message_text);
        try {
            execute(message); // Sending our message object to user
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
  }
}

error is :

org.telegram.telegrambots.meta.exceptions.TelegramApiRequestException: Error removing old webhook
    at org.telegram.telegrambots.util.WebhookUtils.clearWebhook(WebhookUtils.java:79)
    at org.telegram.telegrambots.bots.TelegramLongPollingBot.clearWebhook(TelegramLongPollingBot.java:25)

Caused by: org.telegram.telegrambots.meta.exceptions.TelegramApiException: Unable to execute deleteWebhook method
    at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:668) 
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
    at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1937)    

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)  
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:145)

please help me

Eugène Adell
  • 3,089
  • 2
  • 18
  • 34
  • Look at this question, it might help you: https://stackoverflow.com/questions/6908948/java-sun-security-provider-certpath-suncertpathbuilderexception-unable-to-find – Runningriot Mar 25 '19 at 10:26
  • It could be problem with telegram certificate, try solution from here https://github.com/pengrad/java-telegram-bot-api/issues/160 – Stas Parshin May 10 '19 at 10:15

0 Answers0