【问题标题】:WildFly Swarm + War + local Jar dependencies in Gradle - NullPointerExceptionGradle 中的 WildFly Swarm + War + 本地 Jar 依赖项 - NullPointerException
【发布时间】:2016-11-13 14:08:21
【问题描述】:

我正在尝试使用 WildFly Swarm 构建 Web 应用程序服务器,并且该应用程序必须能够在内部运行另一个 Java 程序(我不想将其作为外部进程运行)。我正在尝试将外部程序作为 .jar 依赖项包含到我的 Web 应用程序中,但是,wildfly-swarm-package 任务总是失败并显示以下内容:

:clean
:compileJava
:processResources UP-TO-DATE
:classes
:war
:wildfly-swarm-package FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':wildfly-swarm-package'.
> java.lang.NullPointerException (no error message)

这是我的gradle.build 文件:

buildscript {
  version = System.getProperty('swarmVersion') ?: '2016.10.0'

  repositories {
    mavenLocal()
    mavenCentral()
  }

  dependencies {
    classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
    classpath "org.wildfly.swarm:wildfly-swarm-plugin:$version"
  }
}

apply plugin: "io.spring.dependency-management"
apply plugin: 'wildfly-swarm'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'war'

//mainClassName = 'org.siret.prank.webapp.rest.Main'

swarm {
  properties {
    swarm.http.port = 8181
  }
}

repositories {
  mavenLocal()
  mavenCentral()
  maven {
    url 'https://maven.repository.redhat.com/nexus/content/repositories/releases/'
  }
  maven {
    url 'https://maven.repository.redhat.com/nexus/content/repositories/thirdparty-releases/'
  }
  flatDir {
       dirs 'libs'
   }
}

dependencyManagement {
  imports {
    mavenBom "org.wildfly.swarm:bom-all:$version"
  }
}

dependencies {
  compile group: 'org.biojava', name: 'biojava-core', version: '4.2.4'
  compile group: 'org.biojava', name: 'biojava-structure', version: '4.2.4'
  compile "org.wildfly.swarm:jaxrs"
  compile group: 'org.wildfly.swarm', name: 'undertow', version: '2016.10.0'
  compile 'org.codehaus.groovy:groovy-all:2.4.7'
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile fileTree(dir: 'libs/lib', include: ['*.jar'])
}

task debugJar(dependsOn:"wildfly-swarm-package") << {
  javaexec {
    main="-jar";
    args=[
            "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5006",
            "build/libs/prank-webapp-swarm.jar"
    ]
  }
}

task runJar(dependsOn:"wildfly-swarm-package") << {
  javaexec {
    main="-jar";
    args=[
            "build/libs/prank-webapp-swarm.jar"
    ]
  }
}

War 插件工作正常,我可以在存档的 WEB-INF/lib 目录中找到 jars。

作为实验,我尝试清空libs文件夹,但错误仍然存​​在。

谢谢, 卢卡斯

【问题讨论】:

  • 不幸的是,我们对 Gradle 插件的支持不是很好,因为我们都是 Maven 用户,所以我们都不熟悉它。您试图在 WF Swarm 中运行的程序是什么?也许有不同的方法?

标签: java gradle war wildfly-swarm


【解决方案1】:

我迁移到 Maven 发现 importing jar to local maven repository 是问题的答案。

现在,Maven 和 Gradle 都可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    • 2018-02-20
    相关资源
    最近更新 更多