如何将 Play 应用程序部署到 Websphere 7
根据 Play 文档,可以在战争中打包 Play 应用程序文件并将其部署到 Websphere,但我遇到了问题。
我正在使用带有 --zip
选项的 play war
命令,该命令运行正常。生成的 war 文件具有正确的布局(WEB-INF 位于顶层,我的 jar 移至 WEB-INF/lib)。
在我的 Websphere 服务器上部署 war 文件后,我将应用程序的类加载顺序更改为父级最后,以便它使用任何冲突的库的 Play 版本。然后我尝试加载我的应用程序的一个页面(任意页面),然后收到错误。
我尝试以相同的方式部署演示应用程序和一个新的空应用程序,但同样,我只是得到一个空页面,上面写着 Not find Get /
。日志中唯一的内容是 WARN ~ 404 ->获取/(获取/)。
我已经在 Play 1.2.3 和 1.2.4、Websphere 7.0.0.0 和 7.0.0.19 上尝试过。我还尝试过在 Websphere 中切换不同的部署选项,尽管默认选项看起来应该可以工作。
有人获得了可以在 Websphere 中运行的 Play 应用程序吗?如果是这样,怎么办?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于让它工作了。我将记录我的步骤,以防其他人将来在 WebSphere 上部署 Play 应用程序时遇到类似的问题。
1 - 第一个问题是 404。Websphere 不会将对 root (/) 的请求传递给应用程序来处理(wtf?),因此解决方法是在路由文件中定义类似的路由:
而不是(或在顶部) of)
2 - 下一个问题是与不存在的持久性 (JPA) 方法相关的错误。 Play 使用 JPA 2.0,而 WebSphere 7 使用他们自己的定制版本的 OpenJPA 1.0。您可以安装JPA 2 和 OSGI 的功能包(您不需要 OSGI 部分,因此可以忽略)。请注意,该功能包要求您安装了 WebSphere 7.0.0.9 或更高版本。这意味着应用程序服务器和捆绑的 JDK 都需要匹配修复包。在安装 JPA 功能包之前,需要先安装服务器和 JDK 的 IE 修复包 21(当时或正在编写的最新版本)。在功能包安装结束时,它会询问您是否要运行配置文件工具。说是的。这个工具可以让你“增强”你的个人资料(你要安装战争的服务器节点)。增强远离!
3 - 构建一个可在 WebSphere 中使用的 war 文件:
这将创建一个名为
的文件夹(展开的 war)和一个名为
的 .war 文件>.war,应用程序 ID 设置为 prod。爆炸的战争可以删除。在 Linux 上运行此命令会将我的 WEB-INF 文件夹放入未命名的文件夹中(因此,从 war 文件的根级别向下一级)。换句话说,它创建的不是/WEB-INF/,而是类似//WEB-INF/ 的结构。不管怎样,我现在正在手动修复它,通过正确地重新压缩它。有人知道如何避免这个问题吗?
4 - 使用管理控制台中的所有默认设置将 war 文件安装到 WebSphere 中...或者如果您知道自己在做什么,则可以调整它们。
5 - 我不完全确定此步骤是否必要(不会改变我的特定应用程序的任何内容),但我在网上读到的有关让 Play 应用程序在 WebSphere 中运行的所有建议都说要执行此操作。嗯,不会造成伤害。单击您安装的应用程序。单击“类加载和更新检测”链接。然后选择“首先使用本地类加载器加载的类(最后是父级)”选项。好的。节省。
6 - 打开浏览器页面到您的地址(如果本地运行 websphere,则为 localhost:9080),然后进行测试。此时应该可以了!希望如此。祝你好运。
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:
instead of (or on top of)
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. I.E. 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:
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.
部署到 Servlet 容器的一个常见问题是,除非您将应用程序部署为 ROOT war 文件,否则经常会遇到问题。您确定您的 WAR 文件已部署,以便应用程序的路径可用为
/
。此线程是遇到的常见问题
如何使用Play Framework 的配置文件中的“war.context”?
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 ?