Jetty and webapp in a single JAR?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Jetty and webapp in a single JAR?

Albert Strasheim
Hello all

I'm playing with JRuby+Rails and embedded Jetty in an attempt to make an
application that consists of a single JAR (note, not WAR). So far, I've been
able to make a JRuby+Rails application into a WAR and serve it up with
Jetty. Works like a dream.

Now I would like to put my own server application (running in a few threads)
and Jetty serving up a web interface to my application (written in
JRuby+Rails) in a single JAR.

I've managed to get a basic embedded Jetty going, but I can't figure out how
to make Jetty serve up a web application from "inside" the JAR (i.e. from
the classpath). As far as I can see, the Jetty WebAppContext class expects
to be configured with a directory.

Is there a way to get this working? I'd then be able to do:

java -jar myapp+jettyrailsapp.jar

and have my application and its Jetty+JRuby+Rails frontend start up as a
single process.

Thanks for any help.

Cheers,

Albert Strasheim


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Jetty and webapp in a single JAR?

Chris Haynes
While awaiting a definitive answer, you could start by investigating the potential of file 'start.config' which is in the resources branch of the 'start' module.

HTH

Chris Haynes



On Sunday, May 20, 2007 at 12:26:14 AM, Albert Strasheim wrote:
> Hello all

> I'm playing with JRuby+Rails and embedded Jetty in an attempt to make an
> application that consists of a single JAR (note, not WAR). So far, I've been
> able to make a JRuby+Rails application into a WAR and serve it up with
> Jetty. Works like a dream.

> Now I would like to put my own server application (running in a few threads)
> and Jetty serving up a web interface to my application (written in
> JRuby+Rails) in a single JAR.

> I've managed to get a basic embedded Jetty going, but I can't figure out how
> to make Jetty serve up a web application from "inside" the JAR (i.e. from
> the classpath). As far as I can see, the Jetty WebAppContext class expects
> to be configured with a directory.

> Is there a way to get this working? I'd then be able to do:

> java -jar myapp+jettyrailsapp.jar

> and have my application and its Jetty+JRuby+Rails frontend start up as a
> single process.

> Thanks for any help.

> Cheers,

> Albert Strasheim


> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support
Reply | Threaded
Open this post in threaded view
|

Re: Jetty and webapp in a single JAR?

Johannes Brodwall
In reply to this post by Albert Strasheim
Hi, Albert

Take a look at the documentation for embedding Jetty:
http://docs.codehaus.org/display/JETTY/Embedding+Jetty.

You might especially like to see
http://jetty.mortbay.org/xref/org/mortbay/jetty/example/OneServletContext.html.

If you have a jar that "includes" jetty's jars, servlet-api etc. just
using this class as the Main-Class should do the trick as long as you
only have one servlet. The doc has more information for more complex
examples.


~Johannes

On 5/20/07, Albert Strasheim <[hidden email]> wrote:

> Hello all
>
> I'm playing with JRuby+Rails and embedded Jetty in an attempt to make an
> application that consists of a single JAR (note, not WAR). So far, I've been
> able to make a JRuby+Rails application into a WAR and serve it up with
> Jetty. Works like a dream.
>
> Now I would like to put my own server application (running in a few threads)
> and Jetty serving up a web interface to my application (written in
> JRuby+Rails) in a single JAR.
>
> I've managed to get a basic embedded Jetty going, but I can't figure out how
> to make Jetty serve up a web application from "inside" the JAR (i.e. from
> the classpath). As far as I can see, the Jetty WebAppContext class expects
> to be configured with a directory.
>
> Is there a way to get this working? I'd then be able to do:
>
> java -jar myapp+jettyrailsapp.jar
>
> and have my application and its Jetty+JRuby+Rails frontend start up as a
> single process.
>
> Thanks for any help.
>
> Cheers,
>
> Albert Strasheim
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jetty-support mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jetty-support
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jetty-support mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jetty-support