How to schedule task daily + onStart() in Play 2.0.4?

Scheduler tasks should be placed only in Global class. Create two tasks, schedule only once first with initialDelay = 0 milliseconds. For the second task, you need to calculate seconds between current DateTime and next planned occurrence (ie. tomorrow at 8:00 o’clock) using common date/time classes, then set this difference as initialDelay and also set … Read more

How do I run a Play Framework 2.0 application as a Windows service?

This worked for me on Windows 7: Create folder C:\my_app Go to your Play! app folder in command line and type play dist Copy generated “something-SNAPSHOT” folder to C:\my_app Download YAJSW and extract to C:\my_app In C:\my_app\something-SNAPSHOT\ make a new file start.bat and fill it with command like this: java -cp “C:\my_app\something-SNAPSHOT\lib\*” play.core.server.NettyServer Save it … Read more

How to write JUnit test with Spring Autowire?

Make sure you have imported the correct package. If I remeber correctly there are two different packages for Autowiring. Should be :org.springframework.beans.factory.annotation.Autowired; Also this looks wierd to me : @ContextConfiguration(“classpath*:conf/components.xml”) Here is an example that works fine for me : @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { “/applicationContext_mock.xml” }) public class OwnerIntegrationTest { @Autowired OwnerService ownerService; @Before public … Read more

scala slick method I can not understand so far

[UPDATE] – added (yet another) explanation on for comprehensions The * method: This returns the default projection – which is how you describe: ‘all the columns (or computed values) I am usually interested’ in. Your table could have several fields; you only need a subset for your default projection. The default projection must match the … Read more

Play 2.x: How to make an AJAX request with a common button

For this job you should go with javascriptRoutes as it generates correct JS paths based on your routes.conf. You’ll find usage sample in Zentask sample Anyway, for now you can fix your AJAX call by changing the url to url : ‘@routes.Application.saveDefaultPhoneForUser()’, This way requires it to place the whole JS in template, which is … Read more

How do I change the default port (9000) that Play uses when I execute the “run” command?

Play 2.x In Play 2, these are implemented with an sbt plugin, so the following instructions are really just sbt tasks. You can use any sbt runner (e In Play 2, these are implemented with an sbt plugin, so the following are really just sbt tasks. You can use any sbt runner (e.g. sbt, play, … Read more

NoSuchMethodError in javax.persistence.Table.indexes()[Ljavax/persistence/Index

I’ve ran into the same problem. The question here is that play-java-jpa artifact (javaJpa key in the build.sbt file) depends on a different version of the spec (version 2.0 -> “org.hibernate.javax.persistence” % “hibernate-jpa-2.0-api” % “1.0.1.Final”). When you added hibernate-entitymanager 4.3 this brought the newer spec (2.1) and a different factory provider for the entitymanager. Basically … Read more