Originally posted by **TheCanay** January 10, 2022
When i'm adding the @Component annotation to my bot class I got an exception:
![Exception](https://user-images.githubusercontent.com/77727402/148824316-7e46c073-9955-4e9f-afc4-b1b4f5c98109.png)
Here is my bot class:
```
@Component
public class MessageHandlerBot extends AbilityBot {
public MessageHandlerBot() {
//error occurs here!
super(BOT_TOKEN, BOT_USERNAME);
}
//creatorId method overriding, and some abilities described
}
```
Here is servicee that starts the bot:
```
public class BotService {
public static void run() {
try {
TelegramBotsApi botsApi = new TelegramBotsApi(DefaultBotSession.class);
botsApi.registerBot(new MessageHandlerBot());
} catch (TelegramApiException e) {
e.printStackTrace();
}
}
}
```
And the main class that runs the program
```
@SpringBootApplication
public class TestTelegramBotApplication {
public static void main(String[] args) {
SpringApplication.run(TestTelegramBotApplication.class, args);
BotService.run();
}
}
```
How to fix it? I need to use the @Autowired annotation from Spring boot, but it doesn't work because I can't mark the bot class as a component or service
Discussed in https://github.com/rubenlagus/TelegramBots/discussions/1025