Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Telegram Bot finished with non-zero exit value 1

  1. #1
    Junior Member
    Join Date
    Jan 2022
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Telegram Bot finished with non-zero exit value 1

    Hello. Help me please find out my error and fix it. Im using spring boot, gradle.

    SendMessageService.Java
    package org.xpremiumbot.services;
     
    import org.springframework.stereotype.Service;
    import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
    import org.telegram.telegrambots.meta.api.objects.Message;
    import org.xpremiumbot.messagesender.MessageSender;
     
    @Service
    public class SendMessageService {
        private final MessageSender messageSender;
     
        public SendMessageService(MessageSender messageSender) {
            this.messageSender = messageSender;
        }
     
        public void test(Message message) {
            var msg = SendMessage.builder()
                    .text("<b>Bold</b> " +
                            "<i>italic</i> " +
                            "<code>mono</code> " +
                            "<a href=\"google.com\">Google<a/>")
                    .parseMode("HTML")
                    .chatId(String.valueOf(message.getChatId()))
                    .build();
            messageSender.sendMessage(msg);
        }
    }

    TelegrambotApplication.java
    package org.xpremiumbot;
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
     
    @SpringBootApplication
    public class TelegrambotApplication {
     
    	public static void main(String[] args) {
    		SpringApplication.run(TelegrambotApplication.class, args);
    	}
     
    }

    Main file (xBot.java)
    package org.xpremiumbot;
     
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.stereotype.Component;
    import org.telegram.telegrambots.bots.TelegramLongPollingBot;
    import org.telegram.telegrambots.meta.api.objects.Message;
    import org.telegram.telegrambots.meta.api.objects.Update;
    import org.xpremiumbot.services.SendMessageService;
     
    @Component
    public class xBot extends TelegramLongPollingBot {
        @Value("${telegram.bot.username}")
        private String username;
        @Value("${telegram.bot.token}")
        private String token;
     
        @Override
        public String getBotUsername() {
            return username;
        }
     
        @Override
        public String getBotToken() {
            return token;
        }
     
        private SendMessageService sendMessageService;
     
        @Override
        public void onUpdateReceived(Update update) {
            if (update.hasMessage()) {
                Message message = update.getMessage();
                if (message.hasText()) {
                    sendMessageService.test(message);
                }
            }
        }
     
        @Autowired
        public SendMessageService getSendMessageService() {
            return sendMessageService;
        }
    }

    And got this error:
    Execution failed for task ':TelegrambotApplication.main()'.
    > Process 'command 'C:/Users/Jexly/.jdks/openjdk-17.0.1/bin/java.exe'' finished with non-zero exit value 1

    I searched the Internet for an error, everything that is written there did not help me. I don’t understand what exactly is my problem, the code is written perfectly

    --- Update ---

    If you need any more files, or a description of what each line does, please contact me, I need to fix this error

  2. #2
    Junior Member
    Join Date
    Jan 2022
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Whats wrong with this code?

    Im coding gradle java spring telegram bot. And get this error ->

    Execution failed for task ':TelegrambotApplication.main()'.
    > Process 'command 'C:/Users/Jexly/.jdks/openjdk-17.0.1/bin/java.exe'' finished with non-zero exit value 1

    Below are the lines of my code. I tried to fix the error, I googled the problem, nothing works.

    package org.xpremiumbot;
     
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
     
    @SpringBootApplication
    public class TelegrambotApplication {
     
    	public static void main(String[] args) {
    		SpringApplication.run(TelegrambotApplication.class, args);
    	}
     
    }

    package org.xpremiumbot;
     
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.beans.factory.annotation.Value;
    import org.springframework.stereotype.Component;
    import org.telegram.telegrambots.bots.TelegramLongPollingBot;
    import org.telegram.telegrambots.meta.api.objects.Message;
    import org.telegram.telegrambots.meta.api.objects.Update;
    import org.xpremiumbot.services.SendMessageService;
     
    @Component
    public class xBot extends TelegramLongPollingBot {
        @Value("${telegram.bot.username}")
        private String username;
        @Value("${telegram.bot.token}")
        private String token;
     
        @Override
        public String getBotUsername() {
            return username;
        }
     
        @Override
        public String getBotToken() {
            return token;
        }
     
        private SendMessageService sendMessageService;
     
        @Override
        public void onUpdateReceived(Update update) {
            if (update.hasMessage()) {
                Message message = update.getMessage();
                if (message.hasText()) {
                    sendMessageService.test(message);
                }
            }
        }
     
        @Autowired
        public SendMessageService getSendMessageService() {
            return sendMessageService;
        }
    }

    package org.xpremiumbot.services;
     
    import org.springframework.stereotype.Service;
    import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
    import org.telegram.telegrambots.meta.api.objects.Message;
    import org.xpremiumbot.messagesender.MessageSender;
     
    @Service
    public class SendMessageService {
        private final MessageSender messageSender;
     
        public SendMessageService(MessageSender messageSender) {
            this.messageSender = messageSender;
        }
     
        public void test(Message message) {
            var msg = SendMessage.builder()
                    .text("<b>Bold</b> " +
                            "<i>italic</i> " +
                            "<code>mono</code> " +
                            "<a href=\"google.com\">Google<a/>")
                    .parseMode("HTML")
                    .chatId(String.valueOf(message.getChatId()))
                    .build();
            messageSender.sendMessage(msg);
        }
    }

  3. #3
    Junior Member
    Join Date
    Jan 2022
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Telegram Bot finished with non-zero exit value 1

    Thanks for help. Bye forum

Similar Threads

  1. How to exit while loop
    By #0Prog in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 19th, 2018, 09:46 AM
  2. My first finished Java project (A text game)
    By robinsuu in forum The Cafe
    Replies: 2
    Last Post: August 9th, 2014, 03:15 PM
  3. Replies: 1
    Last Post: December 4th, 2012, 07:16 AM
  4. Jar self delete on exit?
    By KiwiProg in forum Java Theory & Questions
    Replies: 1
    Last Post: December 19th, 2010, 02:54 AM