Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram bot is not running in Spring 3.1.0 #1226

Closed
zsanzharko opened this issue May 28, 2023 · 11 comments · May be fixed by #1228
Closed

Telegram bot is not running in Spring 3.1.0 #1226

zsanzharko opened this issue May 28, 2023 · 11 comments · May be fixed by #1228

Comments

@zsanzharko
Copy link

Describe the bug
Hi! I can't see when telegram bot is running in spring. He's just start and stoping.

Code

package kz.tiger.zone.tigerzoneshopbot.bot;

import lombok.extern.slf4j.Slf4j;
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.Update;

@Component
@Slf4j
public class ShopBot extends TelegramLongPollingBot {
    private final String botUsername;

    public ShopBot(@Value("${bot.username}") String botUsername,
                   @Value("${bot.token}") String botToken) {
        super(botToken);
        this.botUsername = botUsername;
    }

    @Override
    public void onUpdateReceived(Update update) {
        log.info("Work!");
    }

    @Override
    public String getBotUsername() {
        return botUsername;
    }
}

LOG


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.0)

2023-05-28T17:50:08.302+06:00  INFO 28032 --- [           main] k.t.z.t.TigerZoneShopBotApplication      : Starting TigerZoneShopBotApplication using Java 17.0.7 with PID 28032 (D:\develop\projects\tiger-zone-shop-bot\build\classes\java\main started by Legion in D:\develop\projects\tiger-zone-shop-bot)
2023-05-28T17:50:08.305+06:00  INFO 28032 --- [           main] k.t.z.t.TigerZoneShopBotApplication      : No active profile set, falling back to 1 default profile: "default"
2023-05-28T17:50:08.671+06:00  INFO 28032 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-05-28T17:50:08.692+06:00  INFO 28032 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 13 ms. Found 0 JPA repository interfaces.
2023-05-28T17:50:08.988+06:00  INFO 28032 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2023-05-28T17:50:09.226+06:00  INFO 28032 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection org.postgresql.jdbc.PgConnection@40712ee9
2023-05-28T17:50:09.229+06:00  INFO 28032 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2023-05-28T17:50:09.294+06:00  INFO 28032 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-05-28T17:50:09.365+06:00  INFO 28032 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 6.2.2.Final
2023-05-28T17:50:09.366+06:00  INFO 28032 --- [           main] org.hibernate.cfg.Environment            : HHH000406: Using bytecode reflection optimizer
2023-05-28T17:50:09.505+06:00  INFO 28032 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-05-28T17:50:09.643+06:00  INFO 28032 --- [           main] o.s.o.j.p.SpringPersistenceUnitInfo      : No LoadTimeWeaver setup: ignoring JPA class transformer
2023-05-28T17:50:09.694+06:00  INFO 28032 --- [           main] org.hibernate.orm.dialect                : HHH035001: Using dialect: org.hibernate.dialect.PostgreSQLDialect, version: org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$DialectResolutionInfoImpl@50b0afd7
2023-05-28T17:50:09.872+06:00  INFO 28032 --- [           main] o.h.b.i.BytecodeProviderInitiator        : HHH000021: Bytecode provider name : bytebuddy
2023-05-28T17:50:10.046+06:00  INFO 28032 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-05-28T17:50:10.050+06:00  INFO 28032 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-05-28T17:50:10.425+06:00  INFO 28032 --- [           main] k.t.z.t.TigerZoneShopBotApplication      : Started TigerZoneShopBotApplication in 2.495 seconds (process running for 3.068)
2023-05-28T17:50:10.430+06:00  INFO 28032 --- [ionShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-05-28T17:50:10.432+06:00  INFO 28032 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2023-05-28T17:50:10.439+06:00  INFO 28032 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.

Information

  • Spring version: 3.1.0
  • Version starter 6.5.0
@centralhardware
Copy link

are you sure that classpath contain starter?

@zsanzharko
Copy link
Author

@centralhardware
Are you mean about gradle dependencies?
This is my dep.

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    compileOnly 'org.projectlombok:lombok'
    implementation 'org.postgresql:postgresql'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    implementation 'org.telegram:telegrambots-spring-boot-starter:6.5.0'
}

@zsanzharko zsanzharko changed the title Telegram bot is not running in Spring Telegram bot is not running in Spring 3.1.0 May 29, 2023
@Aryesia
Copy link

Aryesia commented May 29, 2023

I have same problem, but I fixed that after created annotation:
image
And use it with MainApplicationClass

@zsanzharko
Copy link
Author

@rubenlagus What do you think?

@Programistich
Copy link

@Aryesia but its not help, i create extend TelegramLongPollingBot and add EnableTelegramBot to application and no print update

@Aryesia
Copy link

Aryesia commented Jun 4, 2023

@Programistich Hmm.. It's working for me. Maybe you have another problem (Proofs in screenshots)
Снимок экрана 2023-06-05 в 00 28 02
Снимок экрана 2023-06-05 в 00 22 51

@Programistich
Copy link

Can u share this project?

@Programistich
Copy link

image image And no one updates print

@Programistich
Copy link

image if i register manual i have error

DefaultBotSession : Error executing org.telegram.telegrambots.meta.api.methods.updates.GetUpdates query: [409] Conflict: terminated by other getUpdates request; make sure that only one bot instance is running

@TheNullablePrototype
Copy link

TheNullablePrototype commented Jun 18, 2023

Running with:

Spring Boot v3.1.0
Spring v6.0.9
Java 20.0.1
Gradle-8.1.1

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.1.0'
    id 'io.spring.dependency-management' version '1.1.0'
}

group = 'group'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    compileOnly 'org.projectlombok:lombok'

    implementation 'org.telegram:telegrambots:6.7.0'
    implementation 'org.telegram:telegrambots-spring-boot-starter:6.7.0'
    implementation 'org.telegram:telegrambotsextensions:6.7.0'

    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
    annotationProcessor 'org.projectlombok:lombok'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
    useJUnitPlatform()
}
@Import({TelegramBotStarterConfiguration.class})
@SpringBootApplication
public class TelegramBotApplication {
    public static void main(String[] args) {
        SpringApplication.run(TelegramBotApplication.class, args);
    }
}

works fine

@zsanzharko
Copy link
Author

Now latest version for telegram is 2.7.12

a48c4b2

wwselleck added a commit to wwselleck/TelegramBots that referenced this issue Jul 23, 2023
Updates documentation for telegrambots-spring-boot-starter to include needed @import annotation 

See: rubenlagus#1226
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants