Payara micro error: In TLD scanning, the supplied resource file does not exist

Payara micro error: In TLD scanning, the supplied resource file does not exist

该应用程序是一个使用 NetBeans Payara Micro 插件创建的 hello world:它只包含一个 index.html 和一个写入 "hello world".

的主要 class

我在 POM 中添加了一个依赖项来检查外部库是否得到正确处理。我不想要超级 jar,所以我的 POM 将库放在 /target 文件夹

内的 /lib 文件夹中

我在 NetBeans 中构建应用程序,然后在 /target 文件夹中打开一个 shell,并使用以下方式进行部署:

java -jar ../payara-micro-5.183.jar myApp.war --addLibs lib/

(关注 this doc on adding jar files in deployment

服务器已启动且应用已部署,但缺少外部库:

  PWC6351: In TLD scanning, the supplied resource file:/C:/Users/LEVALL~1/AppData/Local/Temp/payaramicro-rt8447922723645389161tmp/applications/lib/utils-1.0.jar does not exist
java.io.FileNotFoundException: C:\Users\LEVALL~1\AppData\Local\Temp\payaramicro-rt8447922723645389161tmp\applications\lib\utils-1.0.jar (Le chemin dÆaccÞs spÚcifiÚ est introuvable)
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.zip.ZipFile.<init>(Unknown Source)
        at java.util.jar.JarFile.<init>(Unknown Source)

供参考的POM:

<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>

    <groupId>net.clementlevallois</groupId>
    <artifactId>qof-back-email</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>qof-back-email</name>

    <properties>
        <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.javaee>8.0</version.javaee>
        <version.payara>5.183</version.payara>
        <version.microprofile>2.0.1</version.microprofile>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>utils</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>${version.javaee}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile</groupId>
            <artifactId>microprofile</artifactId>
            <version>${version.microprofile}</version>
            <scope>provided</scope>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>net.clementlevallois.qof.back.email.Controller</mainClass>
                        </manifest>
                    </archive>

                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>install</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>                            
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

您需要删除 pom.xml 文件中 WAR 插件中的 addClasspath 配置。然后你的命令 --addLibs 将起作用。

您在 WAR 内的 MANIFEST 中的当前配置指示在 WAR 所在的文件夹中搜索 JAR。这不适用于 Payara Micro,因为 WAR 文件在部署之前首先被复制到一个临时文件夹中。由于 JAR 不在该文件夹中,因此找不到它们。

您需要在 MANIFEST 中构建一个没有指定类路径的 WAR 文件,然后只需使用 --addLibs 参数来提供额外的 JAR。

因此,如果您只是从 pom.xml 中删除以下内容,一切都应该有效:

<archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>net.clementlevallois.qof.back.email.Controller</mainClass> </manifest> </archive>