2

how to use "war.context" in Configuration file of Play Framework ?

SBerg413
  • 14,046
  • 6
  • 55
  • 87
Tiny Gipxy
  • 121
  • 1
  • 6

1 Answers1

4

Take a look at this thread on the Google Groups for a description of what you are asking.

http://groups.google.com/group/play-framework/browse_thread/thread/b4783c821fd29898?pli=1

In essence, what it is saying, is.

In your application.conf file, you set a property such as

war.context=/MyAppName

Then, in your routes file, you set it up to include your WAR context in the following way

# Set context name 
%{ ctx = play.configuration.getProperty('war.context', '') }% 

# Routes 
# This file defines all application routes (Higher priority routes first) 
# ~~~~ 
# Home page 
GET     ${ctx}/                                      Application.index 
# Map static resources from the /app/public folder to the /public path 
GET     ${ctx}/public/                               staticDir:public 
# Catch all 
*       ${ctx}/{controller}/{action}                 {controller}.{action} 

You can see therefore, whatever you place in your war.context, you can then put into your routes to pick up the correct path.

Codemwnci
  • 51,224
  • 10
  • 90
  • 127
  • Are you sure that this is the recommended way with play 1.1? – niels Dec 05 '10 at 15:19
  • There was a ticket raised on lighthouse (and this has only been in place since 1.1), which Guillaume pointed to the above thread as the answer to the question. – Codemwnci Dec 05 '10 at 15:46
  • i tryed it and i got empty page tomcat 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 – green-creeper Jun 01 '11 at 08:40
  • From your logs you can see it is actually deploying to ROOT context. You also need to specify in Tomcat's server.xml that the context is different if you don't use Play's own built-in server. – Stijn de Witt May 14 '13 at 10:02