Reputation: 10768
The App is a hello world created with the NetBeans Payara Micro plugin: it contains nothing but an index.html and a main class that writes "hello world".
I added a dependency in the POM to check that external libraries are handled correctly. I don't want an uber jar so my POM places the libs in a /lib
folder inside the /target
folder
I build the app in NetBeans then open a shell in the /target
folder, deploying with:
java -jar ../payara-micro-5.183.jar myApp.war --addLibs lib/
(following this doc on adding jar files in deployment)
The server launches and the app deploys, but the external libs are missing:
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)
The POM for reference:
<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>
Upvotes: 1
Views: 1445
Reputation: 7695
You need to remove the addClasspath
configuration in your pom.xml file, in the WAR plugin. Then your command with --addLibs
will work.
Your current configuration in the MANIFEST inside the WAR instructs to search for the JARs in the folder where the WAR is located. This doesn't work with Payara Micro, because the WAR file is first copied into a temporary folder before it's deployed. Since the JARs are not in that folder, they're not found.
You need to build a WAR file without classpath specified in MANIFEST and then just use the --addLibs
argument to supply additional JARs.
So if you just remove the following from your pom.xml all should work:
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>net.clementlevallois.qof.back.email.Controller</mainClass>
</manifest>
</archive>
Upvotes: 1