Errai 2.4.3.Final and Wildfly 8
hr.stoyanov Feb 20, 2014 2:28 AMI managed to upgrade my Errai 2.4.3 app to be deployable on Wildfly 8 Final. The Wildfly 8 CDI is pretty picky and until the Weld developers fix in late March (and propagate the fix to Wildfly 8 release, who knows when) here is what to do:
1. You need use to upgrade Guava 14.0.1 to Guava 16.0.1
2. You need to lose errai cordova
You will still get some Errai warnings, but your app would deploy:
===========================
23:14:20,134 WARN [org.jboss.weld.Event] (MSC service thread 1-3) WELD-000411: Observer method [BackedAnnotatedMethod] public org.jboss.errai.cdi.server.CDIExtensionPoints.observeResources(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.
23:14:20,200 INFO [org.jboss.errai.cdi.server.CDIExtensionPoints] (MSC service thread 1-3) starting errai cdi ...
23:14:21,098 INFO [org.jboss.errai.common.metadata.MetaDataScanner] (Thread-69) added class scanning extensions: org.jboss.errai.common.metadata.JbossVFsTypeHandler
23:14:21,596 INFO [org.jboss.errai.reflections.Reflections] (Thread-69) Reflections took 496 ms to scan 14 urls, producing 438 keys and 2256 values [using 2 cores]
23:14:21,658 INFO [org.jboss.errai.cdi.server.CDIExtensionPoints] (pool-6-thread-1) all services registered successfully
23:14:21,788 WARN [org.jboss.weld.Validator] (weld-worker-1) WELD-001473: javax.enterprise.inject.spi.Bean implementation org.jboss.errai.cdi.server.ErraiServiceBean@745553e declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.
23:14:21,789 WARN [org.jboss.weld.Validator] (weld-worker-1) WELD-001473: javax.enterprise.inject.spi.Bean implementation org.jboss.errai.cdi.server.MessageBusBean@557c80d8 declared a normal scope but does not implement javax.enterprise.inject.spi.PassivationCapable. It won't be possible to inject this bean into a bean with passivating scope (@SessionScoped, @ConversationScoped). This can be fixed by assigning the Bean implementation a unique id by implementing the PassivationCapable interface.
===========================
Here is what my Gradle file looks like:
===================================
//This project uses ideas for GWT from:
// https://github.com/kompot/gwtupld/blob/master/build.gradle
// https://github.com/kompot/waveed/blob/master/build.gradle
// http://www.prait.ch/wordpress/?p=347
// https://code.google.com/p/pigwt/source/browse/trunk/build.gradle?r=22
// https://github.com/davidecavestro/smartgwt-test-case/blob/master/build.gradle
project.description = "stocks 4 grab gwt web application"
//Project properties
project.ext {
erraiVersion = "2.4.3.Final"
warDir = "${project.buildDir}/war"
webInfDir = "${project.warDir}/WEB-INF"
webLibDir = "${project.webInfDir}/lib"
webClassesDir = "${project.webInfDir}/classes"
webResourcesDir = "${project.webInfDir}/resources"
gwtExtraDir = "${project.buildDir}/extra"
deployedWarDir = "${wildfly_root}/standalone/deployments/${project.name}.war"
}
apply plugin: "war"
apply plugin: "eclipse-wtp"
//Override Java plugin defaults
sourceSets.main.output.classesDir = file("${project.webClassesDir}")
sourceSets.main.output.resourcesDir = file("${project.webClassesDir}")
configurations { gwt }
dependencies {
compile project(":stocks4grab:s4g-common")
//Java EE
providedCompile "javax:javaee-api:7.0"
//Others
compile 'com.google.guava:guava:16.0.1'
gwt 'com.google.guava:guava-gwt:16.0.1'
//GWT
compile fileTree (dir: gwt_sdk_root, includes:["gwt-servlet.jar"])
//gwt fileTree (dir: gwt_sdk_root, includes: ["**/*.jar"])
gwt fileTree (dir: gwt_sdk_root, includes: ["gwt-dev.jar", "gwt-user.jar", "validation-api*.jar"])
//Errai
//compile "org.jboss.errai:errai-bus:"+project.erraiVersion
compile ("org.jboss.errai:errai-bus:"+project.erraiVersion){
exclude group: 'com.google.guava'
}
compile "org.jboss.errai:errai-ioc:"+project.erraiVersion
compile "org.jboss.errai:errai-cdi-client:"+project.erraiVersion
//compile "org.jboss.errai:errai-jpa-datasync:"+project.erraiVersion
compile ("org.jboss.errai:errai-jpa-datasync:"+project.erraiVersion){
exclude group: 'com.google.guava'
}
compile "org.jboss.errai:errai-jaxrs-provider:"+project.erraiVersion
compile "org.jboss.errai:errai-javax-enterprise:"+project.erraiVersion
compile "org.jboss.errai:errai-weld-integration:"+project.erraiVersion
compile "org.jboss.errai:errai-ui:"+project.erraiVersion
//compile "org.jboss.errai:errai-navigation:"+project.erraiVersion
compile ("org.jboss.errai:errai-navigation:"+project.erraiVersion){
exclude group: 'com.google.guava'
}
//compile "org.jboss.errai:errai-cordova:"+project.erraiVersion
//compile ("org.jboss.errai:errai-cordova:"+project.erraiVersion){
// exclude group: 'com.google.guava'
//}
//compile "org.jboss.errai:errai-jaxrs-client:"+project.erraiVersion
compile ("org.jboss.errai:errai-jaxrs-client:"+project.erraiVersion){
exclude group: 'com.google.guava'
}
compile "org.jboss.errai:errai-marshalling:"+project.erraiVersion
compile "org.jboss.errai:errai-jboss-as-support:"+project.erraiVersion
}
task copyJars(type: Copy){
from(configurations.compile) into("$project.webLibDir")
}
task copyWebapp(type: Copy){
from("src/main/webapp") into("$project.warDir")
}
task compileGwt (type: JavaExec) {
description = "Compile all gwt modules"
//This prevents unnecessary GWT compilations!
inputs.source sourceSets.main.java.srcDirs
inputs.dir sourceSets.main.output.resourcesDir
outputs.dir buildDir
main = "com.google.gwt.dev.Compiler"
classpath {[
sourceSets.main.java.srcDirs, // Java source
sourceSets.main.output.resourcesDir, // Generated resources
sourceSets.main.output.classesDir, // Generated classes
sourceSets.main.compileClasspath, // Dependencies
configurations.gwt
]}
args =
[
"com.peruncs.s4g.web.gwt.S4GWebApp", // Your GWT module(s)
"-war", project.warDir,
"-extra", project.gwtExtraDir,
//"-logLevel", "INFO",
"-strict",
"-localWorkers", "2",
"-compileReport",
"-ea",
"-optimize","9",
// "-draftCompile" // Speeds up compilation by 25%
]
maxHeapSize = "1024M"
}
task deployWarContent(type: Copy){
from(project.warDir) into(project.deployedWarDir)
}
task deploy << {
ant.touch(file: "${project.deployedWarDir}.dodeploy")
}
task undeploy << {
file(project.deployedWarDir).deleteDir()
file("${project.deployedWarDir}.dodeploy").delete()
file("${project.deployedWarDir}.deployed").delete()
}
//This would start the GWT code server
task startGwt << {
description = "Launch GWT DevMode for all gwt modules"
ant.java( spawn:true, fork:true, classname:"com.google.gwt.dev.DevMode"){
jvmarg(value: "-DDEBUG") //Jetty debugging
jvmarg(value: "-Djava.util.logging.config.file=${project.webInfDir}/logging.properties") //RestEasy logging
jvmarg(value: "-Xmx1024m")
jvmarg(value: "-Xss1024k")
jvmarg(value: "-XX:PermSize=1024m")
jvmarg(value: "-XX:MaxPermSize=1024m")
jvmarg(value: "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005")
arg(value: "com.peruncs.s4g.web.gwt.S4GWebApp")
arg(line: "-startupUrl index.jsp")
//arg(line: "-startupUrl s4g-web/index.jsp")
arg(line: "-war "+project.warDir)
arg(line: "-noserver")
arg(line: "-port 8080")
arg(line: "-codeServerPort 9997")
arg(line: "-extra "+ project.gwtExtraDir)
arg(line: "-logLevel INFO")
classpath {
pathElement(location: "src/main/java")
pathElement(location: "src/main/resources")
pathElement(location: "${project.webClassesDir}")
pathElement(path: configurations.gwt.asPath)
pathElement(path: configurations.compile.asPath)
pathElement(path: configurations.providedCompile.asPath)
}
}
}
task cleanWar << {
delete project.warDir
}
//Tasks dependencies
compileJava.dependsOn copyWebapp, copyJars //upon java compilation, we copy all necessary files to have nice 'exploded' war
compileGwt.dependsOn classes
deploy.dependsOn classes, deployWarContent
war.dependsOn compileGwt
//Due to bugs: GRADLE-2171, GRADLE-1454 and GRADLE-1050,we resort to using Ant's zip task and avoid dupes in the war file
//TODO: revert back to the standard method, since the issue seems fixed as of Gradle 1.7
war << {
ant.zip(destfile: project.war.archivePath,
basedir: project.warDir ,duplicate: 'preserve',
keepcompression: true, update: true)
}
eclipse {
wtp {
facet {
//you can add some extra wtp facets; mandatory keys: 'name', 'version':
facet name: 'wst.jsdt.web', version: '1.0'
facet name: 'jst.web', version: '3.0'
facet name: 'jst.java', version: '1.7'
}
}
//component {
// contextPath = '/'
//}
project {
natures 'com.google.gwt.eclipse.core.gwtNature'
}
}