WAR exporting

856 views
Skip to first unread message

Vincent RISCHMANN

unread,
May 26, 2009, 12:40:57 PM5/26/09
to play-framework
Hi,

I am a little confused with the war exporting: when I export my application,
it creates a directory with the war structure in it, but I expected Play! to
create a .war file (I'd like to deploy my application easily on another
machine via the GlassFish administration interface).

I am not very familiar with the WAR file format, but can I just zip the
directory and rename it to something.war ?

Alberto Gimeno

unread,
May 26, 2009, 12:54:52 PM5/26/09
to play-fr...@googlegroups.com
I think you can just make a file named <something>.war with your
favourite ZIP compressor (for example the jar application in the java
SDK).
--
Alberto Gimeno Brieba
email y gtalk: gime...@gmail.com
blog: http://gimenete.net
web favorita: http://www.debugmodeon.com
teléfono móvil: +34 625 24 64 81

Vincent RISCHMANN

unread,
May 26, 2009, 1:11:59 PM5/26/09
to play-fr...@googlegroups.com
Le mardi 26 mai 2009 18:54:52, Alberto Gimeno a écrit :
> I think you can just make a file named <something>.war with your
> favourite ZIP compressor (for example the jar application in the java
> SDK).
>
> On Tue, May 26, 2009 at 6:40 PM, Vincent RISCHMANN
>
> <zecme...@gmail.com> wrote:
> > Hi,
> >
> > I am a little confused with the war exporting: when I export my
> > application, it creates a directory with the war structure in it, but I
> > expected Play! to create a .war file (I'd like to deploy my application
> > easily on another machine via the GlassFish administration interface).
> >
> > I am not very familiar with the WAR file format, but can I just zip the
> > directory and rename it to something.war ?
Yes, that worked, thanks.

Now deploying in GlassFish doesn't work, I am getting this exception:

2009-05-26T19:06:10.910+0200|SEVERE|sun-appserver2.1|
javax.enterprise.system.tools.deployment|
_ThreadID=20;_ThreadName=Thread-278;_RequestID=aa5cebe2-6d88-4f81-
a584-5fe794b197e9;|Une exception s''est produite dans la phase
J2EEC.org.xml.sax.SAXParseException: TargetNamespace.1: Expecting namespace
'http://java.sun.com/xml/ns/javaee', but the target namespace of the schema
document is 'http://java.sun.com/xml/ns/j2ee'.
com.sun.enterprise.deployment.backend.IASDeploymentException: Erreur lors du
chargement des descripteurs de déploiement pour le module [missionTracking]
ligne 8 colonne 20 -- Fichier de descripteur de déploiement WEB-INF/web.xml
dans l'archive [missionTracking]. TargetNamespace.1: Expecting namespace
'http://java.sun.com/xml/ns/javaee', but the target namespace of the schema
document is 'http://java.sun.com/xml/ns/j2ee'.

I looked in the web.xml file, and the namespace is correct.

Guillaume Bort

unread,
May 26, 2009, 3:48:45 PM5/26/09
to play-fr...@googlegroups.com, play-fr...@googlegroups.com
Yes, a war is just a zip

I will add a --zip option to the war command to do it automatically if
wanted.

Guillaume Bort

unread,
May 26, 2009, 3:55:41 PM5/26/09
to play-fr...@googlegroups.com
Are you sure you have correctly zipped the WAR ? You must zip the
content of the WAR directory, not the WAR directory itself.

On Tue, May 26, 2009 at 7:11 PM, Vincent RISCHMANN

Guillaume Bort

unread,
May 26, 2009, 4:02:50 PM5/26/09
to play-fr...@googlegroups.com
Otherwise, try to replace :

http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd

by

http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd

in the web.xml file.

I'm not sure which is correct ??? It works with tomcat and jetty but
perhaps it is wrong.

Vincent RISCHMANN

unread,
May 26, 2009, 4:22:17 PM5/26/09
to play-fr...@googlegroups.com
Actually I just changed wep-app_2_4.xsd to wep-app_2_5.xsd and the version to 2.5 too. If you try to go to http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd in your browser you'll see the page doesn't exist.
Now it deploys ok on Glassfish, but the application doesn't work. I encountered problems with routes, because I deployed the war on a context like /myApp.
I tested with /myApp at the beginning of my routes, now the routes worked, but I had problems with the templates tags/500.html, tags/404.html which couldn't be found.

Looking at this, and the way it is explained in the release notes (exported directly in the ROOT directory of tomcat/webapps), I wonder if it is even possible to deploy an exported war somewhere else than the root context ?

Vincent RISCHMANN

unread,
May 26, 2009, 4:45:05 PM5/26/09
to play-fr...@googlegroups.com
Le mardi 26 mai 2009 22:02:50, Guillaume Bort a écrit :
> Another problem, not related to GlassFish this time, but I tried to export my
application in a tomcat6 with this command: "play war -o
/srv/tomcat/webapps/ROOT "
and when I try to launch the application, I get this in my catalina.log:

play 2009-05-26 22:25:09,676 -- INFO --
play 2009-05-26 22:25:09,678 -- INFO -- Starting /srv/tomcat/webapps/ROOT/WEB-
INF/application
Exception in thread "http-8080-1" java.lang.ClassCircularityError:
java/util/logging/LogRecord
at play.Logger$JuliToLog4jHandler.publish(Logger.java:410)
at java.util.logging.Logger.log(Logger.java:458)
at java.util.logging.Logger.doLog(Logger.java:480)
at java.util.logging.Logger.logp(Logger.java:680)
at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:167)
at org.apache.juli.logging.DirectJDKLog.error(DirectJDKLog.java:135)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:604)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)

Guillaume Bort

unread,
May 26, 2009, 4:52:25 PM5/26/09
to play-fr...@googlegroups.com
Yes, currently it only works on ROOT context.
It is on my TODO list to add context support.


On Tue, May 26, 2009 at 10:22 PM, Vincent RISCHMANN

Guillaume Bort

unread,
May 26, 2009, 4:55:22 PM5/26/09
to play-fr...@googlegroups.com
Which version of tomcat exactly ? Just tried with the 6.0.18 and don't
have this problem.

On Tue, May 26, 2009 at 10:45 PM, Vincent RISCHMANN

Vincent RISCHMANN

unread,
May 26, 2009, 4:58:12 PM5/26/09
to play-fr...@googlegroups.com
Ok, then I'll wait for this feature :)
Thanks for the help :)

zecme...@gmail.com

unread,
May 26, 2009, 5:03:55 PM5/26/09
to play-framework
Same here, 6.0.18. I tried with both Sun's JDK 1.6.0_13 and openjdk6
but it doesn't change anything.

On 26 mai, 22:55, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Which version of tomcat exactly ? Just tried with the 6.0.18 and don't
> have this problem.
>
> On Tue, May 26, 2009 at 10:45 PM, Vincent RISCHMANN
>
> <zecmerqu...@gmail.com> wrote:
>
> > Le mardi 26 mai 2009 22:02:50, Guillaume Bort a écrit :
> >> Otherwise, try to replace :
>
> >>http://java.sun.com/xml/ns/javaee
> >>http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd
>
> >> by
>
> >>http://java.sun.com/xml/ns/j2ee
> >>http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd
>
> >> in the web.xml file.
>
> >> I'm not sure which is correct ??? It works with tomcat and jetty but
> >> perhaps it is wrong.
>
> >> On Tue, May 26, 2009 at 9:55 PM, Guillaume Bort
>
> >> <guillaume.b...@gmail.com> wrote:
> >> > Are you sure you have correctly zipped the WAR ? You must zip the
> >> > content of the WAR directory, not the WAR directory itself.
>
> >> > On Tue, May 26, 2009 at 7:11 PM, Vincent RISCHMANN
>
> >> > <zecmerqu...@gmail.com> wrote:
> >> >> Le mardi 26 mai 2009 18:54:52, Alberto Gimeno a écrit :
> >> >>> I think you can just make a file named <something>.war with your
> >> >>> favourite ZIP compressor (for example the jar application in the java
> >> >>> SDK).
>
> >> >>> On Tue, May 26, 2009 at 6:40 PM, Vincent RISCHMANN
>

Guillaume Bort

unread,
May 27, 2009, 7:05:22 AM5/27/09
to play-fr...@googlegroups.com
Well,

If you try the revision 419, it should fix these problems.

First it doesn't try anymore to redirect the java.util.logging out to
play.Logger, so I think the class circularity exception
should be gone (I'm not sure thus, because I was not able to reproduce
the problem myself).

