0

I'm trying to use playwright to generate pdfs in my java application. This is working fine locale but when deploying it on an ec2 using Beanstalk I get the following error:

Nov 11 09:17:32 ip-172-xx-xx-2 web: 2021-11-11 09:17:32.927 ERROR 17681 --- [io-5000-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.microsoft.playwright.PlaywrightException: Error {
Nov 11 09:17:32 ip-172-xx-xx-2 web: message='Host system is missing dependencies!
Nov 11 09:17:32 ip-172-xx-xx-2 web: Missing libraries are:
Nov 11 09:17:32 ip-172-xx-xx-2 web: libatk-1.0.so.0
Nov 11 09:17:32 ip-172-xx-xx-2 web: libatk-bridge-2.0.so.0
Nov 11 09:17:32 ip-172-xx-xx-2 web: libcups.so.2
Nov 11 09:17:32 ip-172-xx-xx-2 web: libxkbcommon.so.0
Nov 11 09:17:32 ip-172-xx-xx-2 web: libXcomposite.so.1
...

And of course, the error message is pretty straightforward. Dependencies are missing! I already got to know that I can install these dependencies via the CLI tools, but I have no idea where to install it and how in my build process via CodePipeline with CodeBuild and CodeDeploy. This is the command which you can find here: https://playwright.dev/java/docs/cli/#install-system-dependencies

mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install-deps"

So the question is: Where and how do I install the Playwright dependency in my CodePipeline to run it on ec2 using beanstalk?

Thanks in advance!

FloHiwg
  • 61
  • 7

1 Answers1

0

Dependencies are missing!

OK, so instead of having to worry about dependencies, why not just package them together with the code of your app into an Uber Jar

This can be done quiet easily using mnv. You configure Maven to build a Fat JAR from your project by including the maven-assembly-plugin in your POM file's plugin section.

Add this to your pom.xml

configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>

            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>

And then run mvn clean package. This will package your dependencies into your jar and it will be impossible for them to go missing.

Here's a link with some more details on the topic

Does this solve your problem ? Let me know in the comments

Arthur Klezovich
  • 2,595
  • 1
  • 13
  • 17
  • Tried it but without any success. Thank u though – FloHiwg Nov 11 '21 at 12:31
  • What's the output ? What's the contents of the JAR ? Do you get the same error when deploying ? – Arthur Klezovich Nov 11 '21 at 12:41
  • I'm pretty much stuck one step before. I'm not even able to deploy it because it's stuck in the pipeline with some weird errors that it's not possible to identify the jar. Locally I'm getting the same error as before – FloHiwg Nov 11 '21 at 13:56