I’ve recently been working on porting Jetty to Google’s mobile platform called Android.
It’s early days still, but I’ve succeeded in running a minimal setup with a connector (I’ve tested both bio and nio connectors) and a simple Handler. If you’d like to take a look, then check out the code from the i-jetty project and build it (you’ll need to execute the ant build script and then use Android’s packaging tool or the Eclipse plugin).
Once you’ve built and deployed the i-jetty package to the emulator,  find the “Manage Jetty” application, and select the “Start Jetty” button. Then you’ll be able to select the Browser application and surf to http://127.0.0.1:8080 and hit the demo “Hello” Handler.
For the moment I’ve had to do a teeny hack to the servlet api classes, due to this bug in Android, but hopefully that will be fixed soon and I can revert the temporary patches.
Much work remains to be done, but I thought I’d give everyone early warning that this work was going on. Who knows, it might inspire someone to use Jetty to win the Android developer challenge?!


46 Comments

Anonymous · 20/02/2008 at 10:36

Great !

Don Ferguson · 20/02/2008 at 21:26

Nice going Jan!

Mike Wilson · 29/02/2008 at 04:55

Hi Jan,

Before I found this website I tried to get the embed Jetty into an android app….seems to be having some issues.

Then I saw your posting while researching a solution.

Would you be able to give some direction in making your application work within the emulator?

Jan Bartel · 29/02/2008 at 09:44

Hi Mike,

Its very easy  to get the i-jetty project running. All you need to do is:

+ do an svn checkout of the source.
svn checkout http://i-jetty.googlecode.com/svn/trunk/ i-jetty-read-only

+ do an ant build to suck in the jetty modules from the jetty repo:
cd i-jetty-readonly
ant

+ use the Eclipse plugin to build the project (see http://code.google.com/android/intro/installing.html#installingplugin). I haven’t used the command line tools to generate the .apk files yet. When I sort out how to do it, I’ll post the instructions.

+ once you’ve got the bin/i-jetty.apk file built, then you just have to run it in an emulator. The Eclipse plugin will install and run the emulator for you. Otherwise, at the command line, you need to do: 
$gwt.home/tools/emulator
$gwt.home/tools/adb install $ijetty.home/bin/i-jetty.apk
As you’ll see, the current application that is started by the jetty instance uses a number of specific servlet instances to serve content. I’m working on a more flexible, generic way to serve content, particularly content off the sdcard (see the org.mortbay.i-jetty.servlet.DefaultServlet). Content derived from the various ContentProvider instances is probably always going to require some custom coding.

cheers,
Jan

Luciano · 02/03/2008 at 00:27

Hi Jan

I’m trying to get the i-jetty project running but I can’t build it inside de Eclipse. I’ve installed the Ant Plugin and I’m trying to use it but it’s not working. As I’m not a late user of Eclipse, problably I’m committing mistakes. The error is the following:

Buildfile: C:Documents and SettingsUserworkspacei-jettybuild.xml

generate:
        [echo] Generating src-generated
        [copy] Copying 257 files to C:Documents and SettingsUserworkspacei-jettysrc-generated

BUILD FAILED
C:Documents and SettingsUserworkspacei-jettybuild.xml:45: java.io.IOException: Cannot run program "patch" (in directory "C:Documents and SettingsUserworkspacei-jettysrc-generated"): CreateProcess error=2, O sistema não pode encontrar o arquivo especificado

Total time: 1 second

Any tips?

Thanks in advance

Luciano · 02/03/2008 at 18:29

Hi Jan

At this moment I’ve built the i-jetty app. I don’t know if I do this right, but now it’s occurring the following error (on the emulator) when I try to run the app:

——————
Application Error: org.mortbay.ijetty
An Error has occured in org.mortbay.ijetty.java.lang.ExceptionInInitializeError.
——————

In the debug I could that this happens in this line of the IJetty.java, when I click on the Start button:
startService(new Intent(IJetty.this, IJettyService.class), null);

Do you know what’s going on?

Thanks in advance!

Jan Bartel · 02/03/2008 at 23:29

Hi Luciano,

I believe that I forgot to commit a couple of classes to svn. It should be all checked in now, so do an svn up, rebuild and try it again.

cheers
Jan

Anonymous · 05/03/2008 at 06:19

1) how can i get the source code of i-jetty  in zip format.
2) can i run web services on i-jetty

Anonymous · 05/03/2008 at 10:34

i am getting 105 errors in i-jetty code what amy the problem be?

Anonymous · 06/03/2008 at 04:54

how can i run JSP page on i-jetty?

