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?!
Posted at 02:30AM Feb 21, 2008 by janb in General | Comments[44]
Posted by Anonymous on February 21, 2008 at 03:36 AM EST #
Posted by Don Ferguson on February 21, 2008 at 02:26 PM EST #
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?
Posted by Mike Wilson on February 29, 2008 at 09:55 PM EST #
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
Posted by Jan Bartel on March 01, 2008 at 02:44 AM EST #
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 Settings\User\workspace\i-jetty\build.xml
generate:
[echo] Generating src-generated
[copy] Copying 257 files to C:\Documents and Settings\User\workspace\i-jetty\src-generated
BUILD FAILED
C:\Documents and Settings\User\workspace\i-jetty\build.xml:45: java.io.IOException: Cannot run program "patch" (in directory "C:\Documents and Settings\User\workspace\i-jetty\src-generated"): CreateProcess error=2, O sistema não pode encontrar o arquivo especificado
Total time: 1 second
Any tips?
Thanks in advance
Posted by Luciano on March 02, 2008 at 05:27 PM EST #
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!
Posted by Luciano on March 03, 2008 at 11:29 AM EST #
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
Posted by Jan Bartel on March 03, 2008 at 04:29 PM EST #
2) can i run web services on i-jetty
Posted by Anonymous on March 05, 2008 at 11:19 PM EST #
Posted by Anonymous on March 06, 2008 at 03:34 AM EST #
Posted by Anonymous on March 06, 2008 at 09:54 PM EST #
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
Posted by Jan Bartel on March 07, 2008 at 02:26 PM EST #
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
Posted by Luciano on March 07, 2008 at 03:39 PM EST #
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
Posted by Anonymous on March 15, 2008 at 10:19 AM EST #
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.
Posted by Jukka Eklund on March 18, 2008 at 11:32 PM EST #
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 :-)
Posted by Greg Wilkins on March 21, 2008 at 04:50 PM EST #
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
Posted by Huadong on March 25, 2008 at 06:07 PM EST #
I have sucessfully run the i-jetty on simulator
Huadong
Posted by huadong on March 25, 2008 at 06:15 PM EST #
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
Posted by Jan Bartel on March 27, 2008 at 07:13 PM EST #
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
Posted by huadong on April 05, 2008 at 09:31 AM EST #
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
Posted by Jan Bartel on April 11, 2008 at 10:33 PM EST #
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
Posted by huadong on April 15, 2008 at 11:42 PM EST #
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
Posted by Huadong on May 04, 2008 at 05:13 PM EST #
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>Posted by Bhavana on June 19, 2008 at 06:32 AM EST #
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 from outside the emulator, or http://127.0.0.1:8080 from the browser inside the emulator gives
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... 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:
Posted by Steve J on July 24, 2008 at 07:06 PM EST #
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
Posted by Jan Bartel on July 25, 2008 at 03:21 PM EST #
Thanks for the quick response. Good news....
A clean install and build of r91 worked perfectly (webapps are available and working) after
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
Posted by SteveJ on July 25, 2008 at 08:40 PM EST #
Posted by Sudha Gupta on November 20, 2008 at 12:21 AM EST #
Posted by alberto on January 27, 2009 at 04:16 AM EST #
Posted by Jan on January 28, 2009 at 03:13 AM EST #
Posted by alberto on January 29, 2009 at 10:04 AM EST #
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 JanPosted by Jan on January 29, 2009 at 10:27 AM EST #
Posted by alberto on January 29, 2009 at 01:14 PM EST #
Posted by t-c on February 04, 2009 at 08:57 AM EST #
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!
JanPosted by Jan on February 04, 2009 at 09:42 AM EST #
Posted by lakhdar meziane on February 12, 2009 at 12:03 AM EST #
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)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, StevePosted by Steve Jones on February 13, 2009 at 01:51 PM EST #
Posted by lakhdar meziane on February 27, 2009 at 03:46 AM EST #
Posted by Jan Bartel on April 19, 2009 at 08:33 PM EST #
Posted by kwty on April 26, 2009 at 05:07 PM EST #
kwty,
You might find the new wiki page on building i-jetty answers your questions.
JanPosted by Jan Bartel on April 30, 2009 at 10:47 PM EST #
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
Posted by Jer on May 04, 2009 at 08:55 AM EST #
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, JanPosted by Jan Bartel on May 04, 2009 at 03:53 PM EST #
Posted by sajjad on July 16, 2009 at 05:44 AM EST #
Posted by Brian Sawyer on July 19, 2009 at 09:38 AM EST #