JBoss.orgCommunity Documentation

Chapter 14. Configuration

14.1. Errai Development Mode Configuration
14.1.1. Deployment in Development Mode
14.1.2. Additional Launcher Arguments
14.1.3. Deployment to an Application Server
14.2. Server-Side Class Generation
14.3. Errai Offline Mode Configuration
14.4. ErraiApp.properties
14.4.1. As a Marker File
14.4.2. As a Configuration File
14.5. Messaging (Errai Bus) Configuration
14.5.1. Compile-time Dependencies
14.5.2. Disabling remote communication
14.5.3. Configuring an alternative remote remote bus endpoint
14.5.4. ErraiService.properties
14.5.5. Servlet Configuration
14.6. Errai JAX-RS Setup
14.6.1. Compile-time dependency
14.6.2. GWT Module
14.6.3. Configuration
14.7. Errai JPA
14.7.1. Compile-time Dependencies
14.7.2. GWT Module Descriptor
14.8. Errai JPA Data Sync
14.8.1. Compile-time Dependencies
14.8.2. GWT Module Descriptor
14.9. Errai Data Binding
14.9.1. Compile-time Dependencies
14.9.2. GWT module descriptor
14.9.3. Bootstrapping Data Binding without Errai IOC
14.10. Errai UI
14.10.1. Compile-time dependency
14.10.2. GWT Module Descriptor
14.11. Errai UI Navigation
14.11.1. Compile-time Dependencies
14.11.2. GWT Module Descriptor
14.12. Errai Security
14.12.1. Compile-time dependency
14.12.2. GWT Module Descriptor
14.12.3. CDI and Interceptor Bindings

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

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).

Errai Marshalling and Errai CDI generate class files that should be packaged in your server-side war (usually in WEB-INF/classes). Errai will attempt to discover where these files should be written, but in some project configurations you may need to specify this manually. You can add this system property to your gwt-maven-plugin configuration to explicitly set the target folder to src/main/webapp/WEB-INF/classes:

-Derrai.server.classOutput=src/main/webapp/WEB-INF/classes

Errai provides special support for HTML5’s application caching mechanism that enables applications to work offline. If you’re not familiar with the HTML5 application cache you can find all the details here.

As GWT compiles separate browser-specific JavaScript permutations for your application, it is not enough to manually create a cache manifest file and simply list all generated JavaScript files. This would cause every browser to download and cache JavaScript files that it doesn’t need in the first place (i.e. Safari would download and cache JavaScript files that were generated for Internet Explorer only). Errai solves this problem by using a custom linker to generate user-agent specific cache manifest files.

The following steps are necessary to activate this linker:

  • Define the linker in your gwt.xml module descriptor:

<define-linker name="offline" class="org.jboss.errai.offline.linker.DefaultCacheManifestLinker" />
<add-linker name="offline" />
  • Add the manifest (your_module_name/errai.appcache) to the html tag in your host page:

<html manifest="your_module_name/errai.appcache">
  • Add a mime-mapping to your web.xml file (you can skip this step if you deploy the errai-javaee-all.jar as part of your application):

<mime-mapping>
  <extension>manifest</extension>
  <mime-type>text/cache-manifest</mime-type>
</mime-mapping>
  • Make sure the errai-common.jar file is deployed as part of your application. It contains a servlet that will provide the correct user-agent specific manifest file in response to requests to your_module_name/errai.appcache
  • To obtain manifests that contain other files in addition to those generated by the DefaultCacheManifestLinker, create a subclass that overrides otherCachedFiles(), and use this subclass as a linker instead:
@Shardable

@LinkerOrder(Order.POST)
public class MyCacheManifestLinker extends DefaultCacheManifestLinker {
  @Override
  protected String[] otherCachedFiles() {
    return new String[] {"/my-app/index.html","/my-app/css/application.css"};
  }
}

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.

[[sid-5931338_Messaging%28ErraiBus%29Configuration-MessageDispatching]]

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.

[[sid-5931338_Messaging%28ErraiBus%29Configuration-SimpleDispatcher]]

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.

[[sid-5931338_Messaging%28ErraiBus%29Configuration-AsyncDispatcher]]

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.

[[sid-5931338_Messaging%28ErraiBus%29Configuration-Threading]]

[[sid-5931338_Messaging%28ErraiBus%29Configuration-Clustering]]

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.

[[sid-5931338_Messaging%28ErraiBus%29Configuration-DefaultBlockingServlet]]