Jan Bartel · 06/03/2008 at 21:26

JSP technology has not been ported to the mobile. JSP is a very file-based technology and most of the environment of android is not.  Moreover, the software architecture of android provides strict separation of visibility of data between applications.

Having said that, android does support the use of an SD card, from which Jetty can already serve files. However, there’s a bit of a leap between that and making JSPs work, with their temporary directories, on-the-fly compilation etc etc.

I’d be interested in hearing about what you’re doing with Jetty on android, as what folks need/want to do will help shape the future direction that i-jetty takes.

cheers
Jan

Luciano · 06/03/2008 at 22:39

Hi Jan

Well, we are interested on Android as a potential platform we would use in our academic work. So, we are testing what already is implemented. In fact, we need a implementation of a SOAP Server on Android, so I ask you if you intend to implement this feature. If not, maybe our team could help to meet this goal. I would appreciate if you contact me by email.

Best regards

Anonymous · 14/03/2008 at 18:19

I am also getting the error
Application Error: org.mortbay.ijetty
An Error has occured in org.mortbay.ijetty.java.lang.ExceptionInInitializeError.

I checked out a fresh version and still happening.

It looks good

Jukka Eklund · 18/03/2008 at 07:32

Hi, great to see this happening. We have been developing a web server and related applications for S60 for a while now. I am curious to know how are you going to enable incoming traffic from the Internet? I mean how to get bypass changing IP and firewalls on the cellular network. Or do you plan to have it working only for localhost and a local LAN?

In case you’re interested in our S60 web server (based on Apache) it’s available at http://mymobilesite.net, and there is a whole lot of developer stuff at http://forum.nokia.com/mws.

Greg Wilkins · 21/03/2008 at 00:50

Jukka,

if the mobile ISPs block access, then we will be restricted to localhost and phones that have wifi and/or bluetooth.   But for the main app that we are working on (manage contacts, images, etc from a browser), that is probably not a big limitation.

If mobile ISPs are going to allow access to the phones, then I’d only expect limited ports like 80 to be available, so that means a HTTP server makes more sense.  But one would have to consider the application that would make the network costs worthwhile….   while a mobile phone may be a tempting ad-hoc webcam, I’d want that to use wifi rather than g3 🙂

Huadong · 25/03/2008 at 02:07

Hi Jan,
    recently, I have ported httpd to android recently. When I saw i-jetty, I guess it’s a better choice. After explored the code, I found jsp is not supported,
    Do you mean i-jetty can just support writing servlet?
    Do you have plan to support this?

Thanks & Regards
Huadong

huadong · 25/03/2008 at 02:15

any way
I have sucessfully run the i-jetty on simulator

Huadong

Jan Bartel · 27/03/2008 at 03:13

Huadong,

Support for jsps requires jvm support for dynamic class loading. The android platform at the time of writing does not support that. I’ve tried one of the workarounds that the osgi guys have been using to get the osgi bundles loaded, but I can’t seem to get it to work.

I raised a bug for this at the Android issue tracker:
http://code.google.com/p/android/issues/detail?id=439&can=1&q=dynamic&colspec=ID%20Type%20Version%20Security%20Status%20Owner%20Summary

As you can see, dynamic classloading will not be supported for 1.x. Not sure what the reasoning behind that is, but by all means raise a bug or otherwise let the Android devs know that you’re interested in such a feature and see if we can shift up the priority.

cheers
Jan

huadong · 04/04/2008 at 17:31

Hi Jan,

  Thanks your comments.

 If dynamic load is enable,

  Do you have some idea about how to make developer develop web application on android phone?

 And google the latest code seams enables the dynamic load. Even they disable the function later, we still have some ways to enable dynamic load java class. So we can develop some wars and download to android phone.

 And now i-jetty removed "start" part to deploye web application automaticly.

  We need give a pattern for developers to develop web application for android phone. Also need a delpoye tool like "start".

 Do you have any good advice?

 Any suggestion is welcome, thankx.

 Regards

Huadong

liuhuadong78@gmail.com

Jan Bartel · 11/04/2008 at 07:33

Hi Huadong,

Well, even if dynamic class loading is supported by the jvm, there’s still a way to go to make webapplication development easy.  For example, to support jsp on-the-fly compilation, the Dalvik jvm would need to support byte-code-generation, and as I understand it this is also missing.

As that facility is missing, in order to support jsps, you’d need to precompile them, and precompile them for the Dalvik jvm.  So you’d need to mess around with generating the java code using jspc, then run the Dalvik compiler on the generated files. So that just makes webapp dev that bit more difficult.

Leaving aside jsps, and the need to compile your whole webapp with the Dalvik compiler, there’s still the issue that there’s no way of sharing libraries on the Dalvik platform. So, for example, it would be convenient if you could use the published jetty libs from the i-jetty project rather than having to import the sources into your project and build them.

In the short term, if you want to do webapp development, I’d stay away from jsps, selectively import the jetty sources into your webapp project, and then write a little class with a main to start a jetty server and deploy your webapp (some examples are in the examples/embedded directory of the jetty distro).

If the future, I’d like to write a jetty deployer that would be able to load an Android .apk bundle that contains a webapp from say the sdcard.

regards
Jan

huadong · 15/04/2008 at 08:42

Hi Jan,
    agree, support jsp is a little more difficulty.

    I got one way to develop web application for i-jetty on android by using
    Developer uses eclipse + maven + jetty-maven-plugin to develop web application and servlet. They need make sure the dependence on jetty6.1.9.
    all the servlet will be compiled into a jar file, use dex tool convert the jar file to dex, then zip it as a jar. we can even make the process automatic.
    when make package for web application, put the above servlet jar into webapps’s lib dir. After package, we get a WAR file. This file can be installed to android internal web server webapps dir.
     During xmlConfiguration configure the web application, I add a class name MyClassLoader to load those servlet.

MyClassLoader is derived from URLClassLoader and it uses dexFile to open the jar, use WabAppClassLoader as parent classloader.

Regards
Huadong

Huadong · 04/05/2008 at 02:13

Hi Jan,
    I can’t download the file which size is bigger than 24K when using NIO.
    I have submit an issue
    http://code.google.com/p/i-jetty/issues/detail?id=1

Regards.
Huadong

Bhavana · 18/06/2008 at 15:32

Hi Jan,

I tried downloading i-jetty by  an svn checkout of the source.
http://i-jetty.googlecode.com/svn/trunk/ i-jetty-read-only

However when I gave this url, eclipse threw me an error saying that the remote location did not exist. But after several attempts the following url worked http://i-jetty.googlecode.com/svn/trunk.

Now I am able to run i-jetty on the emulator device. But when I try to acess i-jetty from my machine browser http://localhost:8080 (after doing the adb forward) I get the following error.

<font size=”2″>

ERROR/Jetty(664): EXCEPTION

ERROR/Jetty(664): java.lang.ExceptionInInitializerError: org/mortbay/jetty/Response

ERROR/Jetty(664): at org.mortbay.jetty.HttpConnection.<init>(HttpConnection.java:116)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.newConnection(SelectChannelConnector.java:328)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$1.newConnection(SelectChannelConnector.java:103)

ERROR/Jetty(664): at org.mortbay.io.nio.SelectChannelEndPoint.<init>(SelectChannelEndPoint.java:51)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$ConnectorEndPoint.<init>(SelectChannelConnector.java:338)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.newEndPoint(SelectChannelConnector.java:322)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector$1.newEndPoint(SelectChannelConnector.java:108)

ERROR/Jetty(664): at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:533)

ERROR/Jetty(664): at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:166)

ERROR/Jetty(664): at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)

ERROR/Jetty(664): at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:537)

ERROR/Jetty(664): at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

My laptop has windows vista.

Could you please guide me as of what the problem might be?

Thanks

Bhavana

</font>

Steve J · 24/07/2008 at 04:06

Hi Jan

Brilliant work with i-jetty. I had an early release working on OS X. Now I’m using the latest release (revision 91) on Ubuntu 8.04 and having a few problems.

Running   deploy.sh   seems to build and install everything correctly. i-jetty starts in the emulator.

But then accessing    http://127.0.0.1:8888&nbsp; from outside the emulator, or   http://127.0.0.1:8080 &nbsp; from the browser inside the emulator gives

Error 404 – Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:

I get the same result by ‘hand-crafting’ the build/install.

So it looks like i-jetty is doing something, but not picking up the Hello and Console webapps that should have been deployed.

Perhaps the sdcard content isn’t what it should be. The content after running deploy.sh is at the end of this message.

It’s probably something trivial but I’ve spent 2 full days trying to solve this problem with no success. I wonder if you can suggest anything?

(BTW I’m intending to use i-jetty for a port of our open-source Greenstone 3 digital library software… http://www.greenstone.org)

Thanks
Steve

sdcard:
jetty

sdcard/jetty:
contexts  etc  webapps

sdcard/jetty/contexts:
hello.xml

sdcard/jetty/etc:
webdefault.xml

sdcard/jetty/webapps:
console  hello

sdcard/jetty/webapps/console:
console.css  index.html  meta-inf  web-inf

sdcard/jetty/webapps/console/meta-inf:
manifest.mf  maven

sdcard/jetty/webapps/console/meta-inf/maven:
org.mortbay.ijetty.console

sdcard/jetty/webapps/console/meta-inf/maven/org.mortbay.ijetty.console:
console

sdcard/jetty/webapps/console/meta-inf/maven/org.mortbay.ijetty.console/console:
pom.properties  pom.xml

sdcard/jetty/webapps/console/web-inf:
classes  web.xml

sdcard/jetty/webapps/console/web-inf/classes:

sdcard/jetty/webapps/hello:
index.html  meta-inf  web-inf

sdcard/jetty/webapps/hello/meta-inf:
manifest.mf  maven

sdcard/jetty/webapps/hello/meta-inf/maven:
com.test

sdcard/jetty/webapps/hello/meta-inf/maven/com.test:
hello

sdcard/jetty/webapps/hello/meta-inf/maven/com.test/hello:
pom.properties  pom.xml

sdcard/jetty/webapps/hello/web-inf:
classes  libs  web.xml

sdcard/jetty/webapps/hello/web-inf/classes:

sdcard/jetty/webapps/hello/web-inf/libs:

Jan Bartel · 25/07/2008 at 00:21

Hi Steve,

Thanks for the interest in i-jetty! We’ve been doing some major reorganizations on it lately, and I think you have caught us mid-stream.

 We changed the console from being anchored at "/" to "/console" so I would expect you to get the default jetty 404 page listing the contexts available. I’d be conconcerned if http://localhost:8888/console was not available – is it?  I do plan to provide a much nicer looking default 404 page when running jetty under android, but I unfortunately I just haven’t managed to get around to it yet 🙁

You should be able to avoid that page if you deploy a webapp at "/" – either by putting it in webapps/ROOT  or by using a context xml file to explicitly set the  context path to "/".

cheers
Jan

SteveJ · 25/07/2008 at 05:40

Hi Jan

Thanks for the quick response. Good news….

A clean install and build of r91 worked perfectly (webapps are available and working) after

  1. mvn install     (complains that no path to android home)
  2. mvn -Dandroid.home=<PATH_TO_ANDROID> install
  3. ./deploy.sh

But I then attempted to repeat the process… delete i-jetty, check it out again, same steps as above… and was back at the same state as in my previous post.   ie i-jetty apparently working but the webapps don’t appear.

The only difference between non-working and working states was a reboot in between. So I rebooted and the problem was resolved. I am now unable to replicate the problem at all.

Therefore it must have been something about my machine’s state (Ubuntu 8.04 inside VirtualBox on OSX 10.5.4).

My apologies for taking up your time with the problem.  If I _can_ replicate it I’ll let you know.

Thanks again.
Steve

Sudha Gupta · 19/11/2008 at 07:21

Hello Jan,
I have a J2me project in NetBeans, I want to run it on android.
I have tried through J2me Midp runner but it didnt work. Can you plz tell me is there any way to convert my jar file to .apk through command line.
Thanks
Sudha Gupta

alberto · 26/01/2009 at 11:16

I

Jan · 27/01/2009 at 10:13

Hi Alberto,
The war files need to be served from a web server, and then downloaded by the ijetty application. The easiest way to download them is type into the ijetty download application the url of the webapp from the ijetty download page on google.
By the way, the best way to discuss i-jetty is via the jetty mailing list at support@jetty.codehaus.org.
cheers
Jan

alberto · 28/01/2009 at 17:04

Oh, ok, thank you Jan.
So, for example, if I’m developing a webapp, how should I download it or make it work in the IJetty?
Should I put it into a web server? can it be a local server? or can I do just adb push into the correct path in the IJetty?
Thanks a lot for your help. And thank you for telling me about the jetty mailing list.
Saludos!

Jan · 28/01/2009 at 17:27

Alberto,

Here’s the subscription address for the jetty user list (user@jetty.codehaus.org – ignore support@jetty.codehaus.org, that was my mistake) :
http://xircles.codehaus.org/projects/jetty/lists

If you want to dowload the prepared war file to i-jetty you’ll need to serve it off a server somewhere – either local or remote.

cheers
Jan

alberto · 28/01/2009 at 20:14

Thank you again Jan!
I’ve already downloaded both example apps, although when I’m trying to find them in the browser, their links appear in the localhost:8080 page, but when I’m trying to find them in their own path by clicking the links or writting the path, they don’t appear, it says error 503, service unavailable.
Anyway, thank your for your help!

t-c · 03/02/2009 at 15:57

I have the same problem as alberto – HTTP ERROR: 503. How do I setup the permission?

Jan · 03/02/2009 at 16:42

Please use the jetty lists rather than adding comments to this post.

Here’s the subscription page:
http://xircles.codehaus.org/projects/jetty/lists

This blog only allows limited length comments so I can’t give proper replies anyway!

Jan

lakhdar meziane · 11/02/2009 at 07:03

hello jan i am Lakhdar i have probleme with i-jetty i installed it in emulator under windows and when i acced to my broser “internet explorer”on my desktop and i tpe”http://127.0.0.1:8080or8888″no thing displayed could not find page i do not know what is the problem?!thanks advance and accept all my respects.please answer me i wait u

Steve Jones · 12/02/2009 at 20:51

Hi Jan

Re: ijetty webapps, external library class property files and Resource Bundles

I’m making progress turning our Greenstone software http://www.greenstone.org/greenstone3-home into an i-jetty web. However it’s dependent upon external packages such as xalan etc which have class .properties files that the packages attempt to load a runtime.

An example runtime error is (within Xalan org.apache.xml.serializer)

 ToXMLSAXHandler: MissingResourceException ToXMLSAXHandler: classname = org.apache.xerces.impl.msg.DOMMessages_en_US 

Dexing my webapp ignores .properties files. They end up in the web-inf/classes directory. –keep-classes makes no difference.

I can hack around this for the Greenstone code but not the external libraries.

Do you have any advice for i-jetty webapps using external packages that load properties as ResourceBundles?

Cheers, Steve

lakhdar meziane · 26/02/2009 at 10:46

hi everybody my problem is what u mean by context path?and how can i choose it?thank u very much advance.accept my all respects.good day

Jan Bartel · 19/04/2009 at 05:33

Hi Steve,
The good news is that I think sdk1.5_pre seems to solve the ResourceBundle problem. I’ve only done a quick preliminary test, but the signs are good so far!
cheers
Jan

kwty · 26/04/2009 at 02:07

Hi, I am using ijetty2.0 with sdk1.1-r1 and I download the source code ,mvn,and python as the instructions said but I want to know from where I have to run the code on my g1 and how. Moreover, I followed the instruction to install the mvn but there is error field to install it .
Would you please tell me what exactly the role of each tool I have dowwnload it as I said above on this project??
Thanks,

Jan Bartel · 30/04/2009 at 07:47

kwty,

You might find the new wiki page on building i-jetty answers your questions.

Jan

Jer · 03/05/2009 at 17:55

Hello Jan,

I wanted to say thanks for porting Jetty to the Android platform. I am doing research on Parallel Mobile applications at the University of San Francisco. We are thinking about using Jetty as part of our project.

I have had a little trouble getting the hello and chat apps to run (getting a 503 error), so I posted issue #45 on code.google.com.

thanks again,
jer

Jan Bartel · 04/05/2009 at 00:53

Hi Jer,

I’ve responded on your issue. Just wanted to say good luck with the project, and please let me know how it goes! I’d be happy to put up anything that comes out of the project on the Jetty Powered pages

cheers, Jan

sajjad · 15/07/2009 at 14:44

Hi. I

Brian Sawyer · 18/07/2009 at 18:38

Hi Jan:
I’m able to successfully install the Hello.war servlet from within Ijetty, however when I go to http://127.0.0.1:8080 and select the context for the Hello app from the list that appears after the 404 error, the resulting page say Http error 503, problem accessing Hello2.0, reaason: Service Unavailable.
Also wondered if Webdav servlet has ever been successfully run within Ijetty?
Thanks much for any help.

Anirban Banerjee · 02/04/2010 at 22:23

Hi
I am configuring the greenstone 3.04 to a fedora 12 server. everything is running perfectly except when i modify a collection from the applet version (client machine) then the error “Sh: db2txt command not found” comes and the error comes in xml plugins .so the metadata is no build , But it shows that collection build successfully. but when i go to the search page it shows none and the gsdl server crashed.
Plz reply soon if you can help me out.
Regards

Jan · 06/04/2010 at 02:09

Hi Anirban,

I think you’ll have to contact the Greenstone project folks
for this one, as the error you report doesn’t seem to describe
a problem in the i-jetty code. If the Greenstone folks find an
i-jetty problem, please do ask them to raise an issue at http://code.google.com/p/i-jetty/issues/list.

cheers,

Jan

Comments are closed.