我正在尝试使用 Open Liberty 18.0.0.4 为 MicroProfile 2.1 应用程序构建一个可运行的 jar。我从 guide-getting-started 中复制了大部分代码,并将版本号从 18.0.03 更新为 18.0.0.4。但是,未构建可运行的 Jar,我在package-server步骤中得到以下输出:
[INFO] --- liberty-maven-plugin:2.6.1:package-server (package-server) @ cloud.service.repository ---
[INFO] CWWKM2102I: Using artifact based assembly archive : io.openliberty:openliberty-runtime:null:18.0.0.4:zip.
[INFO] CWWKM2102I: Using installDirectory : /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp.
[INFO] CWWKM2102I: Using serverName : RepositoryService.
[INFO] CWWKM2102I: Using serverDirectory : /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/usr/servers/RepositoryService.
[INFO] CWWKM2112I: Re-using previously installed assembly.
[INFO] CWWKM2134I: Packaging server RepositoryService.
[INFO] Copying 1 file to /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/usr/servers/RepositoryService
[INFO] CWWKM2144I: Update server configuration file server.xml from /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/src/main/liberty/config/server.xml.
[INFO] CWWKM2144I: Update server configuration file bootstrap.properties from inlined configuration.
[INFO] CWWKM2136I: Package file location is /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/cloud.service.repository.zip.
[INFO] CWWKM2001I: server.config.dir is /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/usr/servers/RepositoryService.
[INFO] CWWKM2001I: server.output.dir is /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty-alt-output-dir/RepositoryService.
[INFO] CWWKM2001I: Invoke command is [/home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/bin/server, package, RepositoryService, --archive=/home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/cloud.service.repository.zip, --include=minify,runnable].
[INFO]
[INFO] Packaging server RepositoryService.
[INFO] Querying server RepositoryService for content.
[INFO] Launching RepositoryService (Open Liberty 18.0.0.4/wlp-1.0.23.cl180420181121-0300) on Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_192-b12 (en_US)
[INFO] [AUDIT ] CWWKE0001I: The server RepositoryService has been launched.
[INFO] [WARNING ] CWWKF0024W: The feature com.ibm.websphere.appserver.kernel-1.0 referenced a resource com.ibm.ws.config.utility/[1.0.0,1.0.100) that was unable to be located during a packaging query.
[INFO] [AUDIT ] CWWKF0012I: The server installed the following features: [jsonb-1.0, servlet-4.0, jsonp-1.1, jaxrsClient-2.1, jaxrs-2.1].
[INFO] [AUDIT ] CWWKF0026I: The server RepositoryService is ready to build a smaller package.
[INFO] [AUDIT ] CWWKE1100I: Waiting for up to 30 seconds for the server to quiesce.
[INFO] [AUDIT ] CWWKE0036I: The server RepositoryService stopped after 1.386 seconds.
[INFO] Building archive for server RepositoryService.
[INFO] CWWKE0070W: The loose file /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/usr/servers/RepositoryService/apps/cloud.service.repository.war.xml is invalid.
[INFO] Server RepositoryService package complete in /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/cloud.service.repository.zip.
关键部分是消息The loose file /home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty/wlp/usr/servers/RepositoryService/apps/cloud.service.repository.war.xml is invalid.
它似乎破坏了一切,因为构建步骤的结果是一个 zip 文件而不是一个可运行的 Jar。以下是它声称无效的文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<archive>
<dir sourceOnDisk="/home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/src/main/webapp" targetInArchive="/"/>
<dir sourceOnDisk="/home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/classes" targetInArchive="/WEB-INF/classes"/>
<file sourceOnDisk="/home/thor/.m2/repository/com/knime/enterprise/cloud.service.repository.api/0.0.1-SNAPSHOT/cloud.service.repository.api-0.0.1-SNAPSHOT.jar" targetInArchive="/WEB-INF/lib/cloud.service.repository.api-0.0.1-SNAPSHOT.jar"/>
<file sourceOnDisk="/home/thor/.m2/repository/javax/ws/rs/javax.ws.rs-api/2.1/javax.ws.rs-api-2.1.jar" targetInArchive="/WEB-INF/lib/javax.ws.rs-api-2.1.jar"/>
<file sourceOnDisk="/home/thor/workspace/KNIME-trunk/git/knime-repository-service/com.knime.enterprise.cloud.service.repository/target/liberty-maven/resources/META-INF/MANIFEST.MF" targetInArchive="/META-INF/MANIFEST.MF"/>
</archive>
我在这里看不到任何无效的东西。此外,如果我使用 18.0.0.3 作为assemblyArtifact
pom.xml 中的版本,则相同的过程可以正常工作。
liberty-maven-plugin
这是我正在使用的完整配置:
<plugin>
<groupId>net.wasdev.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<assemblyArtifact>
<groupId>io.openliberty</groupId>
<artifactId>openliberty-runtime</artifactId>
<version>${version.openliberty-runtime}</version>
<type>zip</type>
</assemblyArtifact>
<serverName>${serverName}</serverName>
<stripVersion>true</stripVersion>
<looseApplication>true</looseApplication>
<installAppPackages>project</installAppPackages>
<configFile>src/main/liberty/config/server.xml</configFile>
<packageFile>${package.file}</packageFile>
<include>${packaging.type}</include>
<bootstrapProperties>
<default.http.port>${http.port}</default.http.port>
<default.https.port>${https.port}</default.https.port>
<app.context.root>${warContext}</app.context.root>
</bootstrapProperties>
</configuration>
<executions>
<execution>
<id>stop-server-before-clean</id>
<phase>pre-clean</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
<execution>
<id>create-server</id>
<phase>prepare-package</phase>
<goals>
<goal>install-server</goal>
<goal>create-server</goal>
</goals>
</execution>
<execution>
<id>install-feature</id>
<phase>prepare-package</phase>
<goals>
<goal>install-feature</goal>
</goals>
<configuration>
<outputDirectory>target/liberty-alt-output-dir</outputDirectory>
</configuration>
</execution>
<execution>
<id>install-apps</id>
<phase>package</phase>
<goals>
<goal>install-apps</goal>
</goals>
</execution>
<execution>
<id>package-server</id>
<phase>package</phase>
<goals>
<goal>package-server</goal>
</goals>
<configuration>
<outputDirectory>target/liberty-alt-output-dir</outputDirectory>
</configuration>
</execution>
<execution>
<id>test-start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>test-start-server</goal>
</goals>
</execution>
<execution>
<id>test-stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>test-stop-server</goal>
</goals>
</execution>
/executions>
</plugin>