Unable to deploy multiple projects (generated using gradle) to glassfish from within eclipse Juno


(Chirag Patel) #1

I am using gradle to set up multi-project build. I have following folder layout for projects:

---RootProject
---- build.gradle
---- settings.gradle
------ JarProject (Utility)
 --------- build.gradle
------ JpaProject (Dependency on JarProject)
--------- build.gradle
------ EjbProject (Dependency on JarProject, JpaProject)
--------- build.gradle
------ WebProject (Dependency on EjbProject)
--------- build.gradle

Tools & Technologies

Gradle: 1.6 Java: 1.7 Eclipse: Juno Server: Glassfish 3.1.2.2

I have created multi-project build for the above folder layout. Gradle is able to generate eclipse meta-data for each of the project and I am able to import all projects in to eclipse. Gradle is able to correctly generate “.ear” artifact.

However, I am unable to deploy Ear project from eclipse. During deployment eclipse gives NullPointerException.

In order to tell Gradle to generate appropriate facet for EarProject, EjbProject and JpaProject, I have added following code:

  1. EarProject/build.gradle
apply plugin: 'ear'
apply plugin: 'eclipse-wtp'
eclipse {
    wtp {
       facet {
        facet name:'jst.ear', version:'6.0'
       }
    }
}
  1. EjbProject/build.gradle
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
eclipse {
    wtp {
       facet {
        facet name:'jst.ejb', version:'3.1'
       }
    }
}
  1. JpaProject/build.gradle
apply plugin: 'war'
 apply plugin: 'eclipse-wtp'
   eclipse {
     wtp {
              facet {
                   facet name:'java', version:'1.6' facet name:'jpt.jpa', version:'2.0'
              }
     }
 }
  1. WebProject/build.gradle
apply plugin: 'war'
 apply plugin: 'eclipse-wtp'
 eclipse {
        wtp {
             facet {
                   facet name:'java', version:'1.6' facet name:'jst.web', version:'3.0' facet name:'wst.jsdt.web', version:'1.0'
             }
        }
 }

Notice that even though EjbProject and JpaProject are not Web projects, plugin ‘war’ is applied to configure wtp settings. Because of this gradle thinks that EjbProject and JpaProject are web projects and creates eclipse meta data accordingly.

For EjbProject/JpaProject, the file “org.eclipse.wst.common.component” has following content

<property name="context-root" value="prj-context"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>

Due to this, when I export the EjbProject/JpaProject to ejb-jar or jar file, the eclipse does not include appropriate classes in the jar file.

Another issue is that I am unable to export EarProject to “.ear” file using eclipse “File->Export->Ear File”. I get an exception. When I try to deploy EarProject from within eclipse, it gives NullPointerException.

My idea is to deploy EarProject from within eclipse to Glassfish server defined in eclipse and debug the application.

Please give me guidance.

TiA Chir


(Peter Niederwieser) #2

Due to this, when I export the EjbProject/JpaProject to ejb-jar or jar file, the eclipse does not include appropriate classes in the jar file.

Then probably you shouldn’t apply the ‘war’ plugin to ‘EjbProject’ and ‘JpaProject’.

Please give me guidance.

First thing to do is to study the NPE stack traces in the Eclipse log and try to understand their causes.