Skip to content

[BUG]Caused by: java.nio.file.ProviderNotFoundException: Provider "jar" not found #922

@zhangxin1932

Description

@zhangxin1932

Context:

  • Playwright Version: [1.21.0]
  • Operating System: [CentOS Linux release 7.9.2009]
  • Browser: [Firefox, bundle]
  • Jdk: [
    openjdk version "1.8.0_322"
    OpenJDK Runtime Environment (build 1.8.0_322-b06)
    OpenJDK 64-Bit Server VM (build 25.322-b06, mixed mode)
    ]
  • Extra: []

Code Snippet

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>jar</packaging>
    <groupId>com.zy</groupId>
    <artifactId>hello-world</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.microsoft.playwright</groupId>
            <artifactId>playwright</artifactId>
            <version>1.21.0</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>hello-playwright</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <!-- Configuration of the archiver -->
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                    <excludes>
                        <exclude>**/assembly/</exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/resources/assembly/package.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

src/main/resources/assembly/package.xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly>
    <id>full</id>
    <formats>
        <format>zip</format>
    </formats>
    <dependencySets>
        <dependencySet>
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>lib</outputDirectory>

            <!--<unpack>false</unpack>-->
        </dependencySet>
    </dependencySets>

    <fileSets>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>lib</outputDirectory>
            <includes>
                <include>*.jar</include>
            </includes>
        </fileSet>
    </fileSets>
</assembly>
import com.microsoft.playwright.*;

import java.util.concurrent.TimeUnit;

public class PlayWrightDemo01 {

    public static void main(String[] args) throws Exception {
        try (Playwright playwright = Playwright.create()) {
            Browser browser = playwright.firefox().launch(new BrowserType.LaunchOptions().setHeadless(true).setSlowMo(50));
            Page page = browser.newPage();
            page.navigate("https://www.baidu.com");
            TimeUnit.SECONDS.sleep(60L);
        }
    }
}

Describe the bug

java.lang.RuntimeException: Failed to create driver
	at com.microsoft.playwright.impl.Driver.ensureDriverInstalled(Driver.java:61)
	at com.microsoft.playwright.impl.PlaywrightImpl.create(PlaywrightImpl.java:40)
	at com.microsoft.playwright.Playwright.create(Playwright.java:96)
	at com.microsoft.playwright.Playwright.create(Playwright.java:100)
	// this is business code, omitted...
Caused by: java.nio.file.ProviderNotFoundException: Provider "jar" not found
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:341)
	at java.nio.file.FileSystems.newFileSystem(FileSystems.java:276)
	at com.microsoft.playwright.impl.DriverJar.extractDriverToTempDir(DriverJar.java:91)
	at com.microsoft.playwright.impl.DriverJar.initialize(DriverJar.java:45)
	at com.microsoft.playwright.impl.Driver.ensureDriverInstalled(Driver.java:57)
	... 9 common frames omitted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions