FAQ Database Discussion Community


Use save() method in Play! with inheritance (JPA)

java,jpa,playframework,playframework-2.2,playframework-2.3
I have my super abstract class : @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class User { @Id public int id; public String name; } And two other classes extends User: Customer @Entity @Table(name = "customers") public class Customer extends User{ @Id public int id; public String role; public Customer(String role){...

bindFromRequest and asFormUrlEncoded return different values

forms,scala,playframework,playframework-2.3
I have a form where a field name is the same as one of the method/url parameters on the submit, say someInt. I.e. my form has @(dummyForm:Form[Dummy], someInt:Int) and dummyForm has a field "someInt" -> number and the controller is defined as def submit(someInt:Int) =.... Sample code here. Let's say...

Make DB calls through different models atomic

scala,playframework,playframework-2.3,anorm
Let's say that there are two models, Model1 and Model2, each model has a set of basic methods that call DB to retrieve or write data. For one Model1 there can exist multiple Model2, when inserting a (Model1, List[Model2]) all this data comes from the same form. The current implementation...

Getting JPA to generate tables with specified row format

java,mysql,hibernate,jpa,playframework-2.3
I am using play 2 framework with JPA hibernate. My goal is to get JPA to generate tables on a fresh database using specific ROW_FORMAT: This is what JPA executes on start: create table Admin ( .. ) ENGINE=InnoDB And this is what I want: create table Admin ( .....

How to reference to the standard ActorSystem of play framework 2?

scala,playframework,akka,playframework-2.3
I wish to use the scheduler of akka, the examples are saying: system.scheduler.scheduleOnce() but there is no real information where the "system" should come from. The documentation is a little bit superficial and there was a lot of change (akka moved out of core scala). If I write val system...

Scala Play no application started when grabbing data sources from application.conf

scala,playframework,playframework-2.0,playframework-2.3
I am trying to read in data sources from my application.conf file, but every time I run my server, or try and run test cases, I am getting an error saying that there is no application started. Here is an example of what I am trying to do: Unit test...

Play framwork Host repo.typesafe.com not found

sbt,playframework-2.3,typesafe-activator
Environment: Play framework; activator-1.3.2; Play-Java Web Application build.sbt - name := """ProjectDemoNew""" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayJava) scalaVersion := "2.11.1" resolvers +="Local Maven Repository" at "file:///home/shiva/.m2/repository" libraryDependencies ++= Seq( javaJdbc, javaEbean, cache, javaWs, "org.springframework" % "spring-context" % "3.2.3.RELEASE", "org.springframework" % "spring-aop" % "3.2.3.RELEASE", "org.springframework" %...

Redirect to .scala.html file (Scala Play) only shows plain text

javascript,ajax,scala,playframework,playframework-2.3
I just implemented the Google OAuth hybrid server side flow which requires an AJAX call for retrieving an access token. After I did the AJAX call (stored the token etc.) I would like the server to display some content using a file called home.scala.html. //called when client has confirmed the...

Playframework with Deadbolt 2: Pattern regular expression not match

regex,scala,playframework-2.3,deadbolt-2
I am using Deadbolt2 with play-framework 2.3.x. When I am trying to access the controller with declare deadbolt Patterns using regular expressions. I am getting Not-found error. According to this sample, it is possible to use regular expressions with Pattern in our application. But when I declare a regular expression,...

Less Resources not Compiling Play 2.3.7

css,scala,playframework-2.0,playframework-2.3
I am trying to compile *.less resources from my assets/stylesheets/ directory. I have one file contained in this directory, which is masterpage.less. I have added the sbt plugin for less addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6") in my plugins.sbt file. The Play documentation says: Compilable assets in Play must be defined...

Play Framework 2.3 How to add unique constraint to sample application

forms,playframework,playframework-2.3
Given the Play Framework 2.3 Computer Database sample application, I would like to practice adding a unique constraint on an attribute. Let's say I want the name attribute of the Computer class to be unique. I've tried to do this by adding a validate() function (and a getter) to Computer.java:...

Play-Framework 2.3.x: Unable to send emails using plugin “play-mailer”

scala,email,reactive-programming,playframework-2.3
I am using play-framework 2.3.x and scala 2.11.4. When integrate play-mailer for sending and emails from my application, there is nothing happen. In the logs there are no exception produces and no return values are available. Following is email properties: smtp.host = "smtp.gmail.com" smtp.port = 25 smtp.user = "n****@gmail.com" smtp.password...

Error when creatin SQL table. Eban classes

java,mysql,playframework,ebean,playframework-2.3
I try to create a Transaction SQL table, which contains two foreign key from two others tables : User and Car. Car.java @Entity public class Car extends Model{ @Id @GeneratedValue public int id; @ManyToOne @JoinColumn(name="user_fk") public User user; @OneToOne(cascade=CascadeType.ALL, mappedBy="car") public Transaction transaction; } User.java @Entity public class User extends...

Error message not displaying Scala Play Forms

scala,playframework,playframework-2.0,playframework-2.3
I'm trying to get an error message to display on my form when two passwords do not match on a registration page. Here is my form private val userRegistrationForm = Form(mapping("id" -> optional(of[Long]), "firstName" -> text, "lastName" -> text, "phoneNumber" -> nonEmptyText, "emailAddress" -> email, "passwords" -> tuple( "password" ->...

Play! Framework REST with Hypermedia (HAL+JSON)

rest,playframework,playframework-2.3,hateoas
Is there any plugin for Play! Framework (either Java or Scala) that supports easy creation of Resources that provide hypermedia metadata along with the normal JSON entity? Something similar to Spring Data Rest / Hateoas, that enables easy link creation for json entities. I cant find any concrete examples...

switching between RTL and LTR in play framework

playframework,internationalization,playframework-2.3,scala-template
we are developing a web site that we need to support both LTR and RTL. we find that the best way is to change in CSSs(i.e. CSS for LTR and another to RTL). and that worked fine, the question is how to decide wether the language needs LTR or RTL....

Playframework 2.3x: scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent]

mongodb,scala,compiler-errors,playframework-2.3
i am trying to run async action in play framework and using reactive mongo for database operations. Reactive mongo return results in Future objects. But when i return the Future results in action, i am getting compile time error. Play and Scala is new for me, and still not getting...

Encoding issue only on prod?

nginx,encoding,utf-8,playframework-2.3
I built an app using PlayFramework 2.3 and at some point I upload a CSV file and populate a database with it. When accessing the app in local (127.0.0.1:9000) and doing the upload, everything works fine, the file is uploaded, parsed, and added in the database without any problem. The...

PlayFramework FakeRequest returns 400 error

scala,playframework-2.3
In routes: POST /login controllers.ApplicationCtrl.login() In Controller: def login = Action(parse.json) { implicit request => { val email = (request.body \ "email").as[String] val password = (request.body \ "password").as[String] Ok(Json.toJson( Map("status" -> "OK", "message" -> "%s created".format(email)) )) } In tests "login" in new WithApplication{ val request = route( FakeRequest( Helpers.POST,...

Ebean & Play Framework 2.3.8 : Missing statements

java,playframework,ebean,playframework-2.3
I am working with Play Framework 2.3.8 (Java) and Ebean. My project grows fine and I am now looking for solutions to catch an advanced information from my database . But, I can't find a way to use the "count()" statement or the "group by" statement. I've checked the ebean...

How to eliminate error underlining in IntelliJ 14.0.3 for Play 2.3.7 application?

scala,intellij-idea,playframework-2.3,intellij-idea-14
I am using IntelliJ IDEA 14.0.3 to develop a Play 2.3.7 application using the Scala 1.3.3 plugin. The attached screenshot shows that IntelliJ underlines the parameter to a render method as invalid when, in fact, the system compiles and runs successfully both in IntelliJ and at the command line (using...

Play Framework - play.data.validations vs. custom validations?

java,forms,validation,playframework,playframework-2.3
Using Play Framework 2.3.x, I've found that there is a difference between using the annotations in the play.data.validation package and custom code written in a validate() function. For example, let's say I have Circle.java public class Circle extends Model { @Constraints.Required public String name; public Double radius; public List<ValidationError> validate()...

How to create an Enumeratee filter based on a Future[Boolean] instead of a Boolean

scala,playframework,playframework-2.3
In my Play application, I'm creating an Enumeratee using the filter function: val activeTeams = Enumeratee.filter[Team](teamIsActive) My problem is that my teamIsActive function returns a Team => Future[Boolean] and the Enumeratee.filter method takes a Team => Boolean as parameter: def teamIsActive: (Team) => Future[Boolean] = { team: Team => val...

Play 2.3 override global SecurityHeadersFilter X-FRAME-OPTIONS for a specific action

scala,cors,playframework-2.3
I have enabled SecurityHeadersFilter globally in my Play 2.3. This is my setting: play.filters.headers.frameOptions="SAMEORIGIN" But how can I override an action with X-Frame-Options=GOFORIT instead of SAMEORIGIN?...

Is it possible to configure activator to reload the build.sbt when changed?

sbt,playframework-2.3,typesafe-activator
Is there any configuration or parameter that when running activator run on a PlayFramework project make the SBT monitor the build.sbt file such as any other file in your project? So when you change it and refresh your page it will reload the build.sbt and compile what need to be...

play framework 2.3 change template language without extra request

scala,cookies,playframework,playframework-2.3
The normal way to change the Language is to make redirect responce with .withLang(Lang(newLangCode)) but how is better to change current language without extra redirect, I have the following construction. I try to use the language from user record or from request cookies or headers if user has no language....

Playframework scala class controller vs object controller

routes,playframework-2.3
How to define a controller class in playframework (that will be injected by a dependency container)? For the app/controllers/controller package controllers import play.api.Play /*object*class MainController(name:String) { import play.api.Play.current def index = Ok(Html("index ok "+name)) } My app/Global.scala package app object Global extends GlobalSettings with SecuredSettings with Logger { override def...

ActionBuilder to accept IO[Result] instead of Future[Result]

scala,scalaz,playframework-2.3
I wrote a small example to use the IO monad from scalaz within the play framework. The example below works as expected: object IOAction { def apply(action:IO[Result]):Result = action.unsafePerformIO } class ExampleController extends Controller { val now:IO[DateTime] = IO { DateTime.now } def index = Action { request => IOAction...

Play 2.3.x: Multiproject, disable BoneCP

scala,testing,playframework,playframework-2.3,specs2
I've got a Play project with some subprojects. One of the subproject needs JDBC, so BoneCP (it accessed MySQL DB). On the other hand, the root project doesn't need JDBC at all. My problem is: JDBC is declared in the build.sbt of the subproject. When I run all the tests,...

Retrieving number of rows with non-empty one-to-many relation

playframework,playframework-2.3,ebean
I am using Play Framework 2 (Java) together with Ebean. Among my model classes, I have classA with a one-to-many relation to classB. The associated table for classB therefore has a field which either contains nullor an id for a classA entity. I would like to retrieve the number of...

Different sbt-web pipeline task settings in development vs production?

playframework,sbt,playframework-2.3,uglifyjs,sbt-web
I would like an sbt setting to have a different value when running in development (sbt run) than production (sbt dist / sbt start). Specifically I am using sbt-uglify. I use it in development to concatenate javascript assets into one file. I have compression and mangling disabled in development because...

App not working on Heroku after upgrading database

postgresql,scala,heroku,playframework-2.0,playframework-2.3
I just recently upgraded my database on Heroku from the Hobby dev plan to the Standard 0 plan. My application was working just fine on the Hobby Dev plan with regards to inserting data. I changed the DATABASE_URL to the new DATABASE_URL. I am receiving the correct credentials, which I...

Playframework dynamic form handling

java,forms,playframework-2.3
Hallo guys im new to the playframework and run into a little problem regarding form handling. Here is my view <form action="@routes.Account.changeemail()" method="Post"> email:<input name ="email"> <button type="submit" name="action" value="Change_email">save</button> <br /> </form> <form action="@routes.Account.changepassword()" method="Post"> password:<input name ="password"> <button type="submit" name="action" value="change_password">save</button> </form> <br /> And...

Generate javadoc of a project using Play framework 2.3

playframework,playframework-2.3
I have a java application using Play framework 2.3.8. I have read about the old commands such as play doc. After running activator doc, I get a jar named ***-1.0-SNAPSHOT-javadoc.jar in target\scala-2.11 directory. But it is empty. Could anyone point out by how I could generate the HTML javadoc automatically?...

IntelliJ Ultimate can't find routes in Play 2.3 (Java) project tests

java,intellij-idea,playframework-2.0,playframework-2.3
While my tests run just fine, IntelliJ complains that it can't find the routes object and code auto complete fails to work. I've looked all over the documentation and this should just work. Here is what IntelliJ is reporting Any thoughts as to what might be wrong with my project...

Play Framework submitting boolean values with checkbox?

javascript,forms,checkbox,playframework,playframework-2.3
Using Play 2.3.x I am trying to understand how checkboxes are handled in forms. This question seems like an outdated solution for an older version of Play. I understand that checkbox info will only be posted if checked, but I've created a small sample app and no info is posted...

Java Play! Framework - Unable to populate form with existing value

playframework-2.3
I am using Java Play framework 2.3.6 .I can't able to populate the form with existing value. Given below the code snippets. Application.java public class Application extends Controller{ static Form<Roles> rolesForm=Form.form(Roles.class); public static Result getRoleById(Long id){ Roles r = RolesDao.getRoleById(id); //rolesForm.fill(RolesDao.getRoleById(id)); rolesForm.fill(r); return ok(updateRole.render(rolesForm)); }} updateRole.scala @(roleForm : Form[models.Roles]) @import...

Introspect in-memory H2 Database

h2,playframework-2.3
My Play app uses H2 in-memory database when it runs in dev or test mode. I want to access this database when the app runs in dev mode. So I have the following options 1) Run the database in Embedded/Mixed mode. And make the play framework expose the database to...

Model superclass for JPA in Play Framework in 2.3.x Java

postgresql,jpa,playframework,playframework-2.3
I'm trying to use JPA in Play Framework for Java version 2.3.7. Before in Play 1.x, there was a Model superclass that made it really easy to execute queries like "List persons = Person.findAll();". Is there Model superclass for javaJpa to do this?...

Play application.conf : Where to consult the list of all possible variable?

playframework-2.3
Where can i find the list of all possible variable that is possible to set in play application.conf ? I can't find this information on playframework website. Thank you...

path parameter: Invalid path Scala Play Config file

scala,playframework,playframework-2.0,playframework-2.3
I am getting a parsing exception inside of my application.conf file. Here is my application.conf db.test.driver = org.postgresql.Driver db.test.user = "postgres" db.test.password = "postgres" db.test.url = "jdbc:postgresql://localhost:5432/gasguru" here is the code that I am trying to use to read from my application.conf trait DbConfigWeb extends DbConfig { qualifier: DbQualifier =>...

Logs not showing up Scala Play 2.3.x

scala,playframework,playframework-2.0,playframework-2.3
I am trying to my logs to show up in my play console. Here is an example of a controller I am trying to log information from : import play.api.Logger object LandingPage extends Controller { import ComponentRegistry._ private val emailForm = Form(mapping("id" -> optional(of[Long]), "emailAddress" -> email)(Email.apply _)(Email.unapply _)) def...

Play framework Scala actions

scala,playframework,playframework-2.3
As someone new to Scala, can someone explain the code here? val echo = Action { request => Ok("Got request [" + request + "]") } So I get that you're creating a new value called echo, from an Action trait (similar to a Java interface from what I can...

Load libraries in dist application, which are not known at build time

java,playframework,playframework-2.3
We want to deploy additional third party libraries (which name we dont know at build time) into a dist application, without requiring to rebuild it. Play should load them automatically on start. We tried to copy them to the lib folder, that doesnt work. We saw that there is a...

Playframework with Deadbolt2: overriding method getSubject in trait DeadboltHandler of type

scala,compiler-errors,playframework-2.3,deadbolt-2
I am using Deadbolt2 for authorization. When i, extends DeadboltHandler and override their methods, i am getting following error in eclipse: implements be.objectify.deadbolt.scala.DeadboltHandler.getSubject overriding method getSubject in trait DeadboltHandler of type [A](request: play.api.mvc.Request[A])Option[be.objectify.deadbolt.core.models.Subject]; method getSubject has incompatible type These are compile time errors and produce on getSubject method, because of...

Access body as JSON in ActionBuilder

json,action,playframework-2.3
I'm using Playframework 2.3.X. I'm trying to construct an action function that validates fields in a JSON request.body. The use case is to build "blocks" of validation that I can then chain together. However, I can't seem to access the request.body as a JSON inside the action builder. The following...

Play Ebean .orderBy() broken? Replacing character with “$ ”

java,sql,orm,playframework-2.3,ebean
The following Ebean find String join = "trackToArtists.artist.artistToTags.tag.stationToTags.station"; return find .where() .eq(join, station) .ge(join + ".energyMin", settings.energyMin) .le(join + ".energyMax", settings.energyMax) .ge(join + ".livenessMin", settings.livenessMin) .le(join + ".livenessMax", settings.livenessMax) .ge(join + ".tempoMin", settings.tempoMin) .le(join + ".tempoMax", settings.tempoMax) .ge(join + ".acousticnessMin", settings.acousticnessMin) .le(join + ".acousticnessMax", settings.acousticnessMax) .ge(join +...

Split play project into parts

scala,akka,playframework-2.3
I am having some play framework web project that consist of 3 logical parts: an userweb , an admin area and akka actors. It's slowly growing up and I need to restart the production server for each small change. That's why I decided to split the project into 3 parts....

Scala - unbound wildcard exception (Play Framework 2.3 Template)

scala,playframework,playframework-2.3
I am using Play Framework 2.3 I am using the scala template engine to create my views and Java elsewhere. My model extends an abstract parameterised object like so... (pseudo code) Abstract object: public abstract class MyObject<T> { // various bits public class MyInnerObject { // more stuff } }...

Play Framework - Register a custom DataBinder for dynamic fields

playframework,playframework-2.3,dynamicform
Using Play 2.3.7 (Java) I have the following scenario. I have a class CSVData which contains a list of type CSVField. Here are the attributes for these classes: public class CSVData{ private String name; private String description; private String dataFilePath; private List<CSVField> fields; private Double latitude; private Double longitude; //...

Play Framework:Error type mismatch; found :Int required: play.api.mvc.Result

scala,playframework,playframework-2.3,scala-2.11
I am trying to save form values to a database, and play I am getting the error: type mismatch; found :Int required: play.api.mvc.Result And here is my code : Application.scala import play.api._ import play.api.mvc._ import play.api.data._ import play.api.data.Forms._ import views.html.defaultpages.badRequest import play.api.data.validation.Constraints._ import models.User import models.UserData object Application extends Controller...

Consuming a service using WS in Play

scala,future,playframework-2.3
I was hoping someone can briefly go over the various ways of consuming a service (this one just returns a string, normally it would be JSON but I just want to understand the concepts here). My service: def ping = Action { Ok("pong") } Now in my Play (2.3.x) application,...

Reactive Mongo Extensions: Pass List Of Values In $in Query using `Query DSL`

mongodb,scala,playframework-2.3,querydsl,reactivemongo
I am trying to pass multiples value in $in query using Query DSL with Reactive Mongo Extensions. But the result is empty list. Follwoing is my Code: def findUsersByRolesIds(rolesIds: List[BSONObjectID], page: Int, pageSize: Int): Future[List[User]] = { logger.info("findUsersByRolesIds Reactive Repository Method"); userGenericRepo.find($doc("userRoles._id" $in (rolesIds)), $doc("createdOn" -> -1 ), page, pageSize);...

Issue on saving data into DB using play / Ebean

java,playframework,playframework-2.0,ebean,playframework-2.3
I have 3 classes. Car User UserCars This 3 classes represents tables into my DB. The UserCars table links the Car and Users table and it's constructed the following way: ---Users--- int id int cars_id int user_id ----- I try to save a car related to it's user by using...

Defining cross-attribute Json Validators for a case class in Play Framework 2.3.x (Scala)

json,scala,validation,playframework-2.0,playframework-2.3
I know it's possible to define Case classes that we want to match some given json against (we use JsValue.validate[T]): For example: case class UpdateDashboardModel(id: Long, maybeName: Option[String], containers: Option[List[UpdateContainerModel]], description: Option[String]) And then we must write a Reads[T] to define how to actually turn a json object into an...

Can I ignore the “twitter bootstrap is deprecated” warnings in my code?

twitter-bootstrap,playframework,deprecated,playframework-2.3
I am using the play framework 2.3.8 with twitter Bootstrap 3.3.4 and have several forms in my application, where you can enter input. Sample: @import models.Question @import models.Answer @import helper._ @import helper.twitterBootstrap._ @(questionForm: Form[Question], questionList: List[Question]) @main("Ask Question"){ @helper.form(action = routes.Application.sendQuestion()){ <fieldset> @helper.inputText(questionForm("questionID")) @helper.inputText(questionForm("questionText")) @helper.inputText(questionForm("voteScore"))...

In Playframework2, how can I use “specs2-scalacheck”?

playframework,playframework-2.3,specs2,scalacheck
I want to use ScalaCheck with specs2 in Playframework 2.3.x, and write like this in build.sbt libraryDependencies ++= Seq( ... "org.specs2" %% "specs2-scalacheck" % "2.11.5", ...) However, I found this will return an error during compiling [info] Resolving org.specs2#specs2-scalacheck_2.11;2.11.5 ... [warn] module not found: org.specs2#specs2-scalacheck_2.11;2.11.5 I thought the version of...

Why can't I access the file react.js from the react-0.12.2 webjar?

playframework,reactjs,playframework-2.3,webjars
I use the webjar react-0.12.2 in my Play Framework 2.3 project, and I've depended on it like so: libraryDependencies ++= Seq( "org.webjars" %% "webjars-play" % "2.3.0-2", "org.webjars" % "react" % "0.12.2" ) If I try to access 'react.js' though, like in the following example, I get an error due to...

During testing, how can I fake MailerPlugin.send so I can get the sent email?

scala,testing,playframework,stub,playframework-2.3
During testing I wish to fake play.api.libs.mailer.MailerPlugin in Play 2.3, so that I can get hold of the email being sent. How do I do this? App Code package services import play.api.libs.mailer._ import play.api.Play.current object EmailService { def sendUserNotification(to: String, subject: String, content: String): Unit = { val email =...

Retrieve HTTP status from Promise on Play 2.3.7

java,json,playframework,promise,playframework-2.3
in our project we use JSON for data transmission between front and backend. Basically we creating requests by preparing WSRequestHolder, just like the play doc tells to (https://www.playframework.com/documentation/2.3.7/JavaWS) and then posting a json string. The WSResponse is then mapped "asJson" returned as a Promise. But unlike WSResponse, the JsonNode does...

Advanced HTTP server configurations in Play 2.3

playframework,playframework-2.0,playframework-2.2,playframework-2.1,playframework-2.3
I am using Play 2.3 to develop an application. I need to set http.netty.log.wire to true which is by default false as specified in Play documents. In the below link (last section) it says this option is available but it also specifies "we cannot use application.conf" to specify this. https://www.playframework.com/documentation/2.3.x/ProductionConfiguration...

Play upgrade to 2.4 but failed to fetch sbt-plugin

playframework-2.3,playframework-2.4
[warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: UNRESOLVED DEPENDENCIES :: [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] :: com.typesafe.play#sbt-plugin;2.4.0: not found [warn] :::::::::::::::::::::::::::::::::::::::::::::: [warn] [warn] Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes. [warn] com.typesafe.play:sbt-plugin:2.4.0 (scalaVersion=2.10, sbtVersion=0.13) This is my plugins.sbt: resolvers ++= Seq( "Typesafe Releases" at...

Play Framework Form Error Handling

scala,playframework,playframework-2.3,playframework-2.4
This is my view file containing the form that has to filled in by the user: @helper.form(call) { @helper.input(resumeForm("surname"), '_label -> "Surname") { (id, name, value, args) => <input name="@name" type="text" value="@value" placeholder="Enter your surname"> } } This is my custom field constructor: @(elements: helper.FieldElements) @if(!elements.args.isDefinedAt('showLabel) || elements.args('showLabel) == true)...

Scala Play Forms verify that one date occurs after another

scala,playframework-2.0,playframework-2.3
My form has two dates, but I want to validate that the second date occurs after the first date. Is there a concise way to do this using Play's Form verification? Here is the form I am working with: val policyForm: Form[PolicyForm] = Form(mapping( "amount" -> of[Double].verifying("You need to enter...

Play 2.3.X Security headers are gone when adding CACHE_CONTROL header in doFilter

scala,http-headers,playframework-2.3
My Global.scala: object Global extends WithFilters(SecurityHeadersFilter(), new GzipFilter()) with GlobalSettings { override def doFilter(action: EssentialAction) = EssentialAction { request => action(request).map(_.withHeaders( CACHE_CONTROL -> "no-cache, no-store, must-revalidate, private", PRAGMA -> "no-cache" )) } } All security headers (X-Frame-Options, X-Content-Type-Options, ...) are gone if I tries to override doFilter with CACHE_CONTROL. How...

How can I tell the contents of a webjar?

playframework,playframework-2.3,webjars
Let's say I want to use the webjar react-0.12.2 in my Play Framework 2.3 project, and I've depended on it like so: libraryDependencies ++= Seq( "org.webjars" %% "webjars-play" % "2.3.0-2", "org.webjars" % "react" % "0.12.2" ) How do I tell which assets are available in the react webjar? If I...

Play framework (2.3.5) - Template accessing an inner class fails

playframework,playframework-2.3
I have a class defined like so (pseudo code): package com.some.namespace public class SomeClass { protected SomeClass() {} // stuff... public class SomeInnerClass { public SomeInnerClass() {} // more stuff (accesses instance variables from SomeClass)... } } Then in my template I use the reusable block defines like so: @doSomething(val:...

How to chunk responses in Play without running out of memory

playframework,playframework-2.0,playframework-2.3
I'm iterating over a large data set, with regular calls to play.mvc.Results.Chunks.Out.write(...) from within onReady. Because writes happen faster than data is sent to the client, I'll often run out of memory after a while... So what's the proper way to do this?...

Play 2.x Json transform json keys to camelCase from underscore case

json,playframework-2.2,playframework-2.3
I want to transform a json with underscore case keys to camel case keys. "{\"first_key\": \"first_value\", \"second_key\": {\"second_first_key\":\"second_first_value\"}}" to "{\"firstKey\": \"first_value\", \"secondKey\": {\"secondFirstKey\":\"second_first_value\"}}" This is partial code: val CamelCaseRegex = new Regex("(_.)") val jsonTransformer = (__).json.update( //converts json camel_case field names to Scala camelCase field names ) val jsonRet =...

How to check whether there are newer versions of library dependencies in an sbt/play/activator project

sbt,playframework-2.3,typesafe-activator
Is there any command in Activator that can list all the dependencies and libraries that I use with the current version and newer versions that is possible to use to update my project? This is similar that the apache maven command versions:display-dependency-updates. Is there any similar command available?...

Play framework (Java) model validation - different check for create() and update()

java,validation,playframework,playframework-2.3
I'm using Play 2.3.7 and I basically have the same question as this but I am using Java and I don't know Scala. In my case I have a CSVData class with a name attribute that I want to be unique. In my controller actions for both create() and update(Long...

Play Framework trouble importing scala template from different package

playframework,playframework-2.3,twirl
Using Play 2.3.7, I have a set of bootstrap3 templates similar to this example project, and they are in a package app/views/bootstrap3/. One of these bootstrap3 templates is a text field object in a file named text.scala.html. In a separate package, I have some other templates in which I want...

How to make application to initialize before first request?

playframework,playframework-2.3
I have an application which i run from Intellij IDEA. In global object i have an onStart hook, which starts Akka jobs. When i run this application it didn't initialize until i trigger request to one of controllers. Is it possible to make framework initialize eagerly?...

Using Java 8's stream() gives subclassing error in Play Framework 2.3

playframework,java-8,ebean,playframework-2.3
In my Play Framework 2.3.7 Java app I have written a method that contains the following expression: myList.stream().map(x -> x.myMethod()).collect(Collectors.toList()); This produces the following error: Entity type class models.MyClass is not an enhanced entity bean. Subclassing is not longer supported in Ebean If I replace the expression with the pre-Java...

Play Framework 2.3.x (Java) distribution with Ebean

java,web-deployment,playframework-2.3,ebean
I tested my Play Framework application on my local machine. Everything is working. When I first start my Play application on localhost:9000 it gives me the error that my database 'default' needs an evolution. This all is to be expected and works like a charm. Now, when I render a...

Playframework — where to get working samples

playframework,sample,playframework-2.3
I decided to try Playframework out. I downloaded play2.3.8 from here https://www.playframework.com/download and noticed that I have 3 activator jars but not a /samples directory. I was able to get a /samples directory out of the play2.2 zip but it doesn't seem to run with the activator jars I got...

Why is image-src method-return-type instead of URL/route for Play Framework Module Controller?

scala,image-processing,module,playframework-2.3,brokenimage
I have created a Play Framework module "Ean2BarcodePlayModule" which includes this template "barcode.scala.html" saved in the "views.barcodePackage.tags" package: @(ean: Long) <img class="barcode" alt="@ean" src="@controllers.barcodePackage.BarcodeController.getBarcode(ean)" /> After using "activator publish-local", I've then referenced this in the "index.scala.html" template of a test project: @(message: String) @main("Welcome to Play") { @barcodePackage.tags.barcode(5010255079763L) } The...

Iterating all Play Framework routes in Test

java,routes,integration-testing,playframework-2.3
Is there any way to Iterate all described services in routes file? URL and HTTP methods are needed. I need this feature for running some integration test. I am using Play for Java....

Time field in Play Framework

java,playframework,playframework-2.3
I am trying to create simple time field in my Java Play Framework application. I've prepared a class: public class Schedule extends AbstractEntity { @Temporal(TemporalType.TIME) public Date arrival; @Temporal(TemporalType.TIME) public Date departure; @Enumerated(EnumType.STRING) public Variant variant; } I try to obtain some departure and arrival times via this template: <div...

Restarting Play application Docker container results in 'This application is already running' - RUNNING_PID is not deleted

java,playframework,playframework-2.0,docker,playframework-2.3
Edit: There is a related issue being discussed on Github but in another mode of deployment (Typesafe Activator UI and not Docker). I was trying to simulate a system reboot in order to verify the Docker restart policy which declares to be able to re-run containers in the correct order....

right usage of slick filter

scala,slick,playframework-2.3
I'm using slick to access database. I want to query like this: case class Coupon(couponId:Long, shopId:String) class Coupons(tag:Tag) extends Table[Coupon](tag, "coupons"){ def couponId = column[Long]("coupon_id") def shopId = column[String]("shop_id") override def * = (couponId, shopId) <> (Coupon.tupled, Coupon.unapply) } object Coupons extends TableQuery(new Coupons(_)){ def findCouponBy(couponId:Long, shopId:Option[String]) = { val...

SBT Won´t update .classpath in a Play Scala project

eclipse,scala,sbt,playframework-2.3
I am creating a new Play Scala project within Eclipse + Scala IDE. The original build.sbt file is: name := """portal""" version := "1.0-SNAPSHOT" lazy val root = (project in file(".")).enablePlugins(PlayScala) scalaVersion := "2.11.1" libraryDependencies ++= Seq( jdbc, cache, ws ) I've edited it to include some more dependencies: libraryDependencies...

Deserialize body of result which is a byte array to json response

scala,playframework,playframework-2.3
I'm trying to take the body of a result and deserialize it into JSON. val str = """ {"protectedBitcoinAddress":"moLM1zdPBSh81eykhfcoLZ3myqUSy9FRRG"} """ val request : JsValue = Json.parse(str) println("Request: " + request.toString) val result : Future[Result] = createUnsignedNLockTime()(FakeRequest().withJsonBody(request)) whenReady(result, timeout(19 seconds), interval(5 millis)) { res => println("==============================") val e: play.api.libs.iteratee.Enumerator[Array[Byte]] = res.body...