You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2020/05/07 18:41:12 UTC
[GitHub] [camel-quarkus] vitaB opened a new issue #1200: NullPointerException with telegram webhook
vitaB opened a new issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200
When starting a webhook telegram route the class `TelegramEndpoint` is throwing a null pointer exception, because TelegramService is not initialized. I don't think it's due to `camel-telegram`, because it works without quarkus.
Here the exception:
```
2020-05-07 19:11:05,616 ERROR [io.qua.run.Application] (main) Error running Quarkus application: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:315)
at io.quarkus.runtime.Application.start(Application.java:89)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:90)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: java.lang.RuntimeException: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of null
at org.apache.camel.quarkus.core.CamelMainRecorder.start(CamelMainRecorder.java:98)
at io.quarkus.deployment.steps.Main$start49.deploy_0(Main$start49.zig:97)
at io.quarkus.deployment.steps.Main$start49.deploy(Main$start49.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:254)
... 6 more
Caused by: org.apache.camel.FailedToStartRouteException: Failed to start route route1 because of null
at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:125)
at org.apache.camel.impl.engine.AbstractCamelContext.doWarmUpRoutes(AbstractCamelContext.java:3313)
at org.apache.camel.impl.engine.AbstractCamelContext.safelyStartRouteServices(AbstractCamelContext.java:3206)
at org.apache.camel.impl.engine.AbstractCamelContext.doStartOrResumeRoutes(AbstractCamelContext.java:2992)
at org.apache.camel.impl.engine.AbstractCamelContext.doStartCamel(AbstractCamelContext.java:2790)
at org.apache.camel.impl.engine.AbstractCamelContext.doStartContext(AbstractCamelContext.java:2643)
at org.apache.camel.impl.engine.AbstractCamelContext.doStart(AbstractCamelContext.java:2606)
at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2448)
at org.apache.camel.quarkus.core.CamelMain.doStart(CamelMain.java:56)
at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
at org.apache.camel.quarkus.core.CamelMainRecorder.start(CamelMainRecorder.java:96)
... 9 more
Caused by: java.lang.NullPointerException
at org.apache.camel.component.telegram.TelegramEndpoint.registerWebhook(TelegramEndpoint.java:139)
at org.apache.camel.component.webhook.WebhookEndpoint.doStart(WebhookEndpoint.java:88)
at org.apache.camel.support.service.BaseService.start(BaseService.java:115)
at org.apache.camel.support.service.ServiceHelper.startService(ServiceHelper.java:84)
at org.apache.camel.impl.engine.RouteService.doWarmUp(RouteService.java:141)
at org.apache.camel.impl.engine.RouteService.warmUp(RouteService.java:123)
... 20 more
```
my code example
```
import org.apache.camel.quarkus.kotlin.routes
import javax.enterprise.context.ApplicationScoped
import javax.enterprise.inject.Produces
@ApplicationScoped
class TelegramRoute() {
@Produces
fun myRoutes() = routes {
from("webhook:telegram:bots")
.log("\${body}")
}
}
```
and the pom
```
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
<version>1.0.0-M7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.bot-test</groupId>
<artifactId>camel-quarkus-telegram-bot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<kotlin.version>1.3.72</kotlin.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-kotlin</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-telegram</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<configuration>
<javaParameters>true</javaParameters>
<compilerPlugins>
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<option>all-open:annotation=javax.ws.rs.Path</option>
<option>all-open:annotation=javax.enterprise.context.ApplicationScoped</option>
<option>all-open:annotation=io.quarkus.test.junit.QuarkusTest</option>
</pluginOptions>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>
${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] zhfeng commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
zhfeng commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-628467142
@vitaB I believe that this issue should be fixed in https://github.com/apache/camel/pull/3824 by @davsclaus and in camel-quarkus I think we need to upgrade to camel 3.3.0 soon.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] davsclaus commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-630580839
Yeah we have upgraded to Camel 3.3.0 now
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] davsclaus closed issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
davsclaus closed issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] zhfeng commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
zhfeng commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-628394962
Thanks @davsclaus for pointing it out and I will take a look
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] davsclaus commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-628380562
Ah so its maybe the ordering so webhook is started before telegram. So we should defer the webhook register webhook logic till later. We can for example use a listener to trigger when camel context is started and then regsiter the webhook at that time, let me find some sample code
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] davsclaus commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
davsclaus commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-628381428
See the quartz component and the extended startup listener
https://github.com/apache/camel/blob/master/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java#L55
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [camel-quarkus] zhfeng commented on issue #1200: NullPointerException with telegram webhook
Posted by GitBox <gi...@apache.org>.
zhfeng commented on issue #1200:
URL: https://github.com/apache/camel-quarkus/issues/1200#issuecomment-628436535
There is also a problem that the webhook creates the TelegramEndpoint before the camel context is started, and this endpoint is added to the [DeferServiceStartupListener services](https://github.com/apache/camel/blob/master/core/camel-base/src/main/java/org/apache/camel/impl/engine/DeferServiceStartupListener.java#L39). So it is started in the onCamelContextStarted() and can not be triggered.
The other possible solution is adding the registerWebhook() in the doStart()
```
@Override
protected void doStart() throws Exception {
super.doStart();
/* codes of the initialization of AsyncHttpClient and the telegramService */
if (deferRegisterWebhook) {
doRegisterWebhook();
}
}
@Override
public void registerWebhook() throws Exception {
if (telegramService != null) {
doRegisterWebhook();
} else {
LOG.info("defer the webhook register till the endpoint is started");
deferRegisterWebhook = true;
}
}
```
@davsclaus WDYT ?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org