0

I am trying to build a web application server using WildFly Swarm and the application has to be able to run another Java program inside (I don't want to run it as an external process). I am trying to include the external program as .jar dependency to my web application, however, wildfly-swarm-package task always fails with the following:

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

This is my gradle.build file:

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 plugin works fine, I can find the jars in WEB-INF/lib directory in the archive.

As an experiment, I tried to empty the libs folder and the error still persists.

Thanks, Lukas

  • Unfortunately our support for the Gradle plugin is not that great as none of us are familiar with it as we're Maven users. What is the program you're trying to run inside WF Swarm doing? Maybe there's a different approach? – Ken Nov 14 '16 at 13:50

1 Answers1

0

I migrated to Maven to find out that importing jar to local maven repository is the answer to the problem.

Now, both Maven an Gradle work.