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

Error with KAFKA_JMX_OPTS #504

Closed
alvarolmedo opened this issue Jun 5, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@alvarolmedo
Copy link

commented Jun 5, 2019

When the var KAFKA_JMX_OPTS is passed in a envfile [1] kafka doesn't start, from docker logs:

Error: Could not find or load main class "-Dcom.sun.management.jmxremote

The same var with --env works perfectly.

[1] https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file

@sscaling

This comment has been minimized.

Copy link
Collaborator

commented Jun 5, 2019

We explicitly ignore this var and don't process it (https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh#L121) -could this be a difference in how docker handles this? Judging by the error is it related to having the = sign in the value?

A quick test using the parameters from the README works fine for me:

.env

KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.rmi.port=1099

docker-compose.yml

version: '2'
services:
  zookeeper:
    image: wurstmeister/zookeeper
    ports:
      - "2181:2181"
  kafka:
    build: .
    ports:
      - "9092"
      - "1099:1099"
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 192.168.0.3
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_JMX_OPTS:
      JMX_PORT: 1099
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

I can then connect fine over jconsole, e.g. jconsole 127.0.0.1:1099

If you can provide an example and steps to reproduce then we can take a look and try to rule out that it's anything with the kafka-docker image.

@alvarolmedo

This comment has been minimized.

Copy link
Author

commented Jun 5, 2019

My fault... It's not a problem with the env file, it's a problem with the definition of the value in the env file.
I added to env vars file:

KAFKA_JMX_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=1099"
JMX_PORT=1099

The quotes take this effect when I inspect the container:

# docker inspect kafka | grep -i jmx
                "JMX_PORT=1099",
                "KAFKA_JMX_OPTS=\"-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=1099\"",

So, produces the error observed in the log:

Error: Could not find or load main class "-Dcom.sun.management.jmxremote

@sscaling sscaling added invalid and removed missing info labels Jun 5, 2019

@sscaling sscaling closed this Jun 5, 2019

@alvarolmedo

This comment has been minimized.

Copy link
Author

commented Jun 5, 2019

Without quotes in the env-file:

KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=1099
JMX_PORT=1099

Works like a charm and the inspection is right:

# docker inspect kafka | grep -i jmx
                "JMX_PORT=1099",
                "KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=1099",
@alvarolmedo

This comment has been minimized.

Copy link
Author

commented Jun 5, 2019

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.