I have tried multiple times to run my scripts through docker but, I’m getting session not created issue through docker but it is running fine with pom.xml.
can someone please help me to resolve this issue?
This is my dockerfile:-
=============================================================
# Use an official Maven image to build the project
FROM maven:3.8.8 AS build
# Set the working directory inside the container
WORKDIR /app
# Copy the pom.xml to download project dependencies
COPY pom.xml .
# Download project dependencies to be used offline
RUN mvn dependency:go-offline -B
# Copy the entire project source into the container
COPY . .
# Run tests using Maven (optional, can be skipped if not needed)
RUN mvn clean test
# Package the application as a JAR file using Maven, skipping tests
RUN mvn clean package -DskipTests
# Second stage: use a minimal OpenJDK image to run the application
FROM openjdk:11-slim
# Set the working directory inside the container
WORKDIR /app
# Copy the built JAR file from the Maven build stage
COPY --from=build /app/target/*.jar /app/app.jar
# Expose the port on which the application runs (change if needed)
EXPOSE 8080
# Command to run Xvfb and then your JAR file when the container starts
ENTRYPOINT ["sh", "-c", "Xvfb :99 -ac & java -jar /app/app.jar"]
===============================================================
& This is the issues which i’m facing to run pom.xml through docker:-
===============================================================
51 21:03:41.638 [main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient -- ep-0000000004 releasing valid en
dpoint
66.51 21:03:41.638 [main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager -- ep-0000000004 releasi
ng endpoint
66.51 21:03:41.638 [main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager -- ep-0000000004 connect
ion http-outgoing-2 can be kept alive for 3 MINUTES
66.51 21:03:41.638 [main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager -- ep-0000000004 connect
ion released [route: {s}->https://storage.googleapis.com:443][total available: 3; route allocated: 1 of 5; total allocated: 3
of 25]
66.51 21:03:41.638 [main] INFO io.github.bonigarcia.wdm.online.Downloader -- Extracting driver from compressed file chromedriv
er-linux64.zip
66.51 21:03:42.069 [main] INFO io.github.bonigarcia.wdm.WebDriverManager -- Exporting webdriver.chrome.driver as /root/.cache/
selenium/chromedriver/linux64/129.0.6668.100/chromedriver
66.51 [ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 12.206 s <<< FAILURE! - in TestSuite
66.51 [ERROR] setUp(beagle.automation.RedShift) Time elapsed: 12.203 s <<< FAILURE!
66.51 org.openqa.selenium.SessionNotCreatedException:
66.51 Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
66.51 Host info: host: 'buildkitsandbox', ip: '127.0.0.1'
66.51 Caused by: org.openqa.selenium.WebDriverException:
66.51 Driver server process died prematurely.
66.51 Build info: version: '4.20.0', revision: '866c76ca80'
66.51 System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.153.1-microsoft-standard-WSL2', java.version: '21.0.1
'
66.51 Driver info: driver.version: ChromeDriver
66.51
66.51 [INFO]
66.51 [INFO] Results:
66.51 [INFO]
66.51 [ERROR] Failures:
66.51 [ERROR] RedShift>BrowserSettings.setUp:40 » SessionNotCreated Could not start a new se...
66.51 [INFO]
66.51 [ERROR] Tests run: 3, Failures: 1, Errors: 0, Skipped: 2
66.51 [INFO]
66.51 [INFO] ------------------------------------------------------------------------
66.51 [INFO] BUILD FAILURE
66.51 [INFO] ------------------------------------------------------------------------
66.51 [INFO] Total time: 56.600 s
66.51 [INFO] Finished at: 2024-10-13T21:03:47Z
66.51 [INFO] ------------------------------------------------------------------------
66.51 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project au
tomation: There are test failures.
66.51 [ERROR]
66.51 [ERROR] Please refer to /app/target/surefire-reports for the individual test results.
66.51 [ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
66.51 [ERROR] -> [Help 1]
66.51 [ERROR]
66.51 [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
66.51 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
66.51 [ERROR]
66.51 [ERROR] For more information about the errors and possible solutions, please read the following articles:
66.51 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
------
Dockerfile:17
--------------------
15 |
16 | # Run tests using Maven (optional, can be skipped if not needed)
17 | >>> RUN mvn clean test
18 |
19 | # Package the application as a JAR file using Maven, skipping tests
--------------------
ERROR: failed to solve: process "/bin/sh -c mvn clean test" did not complete successfully: exit code: 1
C:\Users\rahul.y\Desktop\automation_code\beagle\auto-testing>