Show me the code! – By Davanum Srinivas

May 6, 2012

Deploying a Scala based Servlet in Liberty

Filed under: websphere — Tags: , , — Davanum Srinivas @ 8:16 pm

Fetch the scala servlet sample using git:

dims@dims-laptop-520:~$ git clone git://

Take a peek at the servlet code:

package org.peat.scalaservlet

import javax.servlet.http._
import javax.servlet._

class Example extends HttpServlet {

  override def doGet(request: HttpServletRequest, response: HttpServletResponse) = response.getWriter().println( exampleContent )

  def exampleContent(): String = { "Hello world, from a Scala servlet!" }

Build the sample using maven:

dims@dims-laptop-520:~/scala-servlet$ mvn war:war

Follow instructions from the following url to deploy the ScalaServlet.war:

Don’t forget to enable the servlet feature in the defaultServer/server.xml. Once the server is started peek at the logs

dims@dims-laptop-520:~/wlp$ cat ./usr/servers/defaultServer/logs/trace_12.05.04_22.50.54.0.log
[04/May/2012 22:50:54:141 -0700]  00000001 * id= [AUDIT   ] CWWKE0001I: The kernel was launched.
[04/May/2012 22:50:55:645 -0700]  0000001d * id=            [AUDIT   ] CWWKF0007I: A feature update is starting after 1.735 seconds.
[04/May/2012 22:50:55:682 -0700]  00000001 * id= [AUDIT   ] CWWKE0002I: The kernel started after 1.774
[04/May/2012 22:50:56:263 -0700]  00000016 * id=       [AUDIT   ] CWWKZ0058I: Application monitor started after 2.353 seconds.
[04/May/2012 22:50:56:265 -0700]  0000001d * id=            [AUDIT   ] CWWKF0008I: The feature update is complete after 2.356 seconds.
[04/May/2012 22:50:56:314 -0700]  0000001f * id=                    [AUDIT   ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host localhost  (IPv4: port 9080.
[04/May/2012 22:50:56:805 -0700]  00000020 * id=                     [AUDIT   ] CWWKT0016I: Web application available (default_host): http://localhost:9080/ScalaServlet/*
[04/May/2012 22:50:56:811 -0700]  00000020 * id=                    [AUDIT   ] SRVE9998A: Application ScalaServlet added to web container.
[04/May/2012 22:50:56:814 -0700]  00000020 * id=              [AUDIT   ] CWWKZ0001I: The application ScalaServlet has started successfully.

All’s well, now just point your browser to http://localhost:9080/ScalaServlet/


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: