1

I am trying to deploy a war file on a remote JBoss 5.1.0.GA container, using a gradle build file and the Gradle Cargo plugin by Benjamin Muschko (https://github.com/bmuschko/gradle-cargo-plugin).

I am experiencing a java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory when launching the cargoDeployRemote task on a very simple project. The post about Cargo deployment on a JBoss 5.1.0.GA using Maven plugin helped me setting up the dependencies. The missing class NamingContextFactory is also defined inside the jboss-as-varia dependency for example. Obviously, I must be missing something.

The project is only a folder with the following Gradle script, nothing more. I must add that I run the build script from inside a linux virtual machine, a virtualbox guest running ArchLinux, and I want to remotely deploy on a JBoss 5.1.0.GA server running on the host. I am able to access the JBoss via the gateway address (10.0.2.2) from the guest, so I guess this is not the issue here.

I tried to provide the most simple gradle build file for showing this problem. Any clue on what should be done to make this work ? Any help appreciated.

Here's my build.gradle file:

apply plugin: 'war'
apply plugin: 'com.bmuschko.cargo'

buildscript {

    repositories {
        mavenCentral()
    }

    dependencies {
        classpath 'com.bmuschko:gradle-cargo-plugin:2.1.1'
    }

}

repositories {

   mavenCentral()

   dependencies {
        providedCompile 'org.jboss.jbossas:jboss-as-jbossas-remoting:5.1.0.GA'
        providedCompile 'org.jboss.jbossas:jboss-as-client:5.1.0.GA'
        providedCompile 'org.jboss.jbossas:jboss-as-varia:5.1.0.GA'
        providedCompile 'org.jboss.integration:jboss-profileservice-spi:5.1.0.GA'
   }

}

cargo {

    containerId = 'jboss51x'
    port = 8080

    remote {
      username = "admin"
      password = "admin"
      hostname = "10.0.2.2"
    }

    deployable {
        context = 'myawesomewebapp'
    }
}

Here's is the output for 'gradle cargoDeployRemote -i' showing the error:

Executing task ':cargoDeployRemote' (up-to-date check took 0.002 secs) due to: Task.upToDateWhen is false. Container ID = jboss51x Deployable artifacts = [/home/gerald/testapp/build/libs/testapp.war] Starting action 'deploy' for remote container 'JBoss 5.1.x' on 'http://10.0.2.2:8080' Container properties = [:] :cargoDeployRemote FAILED :cargoDeployRemote (Thread[Daemon worker Thread 14,5,main]) completed. Took 0.588 secs.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':cargoDeployRemote'. org.codehaus.cargo.container.ContainerException: Failed to create deployer with implementation class org.codehaus.cargo.container.jboss.JBoss51xRemoteDeployer for the parameters (container [id = [jboss51x]], deployer type [remote]).

And here is the exception:

Caused by: org.codehaus.cargo.container.ContainerException: Failed to create deployer with implementation class org.codehaus.cargo.container.jboss.JBoss51xRemoteDeployer for the parameters (container [id = [jboss51x]], deployer type [remote]).
    at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImplementation(AbstractGenericHintFactory.java:156)
    at org.codehaus.cargo.generic.spi.AbstractIntrospectionGenericHintFactory.createImplementation(AbstractIntrospectionGenericHintFactory.java:93)
    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:140)
    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createDeployer(DefaultDeployerFactory.java:160)
    at org.codehaus.cargo.ant.CargoTask.executeActions(CargoTask.java:758)
    at org.codehaus.cargo.ant.CargoTask.execute(CargoTask.java:577)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    ... 70 more
Caused by: java.lang.reflect.InvocationTargetException
    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:244)
    at org.codehaus.cargo.generic.deployer.DefaultDeployerFactory.createInstance(DefaultDeployerFactory.java:42)
    at org.codehaus.cargo.generic.spi.AbstractGenericHintFactory.createImplementation(AbstractGenericHintFactory.java:150)
    ... 77 more
Caused by: org.codehaus.cargo.util.CargoException: Cannot locate the JBoss connector classes! Make sure the required JBoss JARs (or Maven dependencies) are in CARGO's classpath.
More information on: http://cargo.codehaus.org/JBoss+Remote+Deployer
    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:161)
    at org.codehaus.cargo.container.jboss.JBoss51xRemoteDeployer.<init>(JBoss51xRemoteDeployer.java:41)
    ... 80 more
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
    at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366)
    at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1315)
    at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1068)
    at org.codehaus.cargo.container.jboss.JBoss5xRemoteDeployer.<init>(JBoss5xRemoteDeployer.java:156)
    ... 81 more
Community
  • 1
  • 1
GeraldM
  • 11
  • 2
  • Your repositories.dependencies.providedCompile seems misplaced. These should probably be buildscript.dependencies.classpath . That said I have the same issue with java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory and would be grateful if you share any answers you found here. – Farrukh Najmi Oct 08 '15 at 17:51

1 Answers1

0

I found the answer following resources:

The summary of what I had to do to fix the problem is that I had to have cargo dependencies as cargo configuration in first level dependencies closure (not buildscript.dependencies closure).

apply plugin: 'ear'
apply plugin: 'com.bmuschko.cargo'  

buildscript {  
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.bmuschko:gradle-cargo-plugin:2.2.1'        
    }
}

repositories {
    //Order of repositories is significant and will effect finding of jaas module
    maven {
        name = "JBoss Deprecated Maven Repository"
        url = "https://repository.jboss.org/nexus/content/repositories/deprecated"
    }
    maven {
        url 'https://repository.jboss.org/nexus/content/groups/public/'
    }        
    maven {
        name = "JBoss.org third party releases repository"
        url = "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases"
    }  
    mavenCentral()
    jcenter()
}

dependencies {
    // My app specific modules taken out from here

    def cargoVersion = '1.4.5'
    cargo "org.codehaus.cargo:cargo-core-uberjar:$cargoVersion",
          "org.codehaus.cargo:cargo-ant:$cargoVersion"    
    cargo 'org.jboss.jbossas:jboss-as-jbossas-remoting:5.1.0.GA'
    cargo 'org.jboss.jbossas:jboss-as-client:5.1.0.GA'
    cargo 'org.jboss.jbossas:jboss-as-varia:5.1.0.GA'
    cargo 'org.jboss.integration:jboss-profileservice-spi:5.1.0.GA'
}

cargo {
    containerId = 'jboss51x'
    port = 8009

    remote {
        hostname = project.hostname
        username = project.username
        password = project.password
    }
}
Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54