播放框架+ tomcat [英] Play Framework + tomcat
问题描述
我需要在tomcat上运行play框架应用程序. 我刚做了
I need to run the play framework application on tomcat. i just made
./play war ganshla-ganshla -o ROOT.war --%production
然后我添加了META-INF文件夹(因为我尝试了一下却得到了404) 我将context.xml放入META_INF
then i add META-INF folder (because i tryed whithout it and got 404) i put context.xml into META_INF
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/ROOT"/>
所以现在页面上有错误:
So now i have an error on the page:
找不到Application.index操作
Application.index action not found
在服务器日志中,我有:
in the server log i have:
play.exceptions.ActionNotFoundException: Action Application.index not found
at play.mvc.ActionInvoker.getActionMethod(ActionInvoker.java:582)
at play.mvc.ActionInvoker.resolve(ActionInvoker.java:84)
at play.server.ServletWrapper$ServletInvocation.getInvocationContext(ServletWrapper.java:540)
at play.Invoker$Invocation.init(Invoker.java:193)
at play.Invoker$DirectInvocation.init(Invoker.java:292)
at play.server.ServletWrapper$ServletInvocation.init(ServletWrapper.java:508)
at play.Invoker$Invocation.run(Invoker.java:263)
at play.server.ServletWrapper$ServletInvocation.run(ServletWrapper.java:525)
at play.Invoker.invokeInThread(Invoker.java:67)
at play.server.ServletWrapper.service(ServletWrapper.java:126)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.Exception: Controller controllers.Application not found
... 23 more
04:07:37,225 WARN ~ 404 -> GET / (Application.index action not found)
更新:
试图按照此处的说明进行操作如何使用"war.context"在Play Framework的配置文件中?,现在我有一个空白页,并且此条目在日志中
tryed to make as discribed here how to use "war.context" in Configuration file of Play Framework ? and now i have empty page and this entry in log
INFO: Deploying web application archive ROOT.war
Jun 1, 2011 4:33:29 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ganshla2/jvm/apache-tomcat-6.0.14/domains/ganshla-ganshla.com/ROOT/WEB-INF/lib/geronimo-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
04:33:36,470 INFO ~ Starting /home/ganshla2/jvm/apache-tomcat-6.0.14/domains/ganshla-ganshla.com/ROOT/WEB-INF/application
04:33:37,265 INFO ~ Application is precompiled
推荐答案
我不确定您是否需要担心Play上下文,因为您正在以ROOT身份运行应用程序.我在自己的一个应用程序上进行了尝试,它似乎运行良好,但是我使用的部署选项略有不同.
I am not sure that you need to worry about the Play context, as you are running your application as the ROOT. I tried this myself on one of my applications and it seemed to work fine, however the deployment options I used was slightly different.
我采取的步骤是
play new wartest
然后我编辑了index.html
,以显示已部署了真实"的东西.因此,我在下面添加了几行代码.
I then edited the index.html
to show that something 'real' was getting deployed. So I just added a few lines of code, below.
#{extends 'main.html' /}
#{set title:'Home' /}
Welcome to my first tomcat-play application.
最后,我创建了要部署的文件.
Finally I created the file to deploy.
play war wartest -o ROOT
这将创建一个分解的WAR文件,并允许我将其简单地拖放到Tomtact Webapps目录中.
This creates an exploded WAR file, and allows me to simply drop it into the Tomtact Webapps directory.
我不需要使用上下文或META-INF.只是为了查看它是否有效,这是一个简单的测试,但是由于您的应用程序甚至没有显示索引页面,因此我怀疑您是否达到了我的简单测试所能达到的程度.
I did not need to use context, or META-INF. This was a simple test just to see it working, but as your app is not even showing the index page, I doubt you are even getting as far as my simple test has.
我使用
- Tomcat 7
- Java 6
- 和Windows 7.
我怀疑您的问题出在您的ROOT.war文件的命名上.
I suspect that your issue is with the naming of your ROOT.war file.
这篇关于播放框架+ tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!