'Can not find class in classpath. Trying to run dockerfile for Selenium (JAVA)

I have a Selenium Project build in Java. I am trying to automate E2E testing, so basically just have my ci run docker-compose up and it will go through all the tests. I have set up a docker-compose file using the selenium github

version: '3'
services:
  hub:
    image: selenium/hub:4.1.2
    ports:
      - 4442:4442
      - 4443:4443
      - 4444:4444
  chrome:
    image: selenium/node-chrome:4.1.2
    environment:
      - SE_EVENT_BUS_HOST=hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    depends_on:
      - hub
  firefox:
    image: selenium/node-firefox:4.1.2
    environment:
      - SE_EVENT_BUS_HOST=hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    depends_on:
      - hub
  active-number-summary-test-module:
    container_name: active-number-sumary-test-module
    build: ./
    depends_on:
      - chrome
      - firefox
    environment:
      - APP_URL=${APP_URL}
      - USERNAME=${USERNAME}
      - PASSWORD=${PASSWORD}
      - BROWSER=${BROWSER}
      - CLIENT=${CLIENT}
    env_file:
      - .env

I have a dockerfile that has an image that basically creates a jar file and then executes it so the tests can start.

FROM maven:latest AS MAVEN_BUILD
 
# copy the pom and src code to the container
COPY ./ ./
 
# package our application code
RUN mvn clean package -DskipTests

# CMD ["/bin/bash"]
 
# jdk
FROM openjdk:latest

 
# copy only the artifacts we need from the first stage and discard the rest
COPY --from=MAVEN_BUILD /target/TesterPOM.jar /TesterPOM.jar

COPY --from=MAVEN_BUILD /active-number-summary-module.xml /active-number-summary-module.xml

# COPY --from=MAVEN_BUILD /target ./


 ENV BROWSER="chrome"

# set the startup command to execute the jar
ENTRYPOINT java -cp TesterPOM.jar org.testng.TestNG active-number-summary-module.xml

When i build the dockerfile and try to run it I keep getting class not found in classpath. Please see my test module xml below:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="acive-number-summary-module" parallel="none" allow-return-values="true" >
  <test name="click-on-entry">
    <classes>
      <class name="com.tester.qa.testcases.ActiveNumberSummeryTest"/>
    </classes>
  </test>
  <!-- <test name="search-entry">
    <classes>
      <class name="com.tester.qa.testcases.ActiveNumberSummeryTest"/>
    </classes>
  </test>
  <test name="sorting-button">
    <classes>
      <class name="com.tester.qa.testcases.ActiveNumberSummeryTest"/>
    </classes>
  </test>
  <test name="page-numbers">
    <classes>
      <class name="com.tester.qa.testcases.ActiveNumberSummeryTest"/>
    </classes>
  </test> -->
</suite>

File structure is as shown below: File Structure



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source