如何使用 Maven 将 jar 部署到 JBPM Business Central?

How to deploy a jar with Maven to JBPM Business Central?

当执行 mvn deploy 将 jar 工件推送到已安装的 JBPM KIE Workbench 我得到:Return 代码是:401,ReasonPhrase: Unauthorized

为什么服务器没有授予我访问权限?

要重现请执行以下操作:

使用此处的 docker 图像安装新的 Business Central Installation(KIE Server 7.18.0.Final 和相应的 jBPM Workbench 7.18.0.Final):https://hub.docker.com/r/jboss/jbpm-server-full. Access after startup the webpage http://localhost:8080/business-central/ 并使用默认帐户登录:wbadmin/wbadmin.

使用此 POM 创建一个新示例 Maven Java 项目:

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

    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>

    <groupId>com.sample</groupId>
    <artifactId>project</artifactId>
    <version>1.0.0</version>
    <packaging>kjar</packaging>

    <distributionManagement>
        <!-- don't forget to add the server credentials to your settings.xml -->
        <repository>
            <id>jguvnor-m2-repo</id>
            <name>JBPM Workbench Repo</name>
            <url>http://localhost:8080/business-central/maven2/</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.kie</groupId>
                <artifactId>kie-maven-plugin</artifactId>
                <version>7.18.0.Final</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

将 repo 服务器的凭据添加到您的 maven settings.xml

...
    <server>
        <id>guvnor-m2-repo</id>
        <username>wbadmin</username>
        <password>wbadmin</password>

        <configuration>
            <wagonProvider>httpclient</wagonProvider>
            <httpConfiguration>
                <all>
                    <usePreemptive>true</usePreemptive>
                </all>
            </httpConfiguration>
        </configuration>
    </server>
...

现在使用部署目标构建 maven 项目

mvn deploy

您遇到错误:

[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.618 s
[INFO] Finished at: 2019-05-05T13:07:39+02:00
[INFO] Final Memory: 42M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:3.0.0-M1:deploy (default-deploy) on project jbpmproject: ArtifactDeployerException: Failed to deploy artifacts: Could not transfer artifact com.sample:project:jar:1.0.0 from/to jguvnor-m2-repo (http://localhost:8080/business-central/maven2/): Failed to transfer file: http://localhost:8080/business-central/maven2/com/sample/project/1.0.0/project-1.0.0.jar. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

通过 Workbench Web 前端手动上传 jar 效果很好。

我也尝试在 settings.xml 配置中使用 BASIC Auth,如下所述:https://issues.jboss.org/browse/RHBRMS-2261 但也没有成功。

问题是一个简单的拼写错误:使用 <id>guvnor-m2-repo</id> 而不是 <id>jguvnor-m2-repo</id>,以便与 settings.xml 文件的 ID 相匹配。