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

Errors in examples/messaging at the stage of building (Kafka) and running (JMS) applications #2763

Closed
mic216 opened this issue Feb 11, 2021 · 6 comments · Fixed by #2768
Closed
Assignees
Labels
bug Something isn't working examples P2
Milestone

Comments

@mic216
Copy link

mic216 commented Feb 11, 2021

Environment Details

  • Helidon Version: 2.2.0, 2.2.1
  • Helidon SE or Helidon MP: SE
  • JDK version: 11
  • OS: Linux
  • Docker version (if applicable): 19.03.13

Problem Description

Hi, I found two bugs in examples/messaging https://github.com/oracle/helidon/tree/2.2.0/examples/messaging at the stage of building. The problems are easily reproducible.
The first one is that kafkaRun.sh script seems to be obsolete. Stack traces:

[+] Building 6.8s (7/12)
=> [internal] load build definition from Dockerfile.kafka 1.1s
=> => transferring dockerfile: 44B 0.0s
=> [internal] load .dockerignore 1.7s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/openjdk:8-jre-alpine 2.4s
=> [1/8] FROM docker.io/library/openjdk:8-jre-alpine@sha256:f362b165b870ef129cbe730f29065ff37399c0aa8bcab3e44b51c302938c9193 0.0s
=> [internal] load build context 0.8s
=> => transferring context: 70B 0.0s
=> CACHED [2/8] RUN apk add --no-cache bash curl jq gcompat 0.0s
=> ERROR [3/8] RUN MIRROR=$(curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq -r '.http[0]') && wget -q -O kafka.tar.gz ${MIRROR}kafka/2.5.0/kafka_2.12-2.5.0.tgz && tar -xzf kafka.tar.gz -C /opt && rm ka 2.5s
[3/8] RUN MIRROR=$(curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq -r '.http[0]') && wget -q -O kafka.tar.gz ${MIRROR}kafka/2.5.0/kafka_2.12-2.5.0.tgz && tar -xzf kafka.tar.gz -C /opt && rm kafka.tar.gz && mv /opt/kafka* /opt/kafka:
#6 2.236 wget: server returned error: HTTP/1.1 404 Not Found
failed to solve with frontend dockerfile.v0: failed to build LLB: executor failed running [/bin/sh -c MIRROR=$(curl -s 'https://www.apache.org/dyn/closer.cgi?as_json=1' | jq -r '.http[0]') && wget -q -O kafka.tar.gz ${MIRROR}kafka/${VERSION}/kafka_2.12-${VERSION}.tgz && tar -xzf kafka.tar.gz -C /opt && rm kafka.tar.gz && mv /opt/kafka* /opt/kafka]: runc did not terminate sucessfully
Unable to find image 'helidon-test-kafka:latest' locally
docker: Error response from daemon: pull access denied for helidon-test-kafka, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

And the second one is related to JMS. I can run JMS docker container using "docker run --name='activemq' --rm -p 61616:61616 -p 8161:8161 rmohr/activemq" but it doesn't seem to be available in the web browser. Moreover, running jms-websocket-se application fails and its stack traces are:

log4j:WARN No appenders could be found for logger (org.apache.activemq.util.ThreadPoolUtils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" io.helidon.messaging.MessagingException: Error when creating JMS producer.
at io.helidon.messaging.connectors.jms.JmsConnector.getSubscriberBuilder(JmsConnector.java:356)
at io.helidon.messaging.MessagingImpl.findConnectors(MessagingImpl.java:161)
at java.base/java.util.HashMap$Values.forEach(HashMap.java:976)
at io.helidon.messaging.MessagingImpl.start(MessagingImpl.java:63)
at io.helidon.examples.messaging.se.SendingService.(SendingService.java:71)
at io.helidon.examples.messaging.se.Main.startServer(Main.java:67)
at io.helidon.examples.messaging.se.Main.main(Main.java:51)
Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://127.0.0.1:61616. Reason: java.net.ConnectException: Connection refused (Connection refused)
at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:374)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:304)
at org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:244)
at io.helidon.messaging.connectors.jms.JmsConnector.prepareSession(JmsConnector.java:453)
at io.helidon.messaging.connectors.jms.JmsConnector.getSubscriberBuilder(JmsConnector.java:345)
... 6 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
at java.base/java.net.Socket.connect(Socket.java:609)
at org.apache.activemq.transport.tcp.TcpTransport.connect(TcpTransport.java:525)
at org.apache.activemq.transport.tcp.TcpTransport.doStart(TcpTransport.java:488)
at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)
at org.apache.activemq.transport.AbstractInactivityMonitor.start(AbstractInactivityMonitor.java:169)
at org.apache.activemq.transport.InactivityMonitor.start(InactivityMonitor.java:52)
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
at org.apache.activemq.transport.WireFormatNegotiator.start(WireFormatNegotiator.java:72)
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
at org.apache.activemq.transport.TransportFilter.start(TransportFilter.java:64)
at org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:354)
... 10 more

Steps to reproduce

Kafka issue:

cd helidon/examples/messaging
./kafkaRun.sh

JMS issue:

docker run --name='activemq' --rm -p 61616:61616 -p 8161:8161 rmohr/activemq
cd helidon/examples/messaging/jms-websocket-se
mvn clean install
java -jar target/helidon-examples-jms-websocket-se.jar

@mic216
Copy link
Author

mic216 commented Feb 12, 2021

I fixed Kafka issue, it is enough to upgrade to 2.7.0 version from 2.5.0 version in examples/messaging/docker/kafka/Dockerfile.kafka. ENV VERSION=2.5.0 -> ENV VERSION=2.7.0

@romain-grecourt romain-grecourt added bug Something isn't working examples labels Feb 12, 2021
@romain-grecourt romain-grecourt added this to the 2.3.0 milestone Feb 12, 2021
@danielkec
Copy link
Contributor

danielkec commented Feb 15, 2021

Hi nice catch! Apache mirrors no longer publish version 2.5.0, new dockerfile version #2768 resolves latest version for installation.

@danielkec
Copy link
Contributor

danielkec commented Feb 15, 2021

Are you sure rmohr/activemq image started correctly for you? Just tested freshly pulled image and works as expected:
image

@barchetta barchetta added the P2 label Feb 18, 2021
@mic216
Copy link
Author

mic216 commented Feb 20, 2021

@danielkec Ok, rmohr/activemq now works. I don't know why it didn't work earlier.

Btw, I wanted to create communication between two microservices using kafka server and I want to ask: what is the best practice to make kafka server working merely in backend, because I found that /examples/messaging/kafka-websocket-se works only if javascript WebSocket is opened at frontend. How to make websocket working in clean helidon (backend) without necessity of opening js ws at frontend?

@danielkec
Copy link
Contributor

Not sure if I do understand the question, but if you want to try SE messaging with Kafka without frontend attached take a look at this little example https://github.com/danielkec/streaming-sasl (ignore the graal substitution) it's simple one file example of sending and receiving in console

@danielkec
Copy link
Contributor

You can also find detailed step by step explanation in this article https://medium.com/helidon/helidon-2-0-with-kafka-b97ba4f422bd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working examples P2
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants