ibm-messaging / mq-dev-badge-sample

Sample code of the MQ developer essentials badge
Apache License 2.0
13 stars 37 forks source link

Error: Could not find or load main class com.ibm.mq.badge.Manager #13

Closed ksiv closed 2 years ago

ksiv commented 2 years ago

Docker is built from MQTicketService by execution of "docker build . -t mqbadge:latest" result is FINISHED 16/16

"docker run -e LICENSE=accept -e MQ_QMGR_NAME=QM1 -e LOG_FORMAT=json -e MQ_APP_PASSWORD=passw0rd -p 1414:1414 -p 9443:9443 -ti --name mqebs mqbadge:latest" results in :

{"ibm_messageId":"AMQ9218E","ibm_arithInsert1":1414,"ibm_arithInsert2":98,"ibm_commentInsert1":"bind","ibm_commentInsert2":"TCP/IP","ibm_datetime":"2022-04-11T11:45:59.321Z","ibm_serverName":"QM1","type":"mq_log","host":"9e789f722fe7","loglevel":"ERROR","module":"amqclita.c:746","ibm_sequence":"1649677559_323289100","ibm_processId":"272","ibm_threadId":"1","ibm_version":"9.2.4.0","ibm_processName":"runmqlsr","ibm_userName":"mqm","ibm_installationName":"Installation1","ibm_installationDir":"/opt/mqm","message":"AMQ9218E: The TCP/IP listener program could not bind to port number 1414."}

{"ibm_messageId":"AMQ5027I","ibm_arithInsert1":274,"ibm_arithInsert2":0,"ibm_commentInsert1":"SYSTEM.LISTENER.TCP.1","ibm_datetime":"2022-04-11T11:45:59.325Z","ibm_serverName":"QM1","type":"mq_log","host":"9e789f722fe7","loglevel":"INFO","module":"amqzmgr0.c:4641","ibm_sequence":"1649677559_325683300","ibm_processId":"117","ibm_threadId":"1","ibm_version":"9.2.4.0","ibm_processName":"amqzmgr0","ibm_userName":"mqm","ibm_installationName":"Installation1","ibm_installationDir":"/opt/mqm","message":"AMQ5027I: The listener 'SYSTEM.LISTENER.TCP.1' has ended. ProcessId(274)."}

{"ibm_messageId":"AMQ5027I","ibm_arithInsert1":272,"ibm_arithInsert2":0,"ibm_commentInsert1":"DEV.LISTENER.TCP","ibm_datetime":"2022-04-11T11:45:59.327Z","ibm_serverName":"QM1","type":"mq_log","host":"9e789f722fe7","loglevel":"INFO","module":"amqzmgr0.c:4641","ibm_sequence":"1649677559_327790600","ibm_processId":"117","ibm_threadId":"1","ibm_version":"9.2.4.0","ibm_processName":"amqzmgr0","ibm_userName":"mqm","ibm_installationName":"Installation1","ibm_installationDir":"/opt/mqm","message":"AMQ5027I: The listener 'DEV.LISTENER.TCP' has ended. ProcessId(272)."}

Error: Could not find or load main class com.ibm.mq.badge.Manager

Caused by: java.lang.ClassNotFoundException: com.ibm.mq.badge.Manager`

​ p.s. docker run from https://developer.ibm.com/learningpaths/ibm-mq-badge/create-configure-queue-manager/ works fine

ksiv commented 2 years ago

run.log full execution log

chughts commented 2 years ago

The error is

The TCP/IP listener program could not bind to port number 1414

which implies the you already have something occupying port 1414. If you run docker ps you will get a list of all active containers.

ksiv commented 2 years ago

docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

I removed any other containers, volumes and images. Only one image and one container atm

ksiv commented 2 years ago

My platform is Docker Desktop 4.7.0 (77141) is currently the newest version available. In Linux containers mode Windows 10 Pro

chughts commented 2 years ago

Based on you having had a MQ container running, and you still getting

The TCP/IP listener program could not bind to port number 1414

and there are no running containers locking 1414, I think you might have hit a Windows / Hyper-V bug.

Based on similar issues raised on other repos, try running these commands.

netstat -ano

This will show any ports in use.

If 1414 isn't mentioned then try running

netsh interface ipv4 show excludedportrange protocol=tcp

that will show excluded port ranges. I suspect that 1414 might show up there.

ksiv commented 2 years ago

netstat -ano there is no 1414 port in there netsh interface ipv4 show excludedportrange protocol=tcp

Protocol tcp Port Exclusion Ranges there is no 1414 port in there

ksiv commented 2 years ago

if I reinstall docker container from step https://developer.ibm.com/learningpaths/ibm-mq-badge/create-configure-queue-manager/ and execute compiled test from step https://developer.ibm.com/learningpaths/ibm-mq-badge/write-run-first-mq-app/ javac -cp .\com.ibm.mq.allclient-9.2.4.0.jar;.\javax.jms-api-2.0.1.jar;.\json-20211205.jar com\ibm\mq\samples\jms\JmsPut.java

Received message: Your lucky number today is 15 SUCCESS

D:\my\ibmmq> the port 1414 is present in this case in state listening TCP 0.0.0.0:1414 0.0.0.0:0 LISTENING 10188

UPD: I redone all the routine with following versions Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f) Maven home: D:\SDK\apache-maven-3.6.3\bin.. Java version: 11.0.14.1, vendor: International Business Machines Corporation, runtime: D:\Java\jdk-11.0.14.101-openj9 Default locale: en_US, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" the java version is set as recommended here: https://developer.ibm.com/learningpaths/ibm-mq-badge/write-run-first-mq-app/

ksiv commented 2 years ago

Ok. localized. this project is not Win compatible. Workaround:

  1. remove symlink called "com" from mq-dev-badge-sample\MQTicketService\TicketGenerator\src\main\java
  2. place there a com folder from mq-dev-badge-sample\MQTicketService\TicketGenerator\com
  3. remove and rebuild docker images and containers

Have fun!

vicglarson commented 2 years ago

Symlinks in java sources? Seriously? What a joke,

ksiv commented 2 years ago

One never knows with maven, I thought it's a new feature. Nevertheless, "listener program could not bind to port number 1414."}" - seems a "proper" behavior. I mean it's a bug irrelevant to this ticket as DEV.LISTENER.TCP works fine at least I see it in the console as working and an example from https://developer.ibm.com/learningpaths/ibm-mq-badge/write-run-first-mq-app/ works, I still getting my lucky numbers - this would not work without any listener.

chughts commented 2 years ago

So the take away is make this repo, windows compatible. I'll close this issue, and raise a specific one.

ksiv commented 2 years ago

@chughts, It would be nice for dev juniors as the idea of the project to get into MQ JMS development and the variety of desktop systems is still dominated by Windows. Thanks a lot!