This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Use Scala on a web server

4 replies
Antoine PINSARD
Joined: 2011-05-02,
User offline. Last seen 42 years 45 weeks ago.

Hi world,

I'm gonna start learning Scala and I want first my server to be able
to work with Scala (so with Lift framework),

but I don't know how to do it. I succeeded doing it on my personal
computer but it's on the port 8080 and requires to run "sbt update
jetty-run".

Did someone know how to install a server for Scala ?

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Use Scala on a web server
Run "sbt package" to generate a war file
This then gets copied into an installation of jetty, tomcat, websphere, etc. just the same as deploying any other Java web-app (the exact method depends on your choice of app server).


On 2 May 2011 18:19, Antoine PINSARD <antoine [dot] pinsard [at] gmail [dot] com> wrote:
Hi world,

I'm gonna start learning Scala and I want first my server to be able
to work with Scala (so with Lift framework),

but I don't know how to do it. I succeeded doing it on my personal
computer but it's on the port 8080 and requires to run "sbt update
jetty-run".

Did someone know how to install a server for Scala ?



--
Kevin Wright

gtalk / msn : kev [dot] lee [dot] wright [at] gmail [dot] com kev [dot] lee [dot] wright [at] gmail [dot] commail: kevin [dot] wright [at] scalatechnology [dot] com
vibe / skype: kev.lee.wrightquora: http://www.quora.com/Kevin-Wright
twitter: @thecoda

"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
fanf
Joined: 2009-03-17,
User offline. Last seen 2 years 30 weeks ago.
Re: Use Scala on a web server
On 02/05/2011 19:19, Antoine PINSARD wrote:
313c22f7-438e-43a2-b7d9-db67eb9d704f [at] u15g2000vby [dot] googlegroups [dot] com" type="cite">
Hi world,

I'm gonna start learning Scala and I want first my server to be able
to work with Scala (so with Lift framework),

but I don't know how to do it. I succeeded doing it on my personal
computer but it's on the port 8080 and requires to run "sbt update
jetty-run".

Did someone know how to install a server for Scala ?

You don't want a server for Scala, but a Java application server: Lift application are standard Java servlets, they will run on any Java application server which support that norm (Jetty, Tomcat, JBoss, etc).
So, firt install one of them (Jetty is good, but YMMV).

Then, you will deploy a WAR (Web App Archive)  on that server. A WAR is obtained from SBT with "sbt package", or something like that (I don't know SBT).

Then, you will only have to copy the WAR under the good directory in the application server directory layout. I think for Jetty its $JETTY_HOME/webapps.

For example, if you put "foo.war" in $JETTY_HOME/webapps and then start Jetty, your application will be accessible in localhost:8080/foo/.

There is a bunch of configuration option, specific to each application servers. Here, you will have to read the manual.

Hope it helps.
-- 
Francois ARMAND
http://fanf42.blogspot.com
http://www.normation.com
fanf
Joined: 2009-03-17,
User offline. Last seen 2 years 30 weeks ago.
Re: Use Scala on a web server
On 02/05/2011 19:34, Francois wrote:
4DBEEB1A [dot] 2020905 [at] gmail [dot] com" type="cite"> ...

There is a bunch of configuration option, specific to each application servers. Here, you will have to read the manual.

Hope it helps.

Ho, and there is some more documentation on Lift website: http://www.assembla.com/spaces/liftweb/wiki/Deployment

-- 
Francois ARMAND
http://fanf42.blogspot.com
http://www.normation.com
vpatryshev
Joined: 2009-02-16,
User offline. Last seen 1 year 24 weeks ago.
Re: Use Scala on a web server
Generally speaking, for a small server, you don't need any framework, just have

abstract class YourSpecificServletServlet extends HttpServlet { ... }

then build a war and deploy it in tomcat.

As to port 80, if you are on ubuntu, the following voodoo will help:

sudo apt-get install vsftpd
sudo iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A OUTPUT -d (your server url) -p tcp --dport 80 -j REDIRECT --to-ports 8080
sudo iptables -t nat -A PREROUTING -d (your server url) -p tcp --dport 80 -j REDIRECT --to-ports 8080


Thanks,
-Vlad


On Mon, May 2, 2011 at 10:19 AM, Antoine PINSARD <antoine [dot] pinsard [at] gmail [dot] com> wrote:
Hi world,

I'm gonna start learning Scala and I want first my server to be able
to work with Scala (so with Lift framework),

but I don't know how to do it. I succeeded doing it on my personal
computer but it's on the port 8080 and requires to run "sbt update
jetty-run".

Did someone know how to install a server for Scala ?

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland