Warning: Nothing links to this page

Aptana Jaxer and DWR Integration

The DWR + Jaxer integration makes Java access easy for JavaScript developers using Aptana Jaxer, an Ajax server which embeds the Mozilla browser engine to provide server-side JavaScript, DOM, CSS, plus features typical of app servers for other languages.

Ease of Use

What's in it for DWR and Java users? You can see this as a way to cleanly separate a presentation layer written in Ajax (at both the client and the server) from a back-end business logic layer written in Java such that the Java layer is not directly exposed to the Internet.

What's in it for Jaxer users? You can now tap Java objects directly from their server-side JavaScript code. DWR handles the type conversions and marshalling while letting the developer use the same Java object names and APIs, except of course from JavaScript.

Of course you can also use (Jaxer + DWR) and DWR in parallel to do the above, plus connect to DWR's reverse Ajax capabilities directly from the browser.

Security

Much of the complexity of DWR configuration is to restrict what classes the Internet can access. When DWR is fronted by Jaxer, we don't need to expose DWR to the Internet. Effectively the client becomes trusted, so we can remove some of the configuration steps. There is for example no need for a dwr.xml file any more - The exported classes can be configured directly by the script. Clearly it's important that your DWR server is not accessible from the Internet and is properly fire-walled.

Synchronous Communication

Synchronous communication over the Internet is generally regarded as a bad idea because it freezes the client while the server is responding. In the single-threaded JavaScript environment, this can be a significant glitch in user interface. Inside a corporate LAN, latencies are significantly reduced, and with Jaxer the UI is not visible while the rendering is happening.

About the Downloads

There are 4 files available from the download area. 2 for use in an existing setup, and 2 as a demo to get started.

Files to add to an existing project:

If you are familiar with plain DWR, you don't need dwr.xml or any annotation configuration.

Demo files:

If you want an easy way to see what DWR+Jaxer does, start by deploying this file to a Java server and by deploying demoRemoting.zip to a Jaxer server. See below for more detailed instructions.

How to get started with DWR+Jaxer

1. In your Aptana_Jaxer/public directory, create a directory called demoRemoting, then download and unzip demoRemoting.zip, into this directory.

You should now have 2 extra files:

2. Next, download demoServer.war and deploy it into your application server.

3. Start the application server and browse to http://localhost:8081/demoRemoting.

Troubleshooting

If you get an error message like this:

Jaxer error processing request: JavaScript Error: "Jaxer.dwr is undefined"

Then you are running against a version of Jaxer that does not contain the Jaxer/DWR integration. The preferred solution is to upgrade Jaxer, however if that fails you can also make a small edit to demoRemoting/index.html. See the comments in that file.

If your application server is not on the same machine, or is running on a different port, then you will need to edit Jaxer.dwr.pathToDwrServlet to point at the deployment of a web application containing jaxer-dwr.jar. See demoRemoting/index.html (around line 16) for more details.