JBoss.orgCommunity Documentation

Chapter 14. Configuration

14.1. Errai Development Mode Configuration
14.1.1. Deployment in Development Mode (JBossLauncher)
14.1.2. Additional JBossLauncher Arguments
14.1.3. Deployment to an Application Server
14.2. ErraiApp.properties
14.2.1. As a Marker File
14.2.2. As a Configuration File
14.3. Messaging (Errai Bus) Configuration
14.3.1. Compile-time Dependencies
14.3.2. Disabling remote communication
14.3.3. Configuring an alternative remote remote bus endpoint
14.3.4. ErraiService.properties
14.3.5. Servlet Configuration
14.4. Errai JAX-RS Setup
14.4.1. Compile-time dependency
14.4.2. GWT Module
14.4.3. Configuration
14.5. Errai JPA
14.5.1. Compile-time Dependencies
14.5.2. GWT Module Descriptor
14.6. Errai JPA Data Sync
14.6.1. Compile-time Dependencies
14.6.2. GWT Module Descriptor
14.7. Errai Data Binding
14.7.1. Compile-time Dependencies
14.7.2. GWT module descriptor
14.8. Errai UI
14.8.1. Compile-time dependency
14.8.2. GWT Module Descriptor
14.9. Errai UI Navigation
14.9.1. Compile-time Dependencies
14.9.2. GWT Module Descriptor
14.10. Errai Cordova (Mobile Support)
14.10.1. Compile-time Dependencies
14.10.2. Cordova Maven Plugin
14.10.3. GWT Module Descriptor
14.10.4. Building with Errai Cordova
14.11. Errai Project Dependencies
14.11.1. Errai Messaging
14.11.2. Errai CDI
14.11.3. Errai IOC
14.11.4. Errai UI
14.11.5. Errai Navigation
14.11.6. Errai DataBinding
14.11.7. Errai JPA Client
14.11.8. Errai JPA Datasync
14.11.9. Errai JAXRS
14.11.10. Errai JAXRS

This section contains information on manually setting up Errai and describes additional configurations and settings which may be adjusted.

In development mode we need to bootstrap the CDI environment on our own and make both Errai and CDI available through JNDI (common denominator across all runtimes). GWT by default uses Jetty, that only supports read only JNDI. The current solution for this is to use a custom launcher to control a JBoss AS 7 or Wildfly 8 instance instead of GWT’s built-in Jetty.

To do this, requires the following configurations in the gwt-maven-plugin configuration:


<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>gwt-maven-plugin</artifactId>
  <version>${gwt.version}</version>

  <configuration>
  ...
    <extraJvmArgs>-Derrai.jboss.home=$JBOSS_HOME -Derrai.jboss.javaagent.path=${settings.localRepository}/org/jboss/errai/errai-client-local-class-hider/$ERRAI_VERSION/errai-client-local-class-hider-$ERRAI_VERSION.jar</extraJvmArgs>
    <noServer>false</noServer>
    <server>org.jboss.errai.cdi.server.gwt.JBossLauncher</server>
  </configuration>
  <executions>
  ...
  </executions>
</plugin>

What does all this mean?

We provide integration with the JBoss Application Server, but the requirements are basically the same for other vendors. When running a GWT client app that leverages CDI beans on a Java EE 6 application server, CDI is already part of the container and accessible through JNDI (java:/BeanManager).

ErraiApp.properties acts both as a marker file for JARs that contain Errai-enabled GWT modules, and as a place to put configuration settings for those modules in the rare case that non-default configuration is necessary.

ErraiApp.properties is usually left empty, but it can contain configuration settings for both the core of Errai and any of its extensions. Configuration properties defined and used by Errai components have keys that start with " errai. ". Third party extensions should each choose their own prefix for keys in ErraiApp.properties.

The ErraiService.properties file contains basic configuration for the bus itself. Unlike ErraiApp.properties, there should be at most one ErraiService.properties file on the classpath of a deployed application. If you do not need to set any properties to their non-default values, this file can be omitted from the deployment entirely.

Dispatchers encapsulate the strategy for taking messages that need to be delivered somewhere and seeing that they are delivered to where they need to go. There are two primary implementations that are provided with Errai, depending on your needs.

SimpleDispatcher:

SimpleDispatcher is basic implementation that provides no asychronous delivery mechanism. Rather, when you configure the Errai to use this implementation, messages are delivered to their endpoints synchronously. The incoming HTTP thread will be held open until the messages are delivered.

While this sounds like it has almost no advantages, especially in terms of scalablity. Using the SimpleDispatcher can be far preferable when you’re developing your application, as any errors and stack traces will be far more easily traced and some cloud services may not permit the use of threads in any case.

AsyncDispatcher:

The AsyncDispatcher provides full asynchronous delivery of messages. When this dispatcher is used, HTTP threads will have control immediately returned upon dispatch of the message. This dispatcher provides far more efficient use of resources in high-load applications, and will significantly decrease memory and thread usage overall.

Errai has several different implementations for HTTP traffic to and from the bus. We provide a universally-compatible blocking implementation that provides fully synchronous communication to/from the server-side bus. Where this introduces scalability problems, we have implemented many webserver-specific implementations that take advantage of the various proprietary APIs to provide true asynchrony.

These included implementations are packaged at: org.jboss.errai.bus.server.servlet .

Errai Cordova allows you build an Errai app to natively run on a device. In order to make this as easy as possible we have a maven plugin that will create a native binary that you can install on a device. It will put the html and javascript of you application in a cordova application.


<build>
 ...
    <plugins>
      <plugin>
        <groupId>org.jboss.errai</groupId>
        <artifactId>cordova-maven-plugin</artifactId>
        <version>${errai.version}</version>
      </plugin>

For those not using maven, here is the dependency tree of Errai project jars.