The Source for Java Technology Collaboration
User: Password:



Jean-Francois Arcand

Jean-Francois Arcand's Blog

Running AsyncWeb in GlassFish

Posted by jfarcand on July 21, 2006 at 10:47 AM | Comments (4)

AsyncWeb, the high-throughput non blocking Java HTTP engine who support asynchronous request processing from POJO objects, can now run on top of Grizzly, the http engine used by GlassFish.

AsyncWeb can now be deployed in GlassFish. AsyncWeb is (from the site):

AsyncWeb (built on top of the excellent Mina network framework) employs 
non-blocking selector driven IO at the transport level, and is 
asynchronous thoughout - from the initial parsing of requests, 
right through to and including the services implemented by users.
AsyncWeb breaks away from the blocking request / response architecture 
found in todays popular HTTP engines. This allows it to be highly
scalable and capable of supporting very high throughput - even in high
processing latency scenarios. A simple API allows new asynchronous
services to be created easily - and out-of-the-box Spring integration 
allows hem to be configured simply and with great flexibility. 
In addition to "endpoint" HTTP services, AsyncWeb also 
allows configurable "chains" of behaviour - nabling "filter"
like behaviour to be applied to all requests. Pluggable "resolvers"
map incoming requests to their target HTTP service - and are given
access to the entire incoming request - allowing the routing 
possibilities to be very lexible.

Looks promising, does it? A couple of weeks ago I've started working with Dave Irving, the man behind AsyncWeb, exploring ways to run AsyncWeb on top of Grizzly, the NIO framework used in GlassFish. The technical challenge to makes this happens was to replace, under the hood, the dependencies with MINA.

The good news is that both MINA and AsyncWeb are extremely well designed, and it was easy (without having to change anything inside AsyncWeb*), to run AsyncWeb on top of the Grizzly framework.

Technically, Grizzly receives requests, read |write the bytes and delegate the processing to AsyncWeb, by implementing the MINA interfaces AsyncWeb rely on. Doing the work, I've realized how easy is to build an NIO application on top of MINA. I've implemented one interface and used one MINA wrapper et voila! Note that extending Grizzly is also simple, but lack of available tutorials like MINA make it harder to use (subliminal message for myself...write docs! :-)).

Surprisingly, the code required to run AsyncWeb on top of Grizzly consist of only three classes. The code can be found here.

OK, enough bla bla bla bla bla and let see how it to deploy AsyncWeb in GlassFish. Dont't run away! Dave and I will make the integration much simpler over the next couple of weeks, but for peoples interested now :-), just follow the steps below.

Deploying AsyncWeb in GlassFish

First, install GlassFish by following the steps here. Make sure you get a nightly build released after July 21. Next, get the latest AsyncWeb binary here. Unzip the AsyncWeb bundle. You will get:

4 -rw-r--r--  1 jfarcand jfarcand 3514 May 22 08:10 build.xml
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 conf
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 docs
4 drwxr-xr-x  4 jfarcand jfarcand 4096 May 22 08:10 examples
4 drwxr-xr-x  2 jfarcand jfarcand 4096 May 22 08:10 lib

Copy the content under lib/* to your glassfish installation:

% cp -R lib/* ${glassfish.home}/lib

GlassFish doesn't ship (for now) the Grizzly extension required to enable AsyncWeb. Download the extension here, and unzip the jar file under your GlassFish lib directory:

% cd ${glassfish.home}
% unzip asyncweb-grizzly.jar

Finally, tell GlassFish to listen for AsyncWeb requests by adding, in GlassFish's domain.xml, the following line:

        <http-listener acceptor-threads="1" address="0.0.0.0" 
blocking-enabled="false" default-virtual-server="server" enabled="true" 
family="inet" id="http-listener-1" port="8080" security-enabled="false" 
server-name="" xpowered-by="true">
          <property name="selectorThreadImpl" 
    value="com.sun.grizzly.asyncweb.AsyncWebSelectorThread"/>

This will enable AsyncWeb to listen on port 8080. You are now ready to test the installation by starting GlassFish:

% ${glassfish.home}/bin/asadmin start-domain

and from your browser, issue http://localhost:8080 and see:

Async.jpg

Stay tuned. We will significantly improve the installation steps in the upcoming weeks, and start exploring ways to bundle AsyncWeb's Service with Web Application. We will also explore ways to make use of Grizzly Comet via an AsyncWeb Service!

(*) Ok, only one change in AsyncWeb...make a method public instead or protected

technorati:


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • I follow all steps with glassfish-installer-v1_ur1-b04.jar, asyncWeb_0.8.1.zip and your asyncweb-grizzly.jar.

    But the last page for AsyncWeb does not show up. It is still the normal page for GlassFish.

    How can diagnose the problem? Thanks!

    Posted by: swei75 on July 29, 2006 at 09:54 AM

  • Hi swei75.. I'll be attempting a glassfish/asyncweb install in the next couple of days - following the steps in this blog. I'll attempt to fix any problems I encounter and will report back accordingly. Cheers! Dave

    Posted by: dave_irving on July 31, 2006 at 12:57 AM

  • I've just try (August 30) and it works just fine. have you enabled AsyncWeb by adding the propery in domain.xml?

    Thanks

    -- jeanfrancois

    Posted by: jfarcand on August 30, 2006 at 08:28 AM

  • When I following the instructions, I am getting the following error in the glassfish server.log file:

    [#|2008-04-02T11:28:08.870-0500|SEVERE|sun-appserver9.1|GRIZZLY|_ThreadID=10;_ThreadName=main;_RequestID=8c4e9486-8670-41ac-bd56-19b839d47852;|grizzlyHttpProtocol.endpoint.initerror
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from URL [file://C:/glassfish/domains/domain1/config/AsyncWeb.xml]; nested exception is java.net.UnknownHostException: C
    java.net.UnknownHostException: C

    It looks like the problem is with the file URI not in an accepted format. FYI: I'm running on Windows, is there anything that I can change to make this work?

    Thanks,

    Posted by: yangp3 on April 02, 2008 at 10:19 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds