Reputation: 147
my java app work correct on local ubuntu without docker with: JDK 11, Spring Boot, Selenium 4.0.0-rc-1, Chromium 97.0.4692.99, ChromeDriver 96.0.4664.45
my java app dont work when i migrate it to docker (alpine) with: JDK 11, Spring Boot, Selenium 4.0.0-rc-1, Chromium 93.0.4577.82, ChromeDriver 93.0.4577.63 (but app works fine on docker with ubuntu and chrome - now i have to migrate it to alpine and chromium)
My java driver fragment code (of course i have more standard options like --headless etc):
String chromeDriverLinux = "./config/driver/chromedriver-linux/chromedriver"; //
here is file in target version (93.0.4577.63 for docker)
final ChromeOptions options = new ChromeOptions();
options.addArguments("--remote-debugging-port=9222");
/* commented on non-docker version - i think it may be needed by docker version
when i execute it on local non-docker ver i received error:
Caused by: java.util.concurrent.ExecutionException:
java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:21933
after 180000 ms
*/
options.addArguments("--remote-debugging-address=0.0.0.0");
options.setBinary("/usr/bin/chromium-browser");
ChromiumDriver driver = null;
driver = new ChromeDriver(options); // here is exception
app exception log:
driver exception:
org.openqa.selenium.SessionNotCreatedException: Could not start a new session.
Possible causes are invalid address of the remote server or browser start-up failure.
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:565) ~
[selenium-remote-driver-4.0.0-rc-1.jar!/:?]
...
Caused by: org.openqa.selenium.WebDriverException: Driver server process died
prematurely.
Build info: version: '4.0.0-rc-1', revision: 'bc5511cbda'
System info: host: '5c0bff50d486', ip: '172.17.0.2', os.name: 'Linux', os.arch:
'amd64', os.version: '5.13.0-27-generic', java.version: '11.0.14'
Driver info: driver.version: ChromeDriver
pom.xml:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-devtools</artifactId>
<version>${selenium.version}</version>
</dependency>
Dockerfile:
FROM azul/zulu-openjdk-alpine:11
RUN addgroup -S spring && adduser -S spring -G spring
RUN mkdir -p config/driver/chromedriver-linux
RUN find config/driver/chromedriver-linux/ -type d -exec chmod 0777 {} \;
RUN find config/driver/chromedriver-linux/ -type f -exec chmod 777 {} \;
ADD config/ /config/
RUN chmod 0777 /config/driver/chromedriver-linux/chromedriver
RUN apk update && apk add --no-cache bash \
alsa-lib \
at-spi2-atk \
atk \
cairo \
cups-libs \
dbus-libs \
eudev-libs \
expat \
flac \
gdk-pixbuf \
glib \
libgcc \
libjpeg-turbo \
libpng \
libwebp \
libx11 \
libxcomposite \
libxdamage \
libxext \
libxfixes \
tzdata \
libexif \
udev \
xvfb \
zlib-dev \
chromium \
chromium-chromedriver \
&& rm -rf /var/cache/apk/* \
/usr/share/man \
/tmp/*
USER spring:spring
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} bot-app.jar
ENTRYPOINT ["java","-jar","/bot-app.jar"]
EXPOSE 9223 9222
Run dockerfile:
sudo docker build --no-cache=True -t bot-image .
run container:
sudo docker network create app_bot_network
sudo docker run --network app_bot_network -p 8080:8080 -p 4444:4444 -p 9223:9222 -p 6900:5900 -it --rm --name bot-container bot-image:latest
I also turned off firewall and vpn before start docker.
So, what is problem with error: SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure. ?
it's rather no driver problem version, sth with settings of docker ports, network... ? Or sth with execution of browser ?
regards
Upvotes: 0
Views: 1487
Reputation: 147
I spent some time on it and found solution.
I changed in my java code from:
String chromeDriverLinux = "./config/driver/chromedriver-linux/chromedriver";
(here i had most similar ChromeDriver 93.0.4577.63 version i copy myself)
to:
String chromeDriverLinux = "/usr/bin/chromedriver";
(here i have exactly the same driver version as browser installed by dockerfile apk 93.0.4577.82)
I had strange error exception instead of that driver version is miscellaneous that browser version
Upvotes: 0