Closed arkasandr closed 3 years ago
The error suggests that com.microsoft.playwright.impl.DriverJar
which is provided by driver-bundle module is not on the class path. If you manually configure which jar files are passed to java vm you need to make sure to include all playwright dependencies from pom.xml.
" If you manually configure which jar files are passed to java vm you need to make sure to include all playwright dependencies from pom.xml." no manually config. i use spring-boot-maven-plugin to for install
i think it fails when calling (Driver)jarDriver.getDeclaredConstructor().newInstance(); and try to get DriverJar instance
i think it fails when calling (Driver)jarDriver.getDeclaredConstructor().newInstance(); and try to get DriverJar instance
Correct, and it fails because the DriverJar is not in the classpath (most likely you didn't inlcude driver-bundle.jar into the class path).
@yury-s thanks! i add manually to project /lib and use
ENTRYPOINT exec java -cp target/myApp-1.0.jar -Dloader.path=lib/ org.springframework.boot.loader.PropertiesLauncher
to execute jar file.
Now I try to build dockerfile and have another problem
Caused by: com.microsoft.playwright.PlaywrightException: Error: Host system is missing dependencies!
with list of missing dependencies....
what can be wrong now?
Now I try to build dockerfile and have another problem
Caused by: com.microsoft.playwright.PlaywrightException: Error: Host system is missing dependencies!
with list of missing dependencies.... what can be wrong now?
The message should contain detailed explanation. It's hard to tell without seeing the exact error but my hunch is that this has something to do with browser dependencies. Please use our docker file or the one that published on DockerHub to ensure the deps are preinstalled.
@yury-s thanks for the help. I only add some code to start my spring-boot application at the end of this Dockerfile. May be I mixed directories and my app not find these libraries. This is my Dockerfile
`FROM ubuntu:focal WORKDIR /usr/app
RUN apt-get update && apt-get install -y --no-install-recommends \ libwoff1 \ libopus0 \ libwebp6 \ libwebpdemux2 \ libenchant1c2a \ libgudev-1.0-0 \ libsecret-1-0 \ libhyphen0 \ libgdk-pixbuf2.0-0 \ libegl1 \ libnotify4 \ libxslt1.1 \ libevent-2.1-7 \ libgles2 \ libxcomposite1 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libepoxy0 \ libgtk-3-0 \ libharfbuzz-icu0
RUN apt-get update && apt-get install -y --no-install-recommends \ libgstreamer-gl1.0-0 \ libgstreamer-plugins-bad1.0-0 \ gstreamer1.0-plugins-good \ gstreamer1.0-libav
RUN apt-get update && apt-get install -y --no-install-recommends \ libnss3 \ libxss1 \ libasound2 \ fonts-noto-color-emoji \ libxtst6
RUN apt-get update && apt-get install -y --no-install-recommends \ libdbus-glib-1-2 \ libxt6
RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg
RUN apt-get update && apt-get install -y --no-install-recommends \ xvfb
RUN apt-get update && apt-get install -y --no-install-recommends \ openjdk-8-jdk maven
RUN apt-get update && apt-get install -y --no-install-recommends \ curl unzip
RUN mkdir /tmp/pw-java COPY . /tmp/pw-java RUN cd /tmp/pw-java && chmod 755 ./scripts/download_driver_for_all_platforms.sh && \ mvn install -D skipTests --no-transfer-progress && \ rm -rf /tmp/pw-java
FROM openjdk:11 as backend RUN apt-get update && apt-get install maven -y WORKDIR /backend COPY / . ADD /lib /lib RUN mvn install
ENTRYPOINT exec java -cp target/mosPropBot-1.0.jar -Duser.timezone=UTC -Dloader.path=lib/ org.springframework.boot.loader.PropertiesLauncher
`
And now I have this stack trace
`mos-prop-bot | 2021-02-09 15:31:47.641 ERROR 1 --- [ main] o.s.boot.SpringApplication : Application run failed
mos-prop-bot | mos-prop-bot | java.lang.IllegalStateException: Failed to execute CommandLineRunner mos-prop-bot | at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:782) mos-prop-bot | at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:763) mos-prop-bot | at org.springframework.boot.SpringApplication.run(SpringApplication.java:318) mos-prop-bot | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) mos-prop-bot | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) mos-prop-bot | at ru.cnd.Application.main(Application.java:10) mos-prop-bot | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) mos-prop-bot | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) mos-prop-bot | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) mos-prop-bot | at java.base/java.lang.reflect.Method.invoke(Method.java:566) mos-prop-bot | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:47) mos-prop-bot | at org.springframework.boot.loader.Launcher.launch(Launcher.java:86) mos-prop-bot | at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) mos-prop-bot | at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:577) mos-prop-bot | Caused by: com.microsoft.playwright.PlaywrightException: Error: Host system is missing dependencies! mos-prop-bot | mos-prop-bot | Missing libraries are: mos-prop-bot | libgobject-2.0.so.0 mos-prop-bot | libglib-2.0.so.0 mos-prop-bot | libatk-1.0.so.0 mos-prop-bot | libatk-bridge-2.0.so.0 mos-prop-bot | libgio-2.0.so.0 mos-prop-bot | libdrm.so.2 mos-prop-bot | libxkbcommon.so.0 mos-prop-bot | libXcomposite.so.1 mos-prop-bot | libXdamage.so.1 mos-prop-bot | libXfixes.so.3 mos-prop-bot | libXrandr.so.2 mos-prop-bot | libgbm.so.1 mos-prop-bot | libgtk-3.so.0 mos-prop-bot | libgdk-3.so.0 mos-prop-bot | libpango-1.0.so.0 mos-prop-bot | libcairo.so.2 mos-prop-bot | libgdk_pixbuf-2.0.so.0 mos-prop-bot | libatspi.so.0 mos-prop-bot | libxshmfence.so.1 mos-prop-bot | mos-prop-bot | Note: use DEBUG=pw:api environment variable and rerun to capture Playwright logs. mos-prop-bot | at com.microsoft.playwright.impl.WaitableResult.get(WaitableResult.java:50) mos-prop-bot | at com.microsoft.playwright.impl.ChannelOwner.runUntil(ChannelOwner.java:88) mos-prop-bot | at com.microsoft.playwright.impl.Connection.sendMessage(Connection.java:74) mos-prop-bot | at com.microsoft.playwright.impl.ChannelOwner.sendMessage(ChannelOwner.java:79) mos-prop-bot | at com.microsoft.playwright.impl.BrowserTypeImpl.launchImpl(BrowserTypeImpl.java:44) mos-prop-bot | at com.microsoft.playwright.impl.BrowserTypeImpl.lambda$launch$0(BrowserTypeImpl.java:36) mos-prop-bot | at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:51) mos-prop-bot | at com.microsoft.playwright.impl.BrowserTypeImpl.launch(BrowserTypeImpl.java:36) mos-prop-bot | at com.microsoft.playwright.impl.BrowserTypeImpl.launch(BrowserTypeImpl.java:29) mos-prop-bot | at ru.cnd.config.BrowserInitialize.launchBrowser(BrowserInitialize.java:15) mos-prop-bot | at ru.cnd.config.ServiceInitialize.lambda$configAuthentication$0(ServiceInitialize.java:35) mos-prop-bot | at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:779) mos-prop-bot | ... 13 common frames omitted `
I didn't find any decision yet for this problem. I cannot execute jar file with my spring-boot service using playwright.
I found that getResource() causes this exception, but I'm not sure that it is my case. This method in DriverJar.class has such code
private void extractDriverToTempDir() throws URISyntaxException, IOException { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); URI uri = classloader.getResource("driver/" + platformDir()).toURI();
Please, how can I run my jar file correctly or find the reason of such exception?