如何将Play应用部署到Websphere 7 [英] How to deploy Play app to Websphere 7

查看:78
本文介绍了如何将Play应用部署到Websphere 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Play文档,可以打包Play应用在一个war文件中并将其部署到Websphere,但是我遇到了问题.

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.

我正在将play war命令与--zip选项一起使用,该命令工作正常.生成的war文件具有正确的布局(顶层是WEB-INF,我的jar移到了WEB-INF/lib).

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).

在我的Websphere服务器上部署war文件之后,我将应用程序的类加载顺序更改为最后一个父类,以便它使用任何冲突的lib的Play版本.然后,我尝试加载应用程序的页面,任何页面,并出现错误.

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.

我曾尝试以相同的方式部署演示应用程序和新的空白应用程序,但同样,我只得到一个空白页,显示Not found Get /.日志中唯一的是WARN ~ 404 -> GET / (GET /).

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 /).

我已经在Play 1.2.3和1.2.4,Websphere 7.0.0.0和7.0.0.19中进行了尝试.我还尝试过切换Websphere中的不同部署选项,尽管默认选项看起来应该可以使用.

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.

有人有Play应用程序可以在Websphere中工作吗?如果可以,怎么办?

Has anyone gotten a Play app to work in Websphere? If so, how?

推荐答案

我终于可以使用它了.我将记录我的步骤,以防将来其他人遇到在WebSphere上部署Play应用程序时遇到的类似问题.

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-第一个问题是404.Websphere不会将对root(/)的请求传递给应用程序来处理(wtf?),因此解决方法是在您的路由文件中定义类似的路由:

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

代替(或位于其顶部)

GET    /    Application.index

2-下一个问题是与不存在的持久性(JPA)方法相关的错误. Play使用JPA 2.0,而WebSphere 7使用他们自己的定制版本的OpenJPA 1.0.您可以安装用于JPA 2和OSGI的功能包(您不需要OSGI部分,因此可以忽略).请注意,该功能部件包要求您已安装WebSphere 7.0.0.9或更高版本.这意味着与应用程序服务器和捆绑的JDK匹配的修订包. IE.必须先安装服务器和JDK的修订包21(当时或撰写时为最新版本),然后再安装JPA功能包.在功能部件包安装结束时,它将询问您是否要运行配置文件工具.说是.此工具可让您扩充"个人资料(要在其中安装战争的服务器节点).增强!

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-构建一个可在WebSphere中运行的war文件:

3 - Build a war file that will work in WebSphere:

play war <appFolder> -o <outputFolder> --zip --%prod

这将创建一个名为<outputFolder>(爆炸战争)的文件夹和一个名为<outputFolder> .war的.war文件,其应用程序ID设置为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.

在linux上运行此命令会将我的WEB-INF文件夹放在一个未命名的文件夹中(因此,从war文件的根目录下移了一层).换句话说,它创建的不是//WEB-INF/,而是//WEB-INF/.无论如何,我现在通过适当地重新压缩来手动对其进行修复.有人知道如何避免这个问题吗?

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-使用管理控制台中的所有默认设置将war文件安装到WebSphere中...或者如果知道自己在做什么,则对其进行调整.

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-我不完全确定是否需要执行此步骤(对于我的特定应用程序不做任何更改),但是我在网上阅读的有关使Play应用程序在WebSphere中运行的所有建议都说可以做到这一点.嗯,不会痛的.单击已安装的应用程序.单击类加载和更新检测"链接.然后选择首先使用本地类加载器加载的类(最后使用父类加载)"选项.好的.保存.

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-打开一个浏览器页面到您的地址(如果在本地运行Websphere,则为localhost:9080),然后进行测试.在这一点上,它应该可以工作!希望.祝你好运.

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.

这篇关于如何将Play应用部署到Websphere 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