I want to deploy a simple Play (1.2.4) application to WebSphere 8. I have the application working locally on Windows. Both are Java 1.6. I created a WAR file using:
play clean
play war --zip -o c:\sampleapp
then modified the generated web.xml to define my server Datasource, build the war file again and deployed. During the deployment it found my resource-ref from the web.xml and I bound it to the WAS defined datasource. Then I changed classloader order to "parent last" (based on the Play deployment options pages and other threads). Then I started the application with no errors.
I have a class which extends play.jobs.Job with a method marked @OnApplicationStart. When I start the newly installed application through the WAS console, it starts up and executes this method which connects to the datasource and loads up some data and puts it into cache.
The problem comes as soon as I try to access my first Controller, where I get this error:
[9/17/12 16:19:48:132 CDT] 00000022 servlet I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [sampleapp] [/sampleapp] [play]: Initialization successful.
[9/17/12 16:19:48:773 CDT] 00000022 SystemOut O 16:19:48,772 ERROR ~
@6bl9mfbm1
Internal Server Error (500)
Execution exception (In /app/controllers/Application.java around line 41)
RuntimeException occured : play.mvc.Scope$Session
play.exceptions.JavaExecutionException: play.mvc.Scope$Session
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:231)
at play.server.ServletWrapper$ServletInvocation.execute(ServletWrapper.java:557)
at play.Invoker$Invocation.run(Invoker.java:278)
at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:548)
at play.Invoker.invokeInThread(Invoker.java:68)
at play.server.ServletWrapper.service(ServletWrapper.java:142)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1214)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:774)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:456)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1027)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Caused by: java.lang.RuntimeException: play.mvc.Scope$Session
at javassist.runtime.Desc.getClassType(Desc.java:156)
at javassist.runtime.Desc.getType(Desc.java:122)
at javassist.runtime.Desc.getType(Desc.java:78)
at controllers.Application.connected(Application.java:41)
at controllers.Application.index(Application.java:49)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
... 28 more
Here is my relevant Controller code:
public class Application extends Controller {
@Before(unless={"login","index"})
static void addUser() {
User user = connected();
if(user != null) {
flash.put("user", user);
// renderArgs.put("user", user);
} else {
flash.error("Please log in.");
index();
}
}
static User connected() {
// if(renderArgs.get("user") != null) {
// return renderArgs.get("user", User.class);
// }
String username = session.get("user"); // Line 41 - Error!
if(username != null) {
return User.find("byUsername", username).first();
}
return null;
}
public static void index() {
if(connected() != null) {
Download.index(1);
}
render();
}
..
..
}
The error appears to come from the session reference. Note that the commented lines referencing renderArgs also caused a similar error when active.
Is javassist not "enhancing" properly somewhere? I tried replacing the javassist jar with the latest version, with the same result.
I'm trying really hard to get Play in the "enterprise" here, so I'd really like this to work. As of September 2012 I can't tell if Play has run on WAS8 successfully or not. I would consider Play 2 (java) but it seems to be definitely not WAS supported, and the plugin play2war looks to not have WAS support yet either. Silly that we can't run without WAS, but this is the reality of our enterprise.
Update:
I've also tried Play 1.2.5 now and created a new app and added a single line, session.get("x") to the Application.index method. Deployed the war file and got the same error at first access.