Playframework + Tomcat 部署问题 [英] Playframework + Tomcat Deployment issue

查看:27
本文介绍了Playframework + Tomcat 部署问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Tomcat 中部署在 play 框架中开发的 Web 应用程序.前几次尝试,在Tomcat控制台得到如下信息,

I am trying to deploy a web app developed in play framework in Tomcat. The first few times I tried, I got the following message in the Tomcat console,

INFO: validateJarFile(C:Tomcat7webappssandbox.warWEB-INFlibgeronimo-servlet_2.5_spec-1.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

所以我从 play war 文件中手动删除了 geronimo-servlet_2.5_spec-1.2.jar.完成后,我会看到以下成功消息,

So I manually removed the geronimo-servlet_2.5_spec-1.2.jar from the play war file. And once that is done, I see the following success message,

13:56:43,571 INFO  ~ Starting C:Tomcat7webappssandbox.warWEB-INFapplication

13:56:43,618 INFO  ~ Application is precompiled
13:56:44,149 INFO  ~ Connected to jdbc:mysql://localhost/db?useUnicode=yes&ch   aracterEncoding=UTF-8&connectionCollation=utf8_general_ci
13:56:44,899 INFO  ~ Application 'play-sandbox' is now started !

当我尝试使用 url 从 IE 访问应用程序时 http://localhost:8080/play-sandbox 我收到一个 404,提示请求的资源 (/play-sandbox/) 不可用".

When I try to access the application from IE using the url http://localhost:8080/play-sandbox I am getting a 404 that says "The requested resource (/play-sandbox/) is not available".

我在 Tomcat 7 中运行它并且 tomcat 日志很清楚.我用

I am running this in Tomcat 7 and the tomcat logs are clear. I use

 play war play-sandbox -o sandbox.war

发动战争

问题是,

  1. 如何防止 geronimo-servlet_2.5_spec-1.2.jar 冲突?
  2. 为什么我在 Tomcat 部署中无法通过浏览器查看应用程序?play run {app name} 一切正常.

  1. How do I prevent the geronimo-servlet_2.5_spec-1.2.jar conflict?
  2. Why am I unable to view the app via browser in Tomcat deployment? Where as play run {app name} works all fine.

同样的 war 文件在 glassfish 服务器中似乎也能正常工作.我相信这与 playframework 应用程序的上下文路径或应用程序的隔离有关.任何帮助将不胜感激.

The same war file seems working perfectly fine in glassfish server as well. I believe this has something to do with the context path of the playframework application or isolation of the application. Any help would be appreciated.

谢谢,阿比

推荐答案

您是否尝试过较早版本的 Tomact?根据部署矩阵,Play 并未正式"支持 Tomact 7,因此这可能是问题的一部分.请参阅此处http://www.playframework.org/documentation/1.2.1/deployment

Have you tried an earlier version of Tomact? According to the deployment matrix, Play does not 'officially' support Tomact 7, so that may be part of the problem. See here http://www.playframework.org/documentation/1.2.1/deployment

至于为什么应用程序在您执行 play run appname 时工作而不是通过 tomcat 部署时,是因为部署完全不同.Play 不是 Java EE 兼容框架.它选择不走 Servlet 规范路线,因为它觉得太复杂、臃肿并且限制了他们想要使用 Play 的地方.这就是为什么您没有 Session 和其他 Java EE 核心功能之类的东西.

As for why the application works when you do play run appname and not when you deploy through tomcat, is that the deploment is completely different. Play is not a Java EE compliant framework. It chose not to go down the Servlet spec route, as it felt it was too complicated, bloated and restricted where they wanted to take Play. This is why you don't have things like the Session and other Java EE core functions.

因此,要让 Play 在 Servlet 容器中工作,需要将 Play 应用程序包装在一个包装器中,该包装器将应用程序公开为符合 Servlet 的应用程序,并将其全部移动到一个 WAR 文件中.但是,您确实会失去标准 Play 应用程序的某些功能.

Therefore, to get Play to work in a Servlet container, it is required to wrap the Play application in a wrapper that exposes the application as a Servlet compliant application, and move it all into a WAR file. You do however lose some of the features of a standard Play application.

Play 开发人员和我就此而言,建议始终使用 Play 应用程序服务器来充分利用您的应用程序并尽可能简化部署!

The Play Devs, and I for that matter, would recommend always using the Play application server to get the most out of your application and to ease the deployment, if possible!

这篇关于Playframework + Tomcat 部署问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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