Building and Deploying an Enterprise Application with Eclipse STS

Hi,

I know there are many different questions in what im going to describe in the following. It is definitely not only gradle-related, but it’s hard to find a platform to ask those questions, because you can only get help if you clarify the whole setup and aims. For this reason I didn’t have much success with StackOverflow for example as the questions should always stand alone for themselves. So I hope you will try to help me although this forum may not be the right place for all content in this topic.

What I am trying is to set up an environment to create a Java Enterprise Application containing an EJB-Jar and an JavaFX Application Client (Eclipse Gluon project applying the gradle ‘jfxmobile’ plugin). I would like to use CDI instead of JNDI lookups to call the EJBs. I don’t even know If this is actually possible, but I can’t see why it shouldn’t. The project should be deployed to the latest version of Payara server.

My project structure look like this:

GradleMaster/
    - settings.gradle
    - build.gradle
    EAR/
        - build.gradle
    EJB/
        - build.gradle
    JavaFXClient/
        -build.gradle

I altered the project names and left out a second application client created from the Eclipse Application Client wizard for test purposes to make it a bit easier to overview.

The contents of the gradle files look like this:

GradleMaster/settings.gradle:

include 'DataViewerEAR', 'DataViewerEJB', 'DataViewerFX', 'DataViewerTestClient'

GradleMaster/build.gradle:

allprojects{
     apply plugin: 'base'
    apply plugin: 'eclipse'
}
subprojects {
    apply plugin: 'java'    
    repositories{
        mavenCentral()
        jcenter()
    }
    dependencies {
        compile 'ch.qos.logback:logback-classic:1.1.6'     
        compile 'javax:javaee-api:7.0' 
        testCompile 'junit:junit:4.12'
    }
}

EAR/build.gradle:

apply plugin: 'ear'
task wrapper(type: Wrapper){
    gradleVersion = '2.21'
}
dependencies {
    deploy project(':DataViewerEJB')
    earlib project(path: ':DataViewerEJB', configuration: 'compile')
    deploy project(':DataViewerFX')
    deploy project(':DataViewerTestClient')
    earlib 'fish.payara.extras:payara-embedded-all:4.1.153'
    earlib 'javax:javaee-api:7.0'
}
appDirName "EarContent" 

EAR/build.gradle:

dependencies{
    compile 'org.elasticsearch:elasticsearch:1.6.0'
}
sourceSets {
  main {
     java {
        srcDir 'ejbModule'  
        } 
     }
  test {
     java {
        srcDir 'test'
        } 
     }
} 

JavaFXClient/build.gradle:

apply plugin: 'org.javafxports.jfxmobile'
buildscript {
    repositories {
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b10'        
    }  
}
retrolambda {
    oldJdk System.getenv("JAVA7_HOME")
}
mainClassName = 'com.mannikj.dataviewer.fx.main.DataViewerApplication'
jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
    }
}
jar {
    manifest {
        attributes 'Main-Class': 'com.mannikj.dataviewer.fx.main.DataViewerApplication'
        attributes 'Permissions': 'all-permissions'
    }
}

The outcomes of the ‘ear’ task of the EAR project seem to be quite ok and I am able to deploy the file manually to Payara using the web administration. Although there are several strange messages in the server log. As I am a new user, I cannot upload files and the log files are to long to embed them in the post. I will try to add them later.

It is very strange that a few messages refer to an EJB called TimerBean that is afterwards deployed to Payara as an EJB module of the EAR application. I don’t know where this comes from…

Deploying via Eclipse by Right Click on EAR project->Run As->Run on Server results does not work at all. I will also try to provide the log messages later on. Maybe someone could tell me the best way to hand out the log files for you. The forum’s post rules are very restrictive.

For me in looks like Eclipse does not use Gradle to create the EAR for deployment, but tries to build it on it’s own.

Another big issue is Java WebStart in general. When trying to launch the application there security issues. You find many users with the same problems, but there has not been a solution for me yet.

I could provide further information if someone who wants to help asks for it. I would also give my workspace to chosen users if anyone declares oneself ready to comply with it. There are probably some instructions or XML-configs missing to tell Payara exactly what to do, but I am quite new to that whole stuff. I also not sure whether Gradle could produce these files during build dynamically instead of declaring it in ugly XML files.

Thank you in advance!

Best regards,
Jannik

This seems to be the only Gradle related questions. The answer is yes: When you use the Eclipse web tools, it will not call Gradle, but do everything itself.

For the rest of your questions, you will surely get better answers on a forum that is focussed on JEE development.

Yeah, you are probably right, but there are always other gradle-related questions coming up and it’s often necessary to describe the whole setting to enable help. I thought I could bundle them in this thread so I don’t always need to ask a new question from scratch.

So is there a way to convince Eclipse of using Gradle automatically?

I would also like to refer to a question I posted on StackOverflow a few days ago that still isn’t answered:


This question is a really basic gradle question about task execution in multi-project builds. For example when adding task hello << { task -> println "I'm $task.project.name" } to allprojects in the root build file, I understand it like this that by running the ‘hello’ task on the root project, the hello task for each project down the hierarchy should be executed. In my setup that does not happen. Do I miss something?

In general you will get more help if you trim your problem down and ask specific questions, ideally attaching an example project. People helping on forums mostly do so in their free time and you don’t want to take more than necessary of that :wink:

You can’t make Eclipse WTP delegate to Gradle atm. You could use a Gradle plugin like gretty to run your webapp locally instead of using WTP. Then launching would be just one Gradle task away and other devs don’t need to setup a server in Eclipse etc.

The stackoverflow problem looks sts specific. There are tasks (launches a task only on that project) and task selectors (launches all tasks of that name in all subprojects). Look if sts has an option to do the latter. Buildship (the official Gradle Eclipse plugin) does have this option.

Does anybody know if there has been any progress on this? I.e. Eclipse WTP integration with gradle projects.