Using antify to run your Play application with ant

Since the version 1.2.2 of Play the antify module has been part of the framework.

Here is how you can run your Play application with ant:

  1. Generate the build.xml file
    /home/huljas/test-app>play antify
    ~        _            _
    ~  _ __ | | __ _ _  _| |
    ~ | '_ \| |/ _' | || |_|
    ~ |  __/|_|\____|\__ (_)
    ~ |_|            |__/
    ~ play! 1.2.2,
    ~ OK, a build.xml file has been created
    ~ Define the PLAY_PATH env property, and use it with ant run|start|stop
  2. Set the PLAY_PATH environment variable
    /home/huljas/testapp>export PLAY_PATH=/usr/local/play-1.2.2
    /home/huljas/testapp>echo $PLAY_PATH
  3. Now you can run your application with ant!

    Check the main targets:
    /home/huljas/testapp>ant -p
    Buildfile: /home/huljas/testapp/build.xml
    Main targets:
     auto-test   Automatically run all application tests
     precompile  Compile all java sources and templates
     run         Runs the application
     start       Starts the application as a daemon
     stop        Stop the application daemon
     test        Run the application in test mode

    Run you application

    /home/huljas/testapp>ant run
    Buildfile: /home/huljas/testapp/build.xml
        [java] Listening for transport dt_socket at address: 8000
        [java] 23:06:22,366 INFO  ~ Starting /home/huljas/testapp
        [java] 23:06:22,806 WARN  ~ You're running Play! in DEV mode
        [java] 23:06:22,876 INFO  ~ Listening for HTTP on port 9000
    (Waiting a first request to start) ...

IE Unable to modify the parent container OR 800a03e8 error

Recently I encountered the following error with IE which left me puzzled and the page unfinished:

Message: HTML Parsing Error: Unable to modify the parent container element 
before the child element is closed (KB927917)
Line: 0
Char: 0
Code: 0

With the Javascript debugger I found a different message:

Could not complete the operation due to error 800a03e8

And what was even more weird was that the page worked fine not only with FF and Chrome but also with IE7 and IE9 and most versions of IE8 too! There were only TWO computers with IE8 in the office where we were able to reproduce the problem.

So after some digging (This took a while because that particular line was a 3rd party Javascript using document.write() so I couldn't modify it NOR wrap it inside a ready handler) I was able to conclude that the line where the debugger caught the error was not the cause of the error.

With that information I was able to trace the problem to another Javascript, which was missing the ready handlers. When I wrapped the code inside $(function() { ... }); the problem was solved.

Lesson learned? Always use the jQuery ready handler, it can save you a lot of trouble!

Useful formats for Java Formatter

Some examples of using String.format(..) which are documented in a kinda complicated manner in the docs.