BUG Community

Welcome! Log In

bballantine's Blog

/// Stripes (on Jetty (on BUG))

The default BUG software stack includes a simple Java web server and Servlet implementation.  The speed and simplicity comes at the expense of functionality.  In the web world, this means that JSP isn't supported.  To help remedy this, we created Sewing, a simple web framework for embedded OSGi systems.  It's not JSP, but it is Freemarker based and has a simple MVC architecture that makes creating dynamic web sites easy. If you want to host a full Java web application and JSP on BUG, you have to leave BUG's stock JVM behind.

Recently I got Jetty, a java-based, open source HTTP Server and Servlet container, running on BUG along with a simple Java web application framework called Stripes.  Here's what I had to do:

Both ipk and Jetty like to put things in /tmp which, by default on the BUG, is a tmpfs only 8 MB big.  You may get errors installing ipks or running Jetty that say "device full" or something like that.  You can fix this by editing /etc/fstab.  Open /etc/fstab in vi, and on the 5th line change size=8M to be size=64M.  Then restart your BUG.

The next step is to install a Java 1.5 compatible JVM on BUG.  Cacao + GNU Classpath is available in our extras repo, but I had some problems with a couple of libraries in the classpath that caused Jetty to throw errors and it was slow.  So, my collegues made Cacao + OpenJDK available as a tarball of ipks.  You can download this directly to your BUG:

wget http://bugcommunity.com/downloads/files/openjdk.tar.gz

Uncompress this and install the ipks

ipkg install *.ipk

Now you have a more complete version of Java.  Check it out:

root@bug:~# java -version java version "1.6.0_0" IcedTea Runtime Environment (1.5-rffe92bbe7e84) (build 1.6.0_0-b16) CACAO (build 0.99.4, compiled mode

As agordon would say, "Groovy!" 

Now you have to install Jetty.  I got the latest release of Jetty 6 I could find here: http://dist.codehaus.org/jetty/ .  It comes as a .zip, which you can put directly on your BUG and unzip.  After you unzip the Jetty archive, you can run Jetty with the default configuration on port 8080.

cd jetty-6.1.21 java -jar start.jar

It takes about a minute for things to get going, and you'll see debug messages on your screen (and errors if there are any).  But if all goes well, you should be able to browse to http://<BUG-IP>:8080/ and see the Jetty welcome page.  There are a couple of JSP examples to try out and also a cool Cometd example, so give it a spin.

Now, most people, including myself, are not content to hack JSP in the old-school way.  I decided to try out a small and compelling Java web framework called Stripes.  Getting it to work on the BUG was a breeze.

For this proof of concept, I followed the Stripes Quickstart Guide and created the calculator Stripes application.  I used Eclipse and its web development plugins to create a Dynamic Web Project.  I added the Jetty jars to the classpath and followed the directions in the Quickstart Guide to create the project.  Finally, using Eclipse, I exported the finished project as a war file (mine was called stripes1.war).

To test your new Stripes application on the BUG, copy the war file into your jetty/webapps folder and restart the server.  The war file will be picked up automatically.  You can then browse to your application.  In my case it was: http://<BUG-IP>/stripes1/quickstart

created on: 10/02/09

Post Comments

Add Your Comment!

» All comments
» Comments RSS

Powered by Community Engine

Top
Login
Close
Bottom