How to deploy Play app to Websphere 7
According to the Play documentation, it is possible to pack a Play app in a war file and deploy it to Websphere, but I'm having problems.
I'm using the play war
command with the --zip
option, which is working properly. The resulting war file has the right layout (WEB-INF at top level, with my jars moved to WEB-INF/lib).
After deploying the war file on my Websphere server, I change the app's class loading order to parent last so that it uses Play's version of any libs that conflict. And then I try to load a page, any page, of my app, and get an error.
I've tried deploying demo apps and a new empty app the same way, but again, I just get an empty page that says Not found Get /
. The only thing in the log is WARN ~ 404 -> GET / (GET /)
.
I've tried it with Play 1.2.3, and 1.2.4, Websphere 7.0.0.0, and 7.0.0.19. I've also tried toggling the different deployment options in Websphere, though the default options look like they should work.
Has anyone gotten a Play app to work in Websphere? If so, how?
I finally have it working. I'll document my steps in case anyone else runs into similar problems deploying a Play app on WebSphere in the future.
1 - The first issue was the 404. Websphere doesn't pass requests for root (/) to the app to handle (wtf?), so the fix is to define a similar route in your routes file:
GET /* Application.index
instead of (or on top of)
GET / Application.index
2 - The next issue was errors related to persistence (JPA) methods not existing. Play uses JPA 2.0, while WebSphere 7 uses their own custom version of OpenJPA 1.0. You can install a feature pack for JPA 2 and OSGI (you don't need the OSGI part, so it can be ignored). Note that the feature pack requires that you have WebSphere 7.0.0.9 or later installed. That means matching fix packs for both the app server and the bundled JDK. IE fix pack 21 (the latest at the time or writing) for both the server and the JDK need to be installed first before installing the JPA feature pack. At the end of the feature pack installation, it will ask you if you want to run the profile tool. Say yes. This tool will let you "augment" your profile (the server node you're going to install your war on). Augment away!
3 - Build a war file that will work in WebSphere:
play war <appFolder> -o <outputFolder> --zip --%prod
This will create a folder named <outputFolder>
(an exploded war) and a .war file named <outputFolder>
.war, with the app id set to prod. The exploded war can be deleted.
Running this command on linux keeps putting my WEB-INF folder inside an unnamed folder (so, down a level from the root level of the war file). In other words, instead of /WEB-INF/, it's creating a structure like //WEB-INF/. Anyway, I'm fixing it manually for now, by re-zipping it properly. Anyone know how to avoid this problem?
4 - Install the war file into WebSphere with all the default settings in the admin console...or tweak them if you know what you're doing.
5 - I'm not entirely sure if this step is necessary (doesn't change anything for my particular app), but all the advice I've read online about getting Play apps to run in WebSphere say to do this. Meh, it can't hurt. Click on your installed app. Click on the "Class loading and update detection" link. Then select the "Classes loaded with local class loader first (parent last)" option. Ok. Save.
6 - Open a browser page to your address (localhost:9080 if running websphere locally), and test. At this point it should work! Hopefully. Good luck.
A common problem with deploying to Servlet containers is that unless you are deploying your application as the ROOT war file, then you often run into problems. Are you sure that your WAR file has been deployed so that the path to the application is available as /
.
This thread is a common issue encountered
how to use "war.context" in Configuration file of Play Framework ?
链接地址: http://www.djcxy.com/p/55886.html