The namespace for the web.xml file are corrected (the old ones was
effectively wrong).

A new --zip option to the 'war' command allows to create a zipped
version of the war archive
# play war myApp -o ROOT --zip

And some simple fixes should allow to work on any context; BUT
URL are importants things for Play and all the URL mapping is managed
by the conf/routes file.
That mean that if you want to deploy your application on the /myapp
context, you must declare correct routes, like :

GET /myapp/ Application.index
* /myapp/admin module:crud
GET /myapp/public/ staticDir:/public

Now what if you want to deploy the same application on 2 differents
contexts, are want that the context path is a configuration ?
As the routes file is evaluated with the Play template system, you can
make it dynamic in this way :

%{ ctx = play.configuration.getProperty('context', '') }%

GET ${ctx}/myapp/ Application.index
* ${ctx}/myapp/admin module:crud
GET ${ctx}/myapp/public/ staticDir:/public

And take care to always use the reverse routing mechanism in your templates :

@{Application.index()}, instead of / and @{'/public/images/logo.png'}
instead of /public/images/logo.png ...

Can you please test it, and let me know if you still have problems ?

Thanks !

Guillaume;

Vincent RISCHMANN

unread,
May 27, 2009, 3:27:34 PM5/27/09
to play-fr...@googlegroups.com
Ok, I tried rev 419:
- the logger exception is gone
- deploying on tomcat works, both on root context AND on a special context
with your tips
- deploying on glassfish works, however the application does'nt work.
I get this exception:

play.exceptions.TemplateNotFoundException: Template not found : tags/500.html
or tags/500.tag
at play.templates.Template$ExecutableTemplate.invokeTag(Template.java:324)
at /app/views/errors/500.html.(line:9)
at play.templates.FastTags._if(FastTags.java:78)
at play.templates.FastTags$_if.call(Unknown Source)
at /app/views/errors/500.html.(line:8)
at play.templates.Template.render(Template.java:202)
at play.server.ServletWrapper.serve500(ServletWrapper.java:248)
at play.server.ServletWrapper$ServletInvocation.doIt(ServletWrapper.java:333)
at play.Invoker.invokeInThread(Invoker.java:44)
at play.server.ServletWrapper.service(ServletWrapper.java:82)

It may have something to do with file permissions, but I gave a 777 chmod to
these files...

Anyway, thanks for your help, now I am able to deploy several applications on
one tomcat instance :)

Just one thing though, the exported war is HUGE (like 60mb for my little
application), I think it is because of all the jars exported too, it would be
nice to just export the used ones.

Guillaume Bort

unread,
May 27, 2009, 4:59:23 PM5/27/09
to play-fr...@googlegroups.com
Do you know if glassfish explode the WAR file ? Or does it try to work
with the plai zipped file ?
Play can't work if the war is not exploded ...

Vincent RISCHMANN

unread,
May 27, 2009, 5:37:13 PM5/27/09
to play-fr...@googlegroups.com
The war is unzipped in a directory, keeping the same structure.
Ok, I found the problem: it seems glassfish doesn't look in anything outside
the application directory.
I just copied the tags/ and errors/ directories in application/, and it
worked.

But now, I have an SQL exception:

play.exceptions.JavaExecutionException:
Internal Exception: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost:3306/acrobatt

I think the classpath is not set correctly, is there a way to know the
classpath Play is using ?

Guillaume Bort

unread,
May 28, 2009, 3:40:34 AM5/28/09
to play-fr...@googlegroups.com
In the WAR file, the classpath construction is pretty simple : just
all the *.jar from the WEB-INF/lib. (application/lib/*, and
modules/xxx/lib* are ignored).
The framework should try to locate the play.jar file, and then
construct paths from this root (to find the default templates
directory, etc ..).

So is the mysql driver present is WEB-INF/lib ?

On Wed, May 27, 2009 at 11:37 PM, Vincent RISCHMANN

Vincent RISCHMANN

unread,
May 28, 2009, 7:44:48 AM5/28/09
to play-fr...@googlegroups.com
Yes, the mysql-connector.jar is in WEB-INF/lib

Guillaume Bort

unread,
May 28, 2009, 7:49:35 AM5/28/09
to play-fr...@googlegroups.com
Ok. So I think that the ClassLoader system for Glassfish is pretty
different ...
I will take the time to install glassfish to see what happend.

Thanks.

On Thu, May 28, 2009 at 1:44 PM, Vincent RISCHMANN

ni_lus

unread,
Jun 26, 2009, 4:08:52 AM6/26/09
to play-framework
Hi,

I'm trying the following codes on routes file so I can deploy my war
on our servlet container,

%{ ctx = play.configuration.getProperty('context', '') }%

But it the context path does not get prepended on the links generated
or when I action chain methods..


For example ,

public class Session extends Controller {
public static void index(String app, String user, String hash){
if(StringUtils.isEmpty(app) && StringUtils.isEmpty(user)){
login(null, null, null);
}else{
checkHash(app, user, hash);
}
}
public static void login(String name, String pass, String submit){
if(submit != null){
// some code here to check name and pass
}else{
render(); // render Session/login.html for
username/password inputs
}
}

and routes file

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

* ${ctx}/ Session.index
* ${ctx}/login Session.login


So what happens is:
1. user access "http://localhost:8000/approvers", approvers here is
the context path
2. based on above code, it Session.index forwards to Session.login.
3. but on the browser, it gets forwarded to "http://localhost:8000/
login", therefore not adding the context path.

I have also tried accessing "http://localhost:8000/approvers/login".
It reaches the login page but if I check the source I only get the
following

<form action="/login" ...> instead of <form action="/approvers/
login" ...>

on Session\login.html I used

<form action="@{Session.login}" ....>


Is this a bug?
> On Tue, May 26, 2009 at 11:03 PM, zecmerqu...@gmail.com

Guillaume Bort

unread,
Jun 26, 2009, 4:23:43 AM6/26/09
to play-fr...@googlegroups.com
It should just work with a recent version.

Which play version do you use ?
What have you set in the context configuration property ? '/approvers'
or 'approvers'

Guillaume.

ni_lus

unread,
Jun 26, 2009, 5:38:35 AM6/26/09
to play-framework
Ok, I'm using 1.0 stable6 (not the nightly build). I'll download the
latest nightly build later and try.



Thanks.




On Jun 26, 4:23 pm, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> It should just work with a recent version.
>
> Which play version do you use ?
> What have you set in the context configuration property ? '/approvers'
> or 'approvers'
>
> Guillaume.
>
> >> # playwarmyApp -o ROOT --zip
> >> >> >> > Are you sure you have correctly zipped theWAR? You must zip the
> >> >> >> > content of theWARdirectory, not theWARdirectory itself.
>
> >> >> >> > On Tue, May 26, 2009 at 7:11 PM, Vincent RISCHMANN
>
> >> >> >> > <zecmerqu...@gmail.com> wrote:
> >> >> >> >> Le mardi 26 mai 2009 18:54:52, Alberto Gimeno a écrit :
> >> >> >> >>> I think you can just make a file named <something>.warwith your
> >> >> >> >>> favourite ZIP compressor (for example the jar application in the java
> >> >> >> >>> SDK).
>
> >> >> >> >>> On Tue, May 26, 2009 at 6:40 PM, Vincent RISCHMANN
>
> >> >> >> >>> <zecmerqu...@gmail.com> wrote:
> >> >> >> >>> > Hi,
>
> >> >> >> >>> > I am a little confused with thewarexporting: when I export my
> >> >> >> >>> > application, it creates a directory with thewarstructure in it, but
> >> >> >> >>> > I expected Play! to create a .warfile (I'd like to deploy my
> >> >> >> >>> > application easily on another machine via the GlassFish
> >> >> >> >>> > administration interface).
>
> >> >> >> >>> > I am not very familiar with theWARfile format, but can I just zip

ni_lus

unread,
Jun 28, 2009, 11:15:44 PM6/28/09
to play-framework
Ok I have downloaded stable 457. I still can't get it to work. I did
the flolowing:
1. play new test
2. play war test -o testw --zip
3. I deployed testw.war on Apache tomcat 6.
4. I modified the routes file:

# Set context name
%{ ctx = play.configuration.getProperty('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}

5. I reloaded context and tried to access 'http://localhost:18085/
test/'

Then error occurs saying 'Caused by: java.lang.NoClassDefFoundError:
net/sf/ehcache/CacheManager'
So I downloaded ehcache 1.6 jar, added it to the libs folder under
'\webapps\test\web-inf\lib' and reloaded the context.

Now I get the following and it seems play did not resolved the context
path:


Not found

GET /test/
These routes have been tried, in this order :

1. GET /
Application.index
2. GET /public/
staticDir:public
3. * /{controller}/{action}
{controller}.{action}





On Jun 26, 4:23 pm, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> It should just work with a recent version.
>
> Which play version do you use ?
> What have you set in the context configuration property ? '/approvers'
> or 'approvers'
>
> Guillaume.
>
> >> # playwarmyApp -o ROOT --zip
> >> >> >> > Are you sure you have correctly zipped theWAR? You must zip the
> >> >> >> > content of theWARdirectory, not theWARdirectory itself.
>
> >> >> >> > On Tue, May 26, 2009 at 7:11 PM, Vincent RISCHMANN
>
> >> >> >> > <zecmerqu...@gmail.com> wrote:
> >> >> >> >> Le mardi 26 mai 2009 18:54:52, Alberto Gimeno a écrit :
> >> >> >> >>> I think you can just make a file named <something>.warwith your
> >> >> >> >>> favourite ZIP compressor (for example the jar application in the java
> >> >> >> >>> SDK).
>
> >> >> >> >>> On Tue, May 26, 2009 at 6:40 PM, Vincent RISCHMANN
>
> >> >> >> >>> <zecmerqu...@gmail.com> wrote:
> >> >> >> >>> > Hi,
>
> >> >> >> >>> > I am a little confused with thewarexporting: when I export my
> >> >> >> >>> > application, it creates a directory with thewarstructure in it, but
> >> >> >> >>> > I expected Play! to create a .warfile (I'd like to deploy my
> >> >> >> >>> > application easily on another machine via the GlassFish
> >> >> >> >>> > administration interface).
>
> >> >> >> >>> > I am not very familiar with theWARfile format, but can I just zip

ni_lus

unread,
Jun 29, 2009, 12:45:44 AM6/29/09
to play-framework
Ok. I got it now.. i was so dumb, i never placed context=/test into
'conf/application.conf' file. It's working now.

But my question is, why not use 'application.getContextPath()' and
placed into the 'context' configuration property? I guess it
complicates things. Anyway thanks for the help..



On Jun 26, 4:23 pm, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> It should just work with a recent version.
>
> Which play version do you use ?
> What have you set in the context configuration property ? '/approvers'
> or 'approvers'
>
> Guillaume.
>
> >> # playwarmyApp -o ROOT --zip
> >> >> >> > Are you sure you have correctly zipped theWAR? You must zip the
> >> >> >> > content of theWARdirectory, not theWARdirectory itself.
>
> >> >> >> > On Tue, May 26, 2009 at 7:11 PM, Vincent RISCHMANN
>
> >> >> >> > <zecmerqu...@gmail.com> wrote:
> >> >> >> >> Le mardi 26 mai 2009 18:54:52, Alberto Gimeno a écrit :
> >> >> >> >>> I think you can just make a file named <something>.warwith your
> >> >> >> >>> favourite ZIP compressor (for example the jar application in the java
> >> >> >> >>> SDK).
>
> >> >> >> >>> On Tue, May 26, 2009 at 6:40 PM, Vincent RISCHMANN
>
> >> >> >> >>> <zecmerqu...@gmail.com> wrote:
> >> >> >> >>> > Hi,
>
> >> >> >> >>> > I am a little confused with thewarexporting: when I export my
> >> >> >> >>> > application, it creates a directory with thewarstructure in it, but
> >> >> >> >>> > I expected Play! to create a .warfile (I'd like to deploy my
> >> >> >> >>> > application easily on another machine via the GlassFish
> >> >> >> >>> > administration interface).
>
> >> >> >> >>> > I am not very familiar with theWARfile format, but can I just zip

Guillaume Bort

unread,
Jun 29, 2009, 4:48:40 AM6/29/09
to play-fr...@googlegroups.com
Yep it could be nice to automatically set the context path.
Can you post a bug request about that ?

Thank you.

ni_lus

unread,
Jun 29, 2009, 10:15:50 PM6/29/09
to play-framework
Bug report added.. Thanks..

On Jun 29, 4:48 pm, Guillaume Bort <guillaume.b...@gmail.com> wrote:
> Yep it could be nice to automatically set the context path.
> Can you post a bug request about that ?
>
> Thank you.
>
> ...
>
> read more »
Reply all
Reply to author
Forward
0 new messages