Coder Social home page Coder Social logo

playframework / playframework Goto Github PK

View Code? Open in Web Editor NEW
12.5K 633.0 4.1K 106.79 MB

The Community Maintained High Velocity Web Framework For Java and Scala.

Home Page: http://www.playframework.com

License: Apache License 2.0

Scala 68.50% Java 30.36% HTML 0.81% CSS 0.01% JavaScript 0.18% Roff 0.12% Less 0.03%
scala java reactive web-framework restful play playframework jvm framework webapps

playframework's Introduction

Play Framework - The High Velocity Web Framework

Twitter Follow Discord GitHub Discussions StackOverflow YouTube Twitch Status OpenCollective

Build Status Maven Repository size Scala Steward badge Mergify Status

The Play Framework combines productivity and performance making it easy to build scalable web applications with Java and Scala. Play is developer friendly with a "just hit refresh" workflow and built-in testing support. With Play, applications scale predictably due to a stateless and non-blocking architecture. By being RESTful by default, including assets compilers, JSON & WebSocket support, Play is a perfect fit for modern web & mobile applications.

Learn More

Sponsors & Backers

If you find Play useful for work, please consider asking your company to support this Open Source project by becoming a sponsor.
You can also individually sponsor the project by becoming a backer.

Thank you to our premium sponsors!

Thank you to all our backers!

License

Copyright (C) from 2022 The Play Framework Contributors https://github.com/playframework, 2011-2021 Lightbend Inc. https://www.lightbend.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

playframework's People

Contributors

benmccann avatar billyautrey avatar cchantep avatar dotta avatar dwijnand avatar erwan avatar gmethvin avatar guillaumebort avatar gurkankaymak avatar huntc avatar ignasi35 avatar ihostage avatar jroper avatar julienrf avatar marcospereira avatar mergify[bot] avatar mkurz avatar naferx avatar nraychaudhuri avatar octonato avatar ph2734 avatar promansew avatar pvlugter avatar raboof avatar richdougherty avatar sadache avatar scala-steward avatar schmitch avatar wsargent avatar xuwei-k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

playframework's Issues

Application configured ClassLoader should be passed on to the ActorSystem constructor

Once again, if the Play application has been configured with a classloader, this classloader should be passed on to the underlying ActorSystem in play.core.Invoker:

https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/play/core/system/Invoker.scala#L21

^ That ActorSystem constructor should be passed the configured classloader, if present in the Application instance, otherwise fallback on the call used currently.
@Gissues:{"order":23.076923076923023,"status":"backlog"}

RuntimeException: DataSource user is null?

Hi!

I'm working on simple project by tutorials and my project isn't working. When i'm trying to save model, edited by form (Special Events -> edit -> Save), Play raised Runtime Exception:

RuntimeException: DataSource user is null?

What is it? Seems like a bug in ebean configuration because similar code form example (computer database) is working fine. Google say nothing except what i'm already done in application.conf

Here is a link to my simple project, you can try in on your own:
https://github.com/bsideup/PlayFrameworkExperiment

Thank you!
@Gissues:{"order":15.384615384615328,"status":"backlog"}

Play documentation cannot be read when using regular SBT or just using sbt-launch.jar

Play's documentation (and welcome page css) are unavailable when regular old sbt users are trying to use play from sbt. Not only that, if sbt wanted to have a distribution that was play friendly, it would have to find the correct documentation sources and embedd them in its own distribution, setting the play.home property. THis means we can't support the "sbt-launch.jar" and that's it method of building a project from nothing in addition to downloading a play distribution.

I propose the following:

  • Documentation is bundled into a zip/jar and deployed with Ivy to the repository
  • Play's sbt-plugin depends/resolves this jar from the cache and hosts from that location, passed in via a setting or hosted via the classpath (in devel mode). (Play should not rely on play.home, or it should install into a play.user.home necessary files, so we can detangle from the play distribution).
  • Play's @documentation view helper guy renders from the passed in jar setting or classpath
  • Documentation artifacts are deployed with the "local repository" that comes in a play distribution

Logger should use Application's classloader, not this.getClass()

If a classloader is configured in an application, that classloader should be used to lookup application-logger.xml, and not this.getClass.getClassLoader()

So, instead of:
this.getClass.getClassLoader.getResource("application-logger.xml")

it should be:

applicationClassLoader.getResource("application-logger.xml")
@Gissues:{"order":28.205128205128155,"status":"backlog"}

Parallel execution definitions of tests are ignored

Play ignores SBT test configuration settings like parallelExecution in Test := true or test grouping, or defined limits like Tags.limit(Tags.Test, 3).

It's not clear (especially not for a Java developer) and undocumented how to execute tests parallel, even if it's possible somehow. Here is an example Build.scala that defines the tests running in multiple JVMs & multiple threads, but all the tests running in a single JVM in a single thread instead.

import sbt._
import Keys._
import play.Project._

object ApplicationBuild extends Build {
    val appName         = "testTest"
    val appVersion      = "1.0-SNAPSHOT"

    val testThreads = 8

    def groupByFirst(tests: Seq[TestDefinition]) =
      tests groupBy (_.name(0)) map {
        case (letter, tests) => new Tests.Group(letter.toString, tests, Tests.SubProcess(Seq("-Dfirst.letter"+letter)))
      } toSeq;

    val appDependencies = Seq(
      javaCore,
    )

    val main = play.Project(appName, appVersion, appDependencies).settings(
      concurrentRestrictions in Global := Seq(
        Tags.limit(Tags.ForkedTestGroup, testThreads),
        Tags.limit(Tags.Test, testThreads),
        Tags.limit(Tags.CPU, testThreads),
        Tags.limit(Tags.Compile, testThreads),
        Tags.limitAll(testThreads),
        Tags.limitUntagged(testThreads)),
      parallelExecution in Test := true,
      testGrouping <<= definedTests in Test map groupByFirst
    )
}

I use JUnit as my testing framework.

I put this line into each tests to test whether the tests run in parallel or not:

System.out.println(String.format("process id: %s thread id: %s", ManagementFactory.getRuntimeMXBean()
    .getName(), Thread.currentThread().getId()));

I understand that certain tests cannot be run parallel (E.g. more than one TestServer in a single JVM or more than one TestServer in multiple JVMs that listens on the same port) but it doesn't mean that parallel execution should be disabled for all kind of tests.

@Gissues:{"order":35.89743589743585,"status":"backlog"}

Controller Test with FakeRequest withFormUrlEncodedBody fails

The "POST" test in the attached project fails because the body is lost.

Play Version:
play! 2.1.0 (using Java 1.7.0_11 and Scala 2.10.0)

Running "test" from the Play command line yields the output below.

The test which attempts a POST to the controller fails because the body is empty after the body parser does it's stuff.

Before the call to the controller, the output is:

before: request.AnyContentAsFormUrlEncoded(Map(bookingRef -> ArrayBuffer(asdf)))

In the controller the output is:

b body AnyContentAsFormUrlEncoded(Map())

The "bindFromRequest" fails and that results in the BadRequest rather than a successful test.

IMPORTANT: The aim of this test is to test the controller WITH stubbed dependencies. That means a work around using Helpers.route isn't an option (AFAIK).

Maybe related to:

http://play.lighthouseapp.com/projects/82401/tickets/773-fakerequestwithformurlencodedbody

https://groups.google.com/forum/?fromgroups=#!topic/play-framework/MD6fUhp2ajw

Test Output:

[demo2] $ test
[info] Compiling 6 Scala sources and 1 Java source to W:\training6_scalabook\pla
y\play-2.1.0\demo2\target\scala-2.10\classes...
[warn] W:\training6_scalabook\play\play-2.1.0\demo2\conf\routes:8: unreachable c
ode
[warn] GET /someAsync controllers.Application.someAsync
[warn] one warning found
[info] Compiling 1 Scala source to W:\training6_scalabook\play\play-2.1.0\demo2
target\scala-2.10\test-classes...
before: request.AnyContentAsFormUrlEncoded(Map(bookingRef -> ArrayBuffer(asdf)))

a
b session Session(Map(username -> [email protected]))
b body AnyContentAsFormUrlEncoded(Map())
b queryString Map()
c
java.lang.AssertionError: expected:<200> but was:<400>
at org.junit.Assert.fail(Assert.java:93)
...

[error] Test controllers.ApplicationTest.testAsyncPost failed: expected:<200> bu
t was:<400>
a
b session Session(Map(username -> [email protected]))
b body AnyContentAsEmpty
b queryString Map(bookingRef -> List(asdf))
d ref asdf
e
[info] play - Starting application default Akka system.
h
f
g
i answer [Stubbed] You said: asdf
[info] play - Shutdown application default Akka system.
[info] controllers.ApplicationTest
[info] x controllers.ApplicationTest.testAsyncPost
[info] + controllers.ApplicationTest.testAsyncGet
[info]
[info]
[info] Total for test controllers.ApplicationTest
[info] Finished in 0.127 seconds
[info] 2 tests, 1 failures, 0 errors
[error] Failed: : Total 2, Failed 1, Errors 0, Passed 1, Skipped 0
[error] Failed tests:
[error] controllers.ApplicationTest
error Tests unsuccessful
[error] Total time: 57 s, completed 14.03.2013 09:05:59
[demo2] $

using @helper.repeat causes invalid i18n message key

@helper.repeat(userForm("roles"), min = 1) { roleField =>
    @helper.select(
        roleField,
        Role.find.all().map(r => r.name -> r.name.capitalize),
        '_default -> Messages("user.selectrole")
    )
}

creates a field with the name roles[0] which is also used for the Messages call. the problem is that this isn't a valid messages file key. causing this error:

`=' expected but `[' found
Suggested format for the message file would be roles.0 and roles.1 and so on (same as play1)

the problem lies here: https://github.com/playframework/Play20/blob/master/framework/src/play/src/main/scala/views/helper/Helpers.scala#L42

Deprecate the Twitter bootstrap helper

The Twitter bootstrap form template helper wasn't updated since a year and does not yet fully support Bootstrap 2.
In a pull request guillaumebort suppose to deprecated the helper in the next Play version (and publish a Plugin for the helper?).

But in Play 2.1 the Play Template helper Documentation still suppose to use the Twitter template helper and there is no note that Bootstrap 2 isn't fully supported which is frustrating for newbies like me.
@Gissues:{"order":66.6666666666666,"status":"backlog"}

Json.toJson() return null directly

Hi, I have this issue: Json.toJson() return null value directly, I would like this method return "" rather than null. I figure out that I can handle this in getters, but I dont want to. Can I write a custom ObjectMapper or Serializer something like that to deal with it? Thanks
@Gissues:{"order":2.5641025641025084,"status":"backlog"}

Can't run "play start" on Windows with JDK 7

C:\play-2.1.0\samples\scala\comet-live-monitoring>C:\play-2.1.0\play start
[info] Loading project definition from C:\play-2.1.0\samples\scala\comet-live-monitoring\project
[info] Set current project to comet-live-monitoring (in build file:/C:/play-2.1.0/samples/scala/comet-live-monitoring/)

(Starting server. Type Ctrl+D to exit logs, the server will remain in background)

Error occurred during initialization of VM
java.lang.ExceptionInInitializerError
        at java.lang.Runtime.loadLibrary0(Runtime.java:841)
        at java.lang.System.loadLibrary(System.java:1084)
        at java.lang.System.initializeSystemClass(System.java:1145)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
        at java.lang.String.charAt(String.java:658)
        at java.io.Win32FileSystem.<init>(Win32FileSystem.java:40)
        at java.io.WinNTFileSystem.<init>(WinNTFileSystem.java:37)
        at java.io.FileSystem.getFileSystem(Native Method)
        at java.io.File.<clinit>(File.java:156)
        at java.lang.Runtime.loadLibrary0(Runtime.java:841)
        at java.lang.System.loadLibrary(System.java:1084)
        at java.lang.System.initializeSystemClass(System.java:1145)

Workaround:

play -Dfile.separator=\/ start

Fix clean-all

play clean-all doesn't work at all with sub projects. It's a hack, and should either be removed altogether, or fixed.

I think modifying SBT clean so that it removes things like the logs and other transient play things is one step, and another step is to modify clean-all to invoke clean in SBT, followed by whatever that magic SBT reboot thing is that Josh showed me.
@Gissues:{"order":38.46153846153841,"status":"backlog"}

Play 2.0. Ebean. OneToMany orphan removal broken

I have two classes with onetomany relationship:

@Entity
public class Parent extends Model{

  @Id
  public Long id;

  @OneToMany(fetch = FeatchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
  public List<Child> children;

}

and

@Entity
public class Child extends Model{

  @Id
  public Long id;

}

So when i call remove() Child entity do not remove from DB.

@Test
   public void first(){
      running(fakeApplication(), new Runnable(
         Parent p = new Parent();
         p.children = new ArrayList<Child>();

         p.children.add(new Child());
         p.children.add(new Child());
         p.children.add(new Child());
         p.children.add(new Child());
         p.save();

         Assert.assertEquals(4, Child.find.all()); // Thats ok

         p = Parent.find.byId(p.id);
         p.children.remove(2);
         p.save();

         Assert.assertEquals(3, Child.find.all()); // Thats fails: we still got 4 children 
      ));
   }

Play 2.0.4, inMemory database.

Please make me know if any other informaition is needed.

implicit typemapper cannot be defined in a package object (runtime error)

I have this implicit to convert from sql.Date to util.Date

implicit val dateTypeMapper = MappedTypeMapper.base[java.util.Date, java.sql.Date](
    { jud => new java.sql.Date(jud.getTime) },
    { jsd => jsd })

When defined in the package object, it compiles, but fails at runtime (when generating the DDL) with a method not found error.

See this gist for the complete source code :https://gist.github.com/tyrcho/5086544

This was initially created in play-slick (playframework/play-slick#32) but it seems more a play issue than a problem with play-slick.

Akka.future does not preserve Http.Context

Akka.future is used in documentation to show how to perform an asynchronous operation. Unfortunately, the Callable that is passed to this operation is run such that the Http.Context thread local is not preserved. Although there is a known workaround, it is a strange inconsistency that I suspect is probably a bug...

Example 1 - a working example

Here is an example using WS that does preserve Http.Context.

    public Result index() throws Exception {

        logger.info("Context before async" + Http.Context.current().id());

        return async(WS.url("http://www.google.com").get().map(new Function<Response, Result>(){
            {
                logger.info("Context in fn creation " + Http.Context.current().id());
            }
            @Override
            public Result apply(Response a) throws Throwable {
                logger.info("Context in fn " + Http.Context.current().id());
                return TODO;
            }
        }));

Example 2 - the problem

Here is an example that uses Akka.future and throws an exception when trying to access the Http.Context

    public Result index() throws Exception {

        return async(Akka.future(new Callable<Result>(){
            {
                logger.info("Context in callable creation " + Http.Context.current().id());
            }
            @Override
            public Result call() throws Exception {

                // TODO: Http.Context should be accessible here instead of throwing exception...?
                logger.info("Context in callable execution " + Http.Context.current().id());
                return TODO;
            }

        }));

Example 3 - a workaround

Known workaround -- use an empty callable to start the processing, and put all code in subsequent calls to map, flatmap, recover or onredeem

    public Result index() throws Exception {
        return async(Akka.future(new Callable<Void>(){

            @Override
            public Void call() throws Exception {
                return null;
            }

        }).map(new Function<Void,Result>(){
            {
                logger.info("Context in function creation " + Http.Context.current().id());
            }
            @Override
            public Result apply(Void a) throws Throwable {
                logger.info("Context in function execution " + Http.Context.current().id());
                return TODO;
            }

        }));

@Gissues:{"order":71.79487179487174,"status":"backlog"}

Missing idea-sources-classifiers

When using a sub-project and run 'idea'. I get this error: "Missing idea-sources-classifiers"

[info] Trying to create an Idea module play-app
[info] Trying to create an Idea module module1
[error] Missing idea-sources-classifiers
java.lang.IllegalArgumentException
at com.typesafe.sbtidea.SbtIdeaPlugin$.logErrorAndFail$1(SbtIdeaPlugin.scala:169)
at om.typesafe.sbtidea.SbtIdeaPlugin$$anonfun$setting$1$1.apply(SbtIdeaPlugin.scala:174)
@Gissues:{"order":12.820512820512764,"status":"backlog"}

2.1 play idea ignores test classifier test scope dependencies

I added this dependency to my project

"com.sclasen" %% "play-extras" % "0.2.6-SNAPSHOT" % "test" classifier "test",

play idea does not add it to my project deps,

compiling with code written against this dep works in play/sbt

added sbt-idea plugin to the project, and ran gen-idea and the dep showed up as expected

Bug with Content-Length

I try to download file in my play project.
Code sample:

public static Result getPDF() {
  response().setContentType("application/x-download");
  response().setHeader("Content-Disposition", "attachment; filename=123.pdf");
  return ok(new FileInputStream(REPORTDIR + "123.pdf"));
}

But when file is 123.pdf too big(2 Mb), and I try to download it,i got the Content-Length: 0 (and i can't download it).
If I write header (Content-Length) play doesn`t get file, file with right size I got only when I stoped play.
On small files (10-100 Kb) it works fine.

Migrated from http://play.lighthouseapp.com/projects/82401/tickets/1040-Bug-with-Content-Length

WAMP Subprotocol rejected by Netty

I'm trying to implement a WAMP module for Play so I can do pub/sub and RPC over websockets. The canonical WAMP JavaScript library is AutobahnJS which sends the Sec-WebSocket-Protocol header set to 'wamp'. This subprotocol is rejected by the WebSocketServerHandshaker13.java in Netty. The reason is that in Play's WebSocketHandshake.scala the handshaker is constructed with null for the subprotocol argument.

I looked at the Netty source and according to the comments the null value means subprotocols are not supported. This seems overly constrained to me for Play. I'm going to ask the Netty people for a 'wildcard' value to accept all subprotocols, but for now can we change null to "wamp"? This won't affect websocket requests with no protocol header, but it will allow WAMP to function normally.

Thanks!

implicit FieldConstructor and Lang not been passed on in template

If I have a custom helper in /app/helper/userSelect.scala.html

@(field: play.api.data.Field, users: Seq[User], args: (Symbol,Any)*)(implicit handler: FieldConstructor, lang: play.api.i18n.Lang)
@input(field, args:_*) { (id, name, value, htmlArgs) =>
    <select id="@id" name="@name" data-widget="userselect" @args.toMap.get('_default).map { defaultValue => data-placeholder="@defaultValue"} @toHtmlArgs(htmlArgs)>
        <option></option>
        @users.map { user =>
            <option value="@user.id"@(if(user != null && value == Some(user.id.toString)) "selected" else "") data-gravatar="@helper.Gravatar.url(user.email)">@user.name</option>
        }
    </select>
}

If I don't explicitly pass the handler and lang on to the input the default FieldConstructor will be used.

I'm using 2.1-RC1 with java

play test stuck when used with twitterbootstrap

Hi,
If I create a new project and run 'play test' the default tests are run and the tests finish but if I add the twitterbootstrap library:

  • bootstrap.js (v.2.3.1) copied to public/javascripts - added to main.scala.html

then 'play test' hangs. It hangs for the test in IntegrationSpec.scala.

Migrated from http://play.lighthouseapp.com/projects/82401/tickets/1038-play-test-stuck-when-used-with-twitterbootstrap
@Gissues:{"order":69.23076923076917,"status":"backlog"}

[2.1.0] Functional tests will fail if Global communicates with database

Functional test and any subsequent tests will fail with SQLException if Global object talks to database.
Steps to reproduce:

  1. create new app
  2. create Global:
import play.api.db.DB
import play.api.{GlobalSettings, Application}
import play.api.Play.current
import scala.slick.session.Database.threadLocalSession
import slick.session.Database

object Global extends GlobalSettings {
  lazy val db = Database.forDataSource(DB.getDataSource())

  override def onStart(app: Application) {
    db.withSession {
      //...
    }
  }
}
  1. run "play test"
  2. get stacktrace
[info] ApplicationSpec
[info] 
[info] Application should
[info] + send 404 on a bad request
[error] c.j.b.h.AbstractConnectionHook - Failed to acquire connection Sleeping for 1000ms and trying again. Attempts left: 10. Exception: null
[error] c.j.b.ConnectionHandle - Database access problem. Killing off all remaining connections in the connection pool. SQL State = 08001
[error] ! render the index page
[error] c.j.b.PoolWatchThread - Error in trying to obtain a connection. Retrying in 1000ms
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost/test
    at java.sql.DriverManager.getConnection(DriverManager.java:604) ~[na:1.7.0_13]
    at java.sql.DriverManager.getConnection(DriverManager.java:221) ~[na:1.7.0_13]
    at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:256) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.ConnectionHandle.obtainInternalConnection(ConnectionHandle.java:211) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.ConnectionHandle.<init>(ConnectionHandle.java:170) ~[bonecp.jar:0.7.1.RELEASE]
    at com.jolbox.bonecp.PoolWatchThread.fillConnections(PoolWatchThread.java:101) [bonecp.jar:0.7.1.RELEASE]
[error]     SQLException: Attempting to obtain a connection from a pool that has already been shutdown. 
[error] Stack trace of location where pool was shutdown follows:
[error]  java.lang.Thread.getStackTrace(Thread.java:1567)
[error]  com.jolbox.bonecp.BoneCP.captureStackTrace(BoneCP.java:543)
[error]  com.jolbox.bonecp.BoneCP.shutdown(BoneCP.java:159)
[error]  com.jolbox.bonecp.BoneCPDataSource.close(BoneCPDataSource.java:123)
[error]  play.api.db.BoneCPApi.shutdownPool(DB.scala:405)
[error]  play.api.db.BoneCPPlugin$$anonfun$onStop$1.liftedTree1$1(DB.scala:263)
[error]  play.api.db.BoneCPPlugin$$anonfun$onStop$1.apply(DB.scala:262)
[error]  play.api.db.BoneCPPlugin$$anonfun$onStop$1.apply(DB.scala:261)
[error]  scala.collection.immutable.List.foreach(List.scala:309)
[error]  play.api.db.BoneCPPlugin.onStop(DB.scala:261)
[error]  play.api.Play$$anonfun$stop$1$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Play.scala:80)
[error]  play.api.Play$$anonfun$stop$1$$anonfun$apply$1$$anonfun$apply$mcV$sp$2.apply(Play.scala:79)
[error]  scala.collection.immutable.List.foreach(List.scala:309)
[error]  play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply$mcV$sp(Play.scala:79)
[error]  play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply(Play.scala:79)
[error]  play.api.Play$$anonfun$stop$1$$anonfun$apply$1.apply(Play.scala:79)
[error]  play.utils.Threads$.withContextClassLoader(Threads.scala:18)
[error]  play.api.Play$$anonfun$stop$1.apply(Play.scala:78)
[error]  play.api.Play$$anonfun$stop$1.apply(Play.scala:77)
[error]  scala.Option.map(Option.scala:145)
[error]  play.api.Play$.stop(Play.scala:77)
[error]  play.api.test.Helpers$.running(Helpers.scala:42)
[error]  test.ApplicationSpec$$anonfun$1$$anonfun$apply$3.apply(ApplicationSpec.scala:18)
[error]  test.ApplicationSpec$$anonfun$1$$anonfun$apply$3.apply(ApplicationSpec.scala:18)
[error]  org.specs2.mutable.SpecificationFeatures$$anon$1$$anonfun$asResult$1.apply(Specification.scala:34)
[error]  org.specs2.mutable.SpecificationFeatures$$anon$1$$anonfun$asResult$1.apply(Specification.scala:34)
[error]  org.specs2.execute.AsResult$$anon$10.asResult(Result.scala:230)
[error]  org.specs2.execute.AsResult$.apply(Result.scala:238)
[error]  org.specs2.specification.Contexts$$anon$4.apply(Contexts.scala:44)
[error]  org.specs2.mutable.SpecificationFeatures$$anon$1.asResult(Specification.scala:34)
[error]  org.specs2.execute.AsResult$.apply(Result.scala:238)
[error]  org.specs2.specification.Example$$anonfun$apply$1.apply(Fragment.scala:141)
[error]  org.specs2.specification.Example$$anonfun$apply$1.apply(Fragment.scala:141)
[error]  org.specs2.specification.Example.execute(Fragment.scala:104)
[error]  org.specs2.specification.FragmentExecution$$anonfun$1.apply(FragmentExecution.scala:52)
[error]  org.specs2.specification.FragmentExecution$$anonfun$1.apply(FragmentExecution.scala:52)
[error]  org.specs2.execute.ResultExecution$class.execute(ResultExecution.scala:22)
[error]  org.specs2.execute.ResultExecution$.execute(ResultExecution.scala:76)
[error]  org.specs2.specification.FragmentExecution$class.executeBody(FragmentExecution.scala:28)
[error]  org.specs2.runner.TestInterfaceConsoleReporter.executeBody(TestInterfaceRunner.scala:125)
[error]  org.specs2.specification.FragmentExecution$class.execute(FragmentExecution.scala:52)
[error]  org.specs2.runner.TestInterfaceConsoleReporter.execute(TestInterfaceRunner.scala:125)
[error]  org.specs2.specification.FragmentExecution$$anonfun$executeFragment$1$$anonfun$apply$1.apply(FragmentExecution.scala:35)
[error]  org.specs2.specification.FragmentExecution$$anonfun$executeFragment$1$$anonfun$apply$1.apply(FragmentExecution.scala:35)
[error]  org.specs2.control.Exceptions$class.catchAllOr(Exceptions.scala:54)
[error]  org.specs2.control.Exceptions$.catchAllOr(Exceptions.scala:109)
[error]  org.specs2.specification.FragmentExecution$$anonfun$executeFragment$1.apply(FragmentExecution.scala:35)
[error]  org.specs2.specification.FragmentExecution$$anonfun$executeFragment$1.apply(FragmentExecution.scala:35)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$org$specs2$reporter$DefaultExecutionStrategy$$executeSequence$1.apply(ExecutionStrategy.scala:99)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$org$specs2$reporter$DefaultExecutionStrategy$$executeSequence$1.apply(ExecutionStrategy.scala:99)
[error]  scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[error]  scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
[error]  scala.collection.immutable.List.foreach(List.scala:309)
[error]  scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
[error]  scala.collection.AbstractTraversable.map(Traversable.scala:105)
[error]  org.specs2.reporter.DefaultExecutionStrategy$class.org$specs2$reporter$DefaultExecutionStrategy$$executeSequence(ExecutionStrategy.scala:99)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$execute$1$$anonfun$2.apply(ExecutionStrategy.scala:43)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$execute$1$$anonfun$2.apply(ExecutionStrategy.scala:41)
[error]  scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
[error]  scala.collection.TraversableOnce$$anonfun$foldLeft$1.apply(TraversableOnce.scala:144)
[error]  scala.collection.GenTraversableViewLike$Mapped$$anonfun$foreach$2.apply(GenTraversableViewLike.scala:81)
[error]  scala.collection.Iterator$class.foreach(Iterator.scala:727)
[error]  scala.collection.AbstractIterator.foreach(Iterator.scala:1156)
[error]  scala.collection.IterableViewLike$Transformed$class.foreach(IterableViewLike.scala:42)
[error]  scala.collection.SeqViewLike$AbstractTransformed.foreach(SeqViewLike.scala:43)
[error]  scala.collection.GenTraversableViewLike$Appended$class.foreach(GenTraversableViewLike.scala:99)
[error]  scala.collection.SeqViewLike$$anon$2.foreach(SeqViewLike.scala:77)
[error]  scala.collection.GenTraversableViewLike$Mapped$class.foreach(GenTraversableViewLike.scala:80)
[error]  scala.collection.SeqViewLike$$anon$3.foreach(SeqViewLike.scala:78)
[error]  scala.collection.TraversableOnce$class.foldLeft(TraversableOnce.scala:144)
[error]  scala.collection.SeqViewLike$AbstractTransformed.foldLeft(SeqViewLike.scala:43)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$execute$1.apply(ExecutionStrategy.scala:41)
[error]  org.specs2.reporter.DefaultExecutionStrategy$$anonfun$execute$1.apply(ExecutionStrategy.scala:38)
[error]  org.specs2.internal.scalaz.syntax.IdOps$class.$bar$greater(IdOps.scala:15)
[error]  org.specs2.internal.scalaz.syntax.ToIdOps$$anon$1.$bar$greater(IdOps.scala:68)
[error]  org.specs2.reporter.AllExporting$class.report(AllExporting.scala:15)
[error]  org.specs2.runner.TestInterfaceConsoleReporter.report(TestInterfaceRunner.scala:125)
[error]  org.specs2.runner.TestInterfaceRunner.runSpecification(TestInterfaceRunner.scala:61)
[error]  org.specs2.runner.TestInterfaceRunner.run(TestInterfaceRunner.scala:54)
[error]  sbt.ForkMain$Run.runTests(ForkMain.java:157)
[error]  sbt.ForkMain$Run.run(ForkMain.java:169)
[error]  sbt.ForkMain.main(ForkMain.java:84)
[error]  (BoneCPDataSource.java:114)
[error] com.jolbox.bonecp.BoneCP.getConnection(BoneCP.java:467)
[error] com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:114)
[error] Global$.onStart(Global.scala:12)
[error] play.api.GlobalPlugin.onStart(GlobalSettings.scala:175)
[error] play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:63)
[error] play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:63)
[error] play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:63)
[error] play.api.Play$$anonfun$start$1.apply(Play.scala:63)
[error] play.api.Play$$anonfun$start$1.apply(Play.scala:63)
[error] play.utils.Threads$.withContextClassLoader(Threads.scala:18)
[error] play.api.Play$.start(Play.scala:62)
[error] play.api.test.Helpers$.running(Helpers.scala:39)
[error] test.ApplicationSpec$$anonfun$1$$anonfun$apply$7.apply(ApplicationSpec.scala:24)
[error] test.ApplicationSpec$$anonfun$1$$anonfun$apply$7.apply(ApplicationSpec.scala:24)
[info]  
[info]  
[info] Total for specification ApplicationSpec
[info] Finished in 865 ms
[info] 2 examples, 0 failure, 1 error
[info] 
[error] Error: Total 13, Failed 0, Errors 1, Passed 12, Skipped 0
[error] Error during tests:
[error]     test.ApplicationSpec
java.lang.RuntimeException: Tests unsuccessful
    at scala.sys.package$.error(package.scala:27)
    at scala.Predef$.error(Predef.scala:123)
    at sbt.Tests$.showResults(Tests.scala:192)
    at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:296)
    at sbt.Defaults$$anonfun$testTasks$6.apply(Defaults.scala:294)
    at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
    at sbt.Scoped$$anonfun$hf4$1.apply(Structure.scala:580)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
    at sbt.std.Transform$$anon$5.work(System.scala:71)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:238)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)
[error] (test:test) Tests unsuccessful

Exception is thrown on call to db.withSession
If I replace this code with the method call of some instance of some class (this is important, it can't be a static object) that incapsulates the same database communication code, tests pass. Or it can be fixed by moving lazy val db = Database.forDataSource(DB.getDataSource()) inside onStart(...). I would understand the reason of error if db field wasn't lazy, but it is.
@Gissues:{"order":76.92307692307688,"status":"backlog"}

play-functional

There are a number of issues of varying severity with play-functional. Not sure if interested.

I18n default value

Hi, I currently translate my application. I saw something which I find wired.

In application.langs we can set the supported languages of our application. And by default we have a messages file to write our sentences.

The fact is if we don't set values in application.langs, the application has errors because it does not load the default messages file.

And if we say that our application is in english, we load the messages.en file instead of the default messages file except if messages.en doesn't exist.

In my opinion, if we don't declare any language in application.langs, we should load the default messages file.

Is there something I didn't understand about Play! ?

Thanks !

Have a great day :)
@Gissues:{"order":87.17948717948715,"status":"backlog"}

Action method cannot use primitive parameter (int, long,..)

Hello,

If you try to create an action like :

public static Result action(long param) {
    return TODO;
}

and then you route it with :

GET /testAction/:param  controllers.Controller.action(param: Long)

You won't be able to test your action, Play server will reset the connexion. Moreover, Play will not log anything, even with all the logger levels in debug.

What would by good is :

  • Update Play to make it work with primitive parameters

    Or
  • Document this behavior and if possible log an error if someone forget to read the doc

Thank you !

computer-database Ebean sample application throws SQLException on heavy load

The computer-database java sample application of play 2.1.0 demonstrates Ebean ORM. I was surprised by the sub-optimal performance of Ebean compared to the JPA and Anorm versions of the computer-database. Then I noticed that the log shows SQLExceptions on heavy load. I used ApacheBench with concurrency level 4 to benchmark the applications.

These exceptions seem to be related to the PagingList query in the model. When a page of /computers is accessed, Ebeans LimitOffsetPagingQuery.java automatically starts a new background thread to fetch the next page. This thread uses a database connection that can be still alive after the HTTP request was processed. On heavy load, the next request can cause the following exception: java.sql.SQLException: Timed out waiting for a free available connection. This exception occurred on Windows 7 and Ubuntu 12.04 LTS using a H2 memory database and a Postgres database.

The FetchAhead feature in Ebean is useless in stateless web applications. According to Ebean user guide chapter 6.7, FetchAhead must be disabled in stateless applications using setFetchAhead(false). The exceptions disappeared after adding this method to the Computer.java model.

Original model Computer.java[line 49]:

            find.where()
                .ilike("name", "%" + filter + "%")
                .orderBy(sortBy + " " + order)
                .fetch("company")
                .findPagingList(pageSize)
                .getPage(page);

Modified model Computer.java[line 49]:

            find.where()
                .ilike("name", "%" + filter + "%")
                .orderBy(sortBy + " " + order)
                .fetch("company")
                .findPagingList(pageSize)
                .setFetchAhead(false)
                .getPage(page);

PagingList queries are used in the Play Ebean documentation as well. setFetchAhead(false) is omitted in the example. PagingLists are designed for stateful applications. Perhaps it is better to avoid PagingLists altogether and just use setFirstRow() and setMaxRows() on the query.

Exception:

2013-03-19 16:11:36,748 - [ERROR] - from application in play-internal-execution-context-1 
! @6dkcjmn6o - Internal server error, for (GET) [/computers] ->

play.api.Application$$anon$1: Execution exception[[PersistenceException: javax.persistence.PersistenceException: java.sql.SQLException: Timed out waiting for a free available connection.]]
    at play.api.Application$class.handleError(Application.scala:289) ~[play_2.10.jar:2.1.0]
    at play.api.DefaultApplication.handleError(Application.scala:383) [play_2.10.jar:2.1.0]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:132) [play_2.10.jar:2.1.0]
    at play.core.server.netty.PlayDefaultUpstreamHandler$$anon$2$$anonfun$handle$1.apply(PlayDefaultUpstreamHandler.scala:128) [play_2.10.jar:2.1.0]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:113) [play_2.10.jar:2.1.0]
    at play.api.libs.concurrent.PlayPromise$$anonfun$extend$1$$anonfun$apply$1.apply(Promise.scala:104) [play_2.10.jar:2.1.0]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) [scala-library.jar:na]
    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) [scala-library.jar:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.7.0_05]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.7.0_05]
    at java.lang.Thread.run(Unknown Source) [na:1.7.0_05]

Benchmark before change:

ab -c 4 -n 1000 http://localhost:9000/computers
Concurrency Level:      4
Time taken for tests:   95.949 seconds
Complete requests:      1000
Failed requests:        41
   (Connect: 0, Receive: 0, Length: 41, Exceptions: 0)
Write errors:           0
Non-2xx responses:      41
Total transferred:      8903987 bytes
HTML transferred:       8822208 bytes
Requests per second:    10.42 [#/sec] (mean)
Time per request:       383.794 [ms] (mean)
Time per request:       95.949 [ms] (mean, across all concurrent requests)
Transfer rate:          90.62 [Kbytes/sec] received

Benchmark after change:

ab -c 4 -n 1000 http://localhost:9000/computers
Concurrency Level:      4
Time taken for tests:   5.372 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      8998000 bytes
HTML transferred:       8917000 bytes
Requests per second:    186.13 [#/sec] (mean)
Time per request:       21.490 [ms] (mean)
Time per request:       5.372 [ms] (mean, across all concurrent requests)
Transfer rate:          1635.58 [Kbytes/sec] received

Add method to Request class to find out about current protocol

Now that play 2.1 supports https via "-Dhttps.protocol=..", it is rather frustrating that there seems to be no direct way to find out what protocol the request came in with (http vs https) (or maybe i just can't find it).

The class play.mvc.Http.RequestHeader seems like the correct place to also contain a method like getProtocol(). Ideally, i could find out whether the customer is on http or https like that:

Http.Context.current().request().protocol()
=> "http" or "https"
@Gissues:{"order":51.28205128205122,"status":"backlog"}

Coffescript native compiler will never run if requireJs is set

While writing a plugin I came across a google group post mentioning that 2.1 now adds a setting to all options for any AssetCompiler. This seemed strange so I went to look at it in the source and I think I uncovered a bug caused by this behavior in the coffescript asset compiler as a result.

The line of code is here: https://github.com/playframework/Play20/blob/master/framework/src/sbt-plugin/src/main/scala/PlayAssetsCompiler.scala#L52

This will add rjs to the end of the options sequence if the requiredJs key is ever set with a non empty sequence, which you can see in line 23 in the same source file. This extra, unexpected option, will always get passed to any configured asset compiler, I suspected this might cause some bugs and I think I at least found one in the Coffeescript asset compiler.

Line of code is here: https://github.com/playframework/Play20/blob/master/framework/src/sbt-plugin/src/main/scala/coffeescript/CoffeescriptCompiler.scala#L60

The options.size == 2 check will always fail if requireJs is enabled and the native option is set. This means any user setting native coffeescript comipler and using requireJs will have a play project not use the native coffeescript compiler as requested and instead fallback on the Java based one.

I couldn't find a good way to confirm this behavior as this won't cause any failure on play's side, it will compile the coffee files either way. But, if it's not using the native compiler as requested then this is obviously an issue from the users perspective.

enable play.core.StaticApplication to load any environment file

Based on my testing so far, it looks like whatever is passed into StaticApplication's constructor is disregarded in favor of the default application.conf. This approach undermines the advantages that could be leveraged by enabling alternative environments:

  • scripts
  • data manipulation
  • conceptual validation (actors, db, etc.)

One of the key features in both Rails and Grails is strong custom environment support coupled with scripts/console capabilities. Would really love to see the same in Play (now that my team's first major app is out the door, maint ops would sure be helpful to achieve via console abilities).

Apologies if this is a duplicate ticket, wasn't successful finding a similar one in GitHub issues.

play dist is broken in Windows

Windows doesn't have chmod. THat call should be boxed around try-catch, or have some kind of "is chmod available" discovery. Some windows shells have it (cygwin/msys bash) others do not.

Use '? super A' for Function parameter in Promise.map and Promise.flatMap

It's currently not possible to call 'map' or 'flatMap' on a Promise of type Promise<? extends A>.

Changing the signature from

    public <B> Promise<B> map(final Function<A, B> function) 

to

    public <B> Promise<B> map(final Function<? super A, B> function)

would solve the issue without breaking existing code.
'flatMap' should be changed accordingly.

can't handle whitespace in project path

Tested on:

OS X 10.7.5
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode

CentOS
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (rhel-1.50.1.11.5.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Steps to recreate:

  1. download & unzip play: wget http://download.playframework.org/releases/play-2.0.4.zip & unzip play-2.0.4.zip
  2. put a space in the path: mv play-2.0.4 play\ 2.0.4
  3. create new (java or scala) play project: cd play\ 2.0.4 & ./play new project
  4. run project: cd project & ../play run
  5. make request: curl localhost:9000

The following exception is reported:

[error] {file:/home/sw206/play%202.0.4/project/}project/compile:sources: java.lang.ExceptionInInitializerError
[error] application - 

! Internal server error, for request [GET /] ->

play.api.UnexpectedException: Unexpected exception [ExceptionInInitializerError: null]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:240) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:233) ~[na:na]
at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:233) ~[na:na]
at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:231) ~[na:na]
at scala.Either$LeftProjection.map(Either.scala:183) ~[scala-library.jar:0.11.3]
java.lang.ExceptionInInitializerError: null
at play.templates.ScalaTemplateCompiler$TemplateAsFunctionCompiler$.getFunctionMapping(ScalaTemplates.scala:561) ~[templates_2.9.1.jar:2.0.4]
at play.templates.ScalaTemplateCompiler$.generateFinalTemplate(ScalaTemplates.scala:500) ~[templates_2.9.1.jar:2.0.4]
at play.templates.ScalaTemplateCompiler$.compile(ScalaTemplates.scala:189) ~[templates_2.9.1.jar:2.0.4]
at sbt.PlayCommands$$anonfun$53$$anonfun$apply$32.apply(PlayCommands.scala:456) ~[na:na]
at sbt.PlayCommands$$anonfun$53$$anonfun$apply$32.apply(PlayCommands.scala:454) ~[na:na]
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60) ~[scala-library.jar:0.11.3]
Caused by: scala.tools.nsc.MissingRequirementError: object scala not found.
at scala.tools.nsc.symtab.Definitions$definitions$.getModuleOrClass(Definitions.scala:655) ~[scala-compiler.jar:na]
at scala.tools.nsc.symtab.Definitions$definitions$.getModule(Definitions.scala:605) ~[scala-compiler.jar:na]
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackage(Definitions.scala:145) ~[scala-compiler.jar:na]
at scala.tools.nsc.symtab.Definitions$definitions$.ScalaPackageClass(Definitions.scala:146) ~[scala-compiler.jar:na]
at scala.tools.nsc.symtab.Definitions$definitions$.AnyClass(Definitions.scala:176) ~[scala-compiler.jar:na]
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:814) ~[scala-compiler.jar:na]

FakeApplication not picking up the application.conf from the subproject

Hi,

When I test and create a FakeApplication() in subproject, it will load the configuration (conf/application.conf) from the root project.

But I would like to made it load the configuration from my subproject (modules/admin/conf/application.conf).

For example,

app
  └ controllers
  └ models
  └ views
conf
  └ application.conf
  └ routes
modules
  └ admin
    └ conf/admin.routes
    └ conf/application.conf
    └ app/controllers
    └ app/models
    └ app/views

project
 └ build.properties
 └ Build.scala
 └ plugins.sbt

Migrated from http://play.lighthouseapp.com/projects/82401/tickets/1013-FakeApplication-not-picking-up-the-applicationconf-from-the-subproject
@Gissues:{"order":64.10256410256403,"status":"backlog"}

Java - reverse routing and default params NPE

Play 2.0.3
Java

If you have defined a route with some default param values like this:

GET     /api/:platformName/asset/:assetId                       controllers.AssetController.getAsset(platformName, assetId:Int, expand ?= "", includeRelations ?= "")

You get a NPE if you supply nulls for the params with default values like this:

routes.AssetController.getAsset(platformName, otherAssetId, null, null).url();

Workaround:

routes.AssetController.getAsset(platformName, otherAssetId, "", "").url();

Scala version defaults to 2.9.2 in sub projects

When adding a sub-project in Build.scala

val myProject = Project("module1", file("modules/module1")).settings()

and then running 'dependencies' results in unresolved dependencies. E.g. "play#play_2.9.2;2.1.0". It starts looking for the play libraries but for scala version 2.9.2 in stead of 2.10.0

Adding the scala version solves the problem, would be nice to at least mention this in the documentation:

val myProject = Project("module1", file("modules/module1")).settings(
scalaVersion := "2.10.0"
)

@Gissues:{"order":10.2564102564102,"status":"backlog"}

[2.1.0 Regression] Dev-Mode ClassLoader does not contain app classes

In play 2.1.0, our custom logback filter located in our app can't be loaded in dev mode (throwing a ClassNotFoundException). In production mode, it can be loaded. In play 2.0, logback was able to load the filter in both modes.

This is the exception we get in dev mode (reduced context, originally about 50 lines of probably irrelevant stuff):

11:38:21,235 |-ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [filter] of type [de.deviceident.log.MarkerFilter] java.lang.ClassNotFoundException: de.deviceident.log.MarkerFilter
        at java.lang.ClassNotFoundException: de.deviceident.log.MarkerFilter
        at      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at      at java.security.AccessController.doPrivileged(Native Method)
        at      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        at      at sbt.PlayCommands$$anonfun$53$$anonfun$55$$anon$2.loadClass(PlayCommands.scala:535)
        at      at ch.qos.logback.core.util.Loader.loadClass(Loader.java:124)

In dev-mode (via 'sbt run'), the following ClassLoader is used (log message provoked by adding a non-fatal error in the application-logger.xml):

11:38:21,166 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@31eeeaed - The class "ch.qos.logback.core.filter.Filter" was loaded by 
11:38:21,167 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@31eeeaed - [SBT/Play shared ClassLoader, with: WrappedArray(file:/home/ole/projects/ll/di/lib/UASparser-0.3.1.jar, file:/home/ole/projects/ll/di/lib/jregex-1.2_01.jar, file:/home/ole/.sbt/boot/scala-2.10.0/lib/scala-library.jar, file:/home/ole/.ivy2/cache/play/play_2.10/jars/play_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/play/sbt-link/jars/sbt-link-2.1.0.jar, file:/home/ole/.ivy2/cache/org.javassist/javassist/jars/javassist-3.16.1-GA.jar, file:/home/ole/.ivy2/cache/play/play-exceptions/jars/play-exceptions-2.1.0.jar, file:/home/ole/.ivy2/cache/play/templates_2.10/jars/templates_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/com.github.scala-incubator.io/scala-io-file_2.10/jars/scala-io-file_2.10-0.4.2.jar, file:/home/ole/.ivy2/cache/com.github.scala-incubator.io/scala-io-core_2.10/jars/scala-io-core_2.10-0.4.2.jar, file:/home/ole/.ivy2/cache/com.jsuereth/scala-arm_2.10/jars/scala-arm_2.10-1.3.jar, file:/home/ole/.ivy2/cache/play/play-iteratees_2.10/jars/play-iteratees_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/org.scala-stm/scala-stm_2.10.0/jars/scala-stm_2.10.0-0.6.jar, file:/home/ole/.ivy2/cache/com.typesafe/config/bundles/config-1.0.0.jar, file:/home/ole/.ivy2/cache/io.netty/netty/bundles/netty-3.5.9.Final.jar, file:/home/ole/.ivy2/cache/org.slf4j/slf4j-api/jars/slf4j-api-1.6.6.jar, file:/home/ole/.ivy2/cache/org.slf4j/jul-to-slf4j/jars/jul-to-slf4j-1.6.6.jar, file:/home/ole/.ivy2/cache/org.slf4j/jcl-over-slf4j/jars/jcl-over-slf4j-1.6.6.jar, file:/home/ole/.ivy2/cache/ch.qos.logback/logback-core/jars/logback-core-1.0.7.jar, file:/home/ole/.ivy2/cache/ch.qos.logback/logback-classic/jars/logback-classic-1.0.7.jar, file:/home/ole/.ivy2/cache/com.typesafe.akka/akka-actor_2.10/bundles/akka-actor_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/com.typesafe.akka/akka-slf4j_2.10/bundles/akka-slf4j_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.1.jar, file:/home/ole/.ivy2/cache/org.joda/joda-convert/jars/joda-convert-1.2.jar, file:/home/ole/.ivy2/cache/org.apache.commons/commons-lang3/jars/commons-lang3-3.1.jar, file:/home/ole/.ivy2/cache/com.ning/async-http-client/jars/async-http-client-1.7.6.jar, file:/home/ole/.ivy2/cache/oauth.signpost/signpost-core/jars/signpost-core-1.2.1.2.jar, file:/home/ole/.ivy2/cache/commons-codec/commons-codec/jars/commons-codec-1.7.jar, file:/home/ole/.ivy2/cache/oauth.signpost/signpost-commonshttp4/jars/signpost-commonshttp4-1.2.1.2.jar, file:/home/ole/.ivy2/cache/commons-logging/commons-logging/jars/commons-logging-1.1.1.jar, file:/home/ole/.ivy2/cache/org.codehaus.jackson/jackson-core-asl/jars/jackson-core-asl-1.9.10.jar, file:/home/ole/.ivy2/cache/org.codehaus.jackson/jackson-mapper-asl/jars/jackson-mapper-asl-1.9.10.jar, file:/home/ole/.ivy2/cache/net.sf.ehcache/ehcache-core/jars/ehcache-core-2.6.0.jar, file:/home/ole/.ivy2/cache/javax.transaction/jta/jars/jta-1.1.jar, file:/home/ole/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.10.0.jar, file:/home/ole/.ivy2/cache/play/play-test_2.10/jars/play-test_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.1.jar, file:/home/ole/.ivy2/cache/org.specs2/specs2_2.10/jars/specs2_2.10-1.13.jar, file:/home/ole/.ivy2/cache/org.specs2/scalaz-core_2.10/jars/scalaz-core_2.10-7.0.0.jar, file:/home/ole/.ivy2/cache/org.specs2/scalaz-concurrent_2.10/jars/scalaz-concurrent_2.10-7.0.0.jar, file:/home/ole/.ivy2/cache/org.specs2/scalaz-effect_2.10/jars/scalaz-effect_2.10-7.0.0.jar, file:/home/ole/.ivy2/cache/com.novocode/junit-interface/jars/junit-interface-0.9.jar, file:/home/ole/.ivy2/cache/junit/junit-dep/jars/junit-dep-4.8.2.jar, file:/home/ole/.ivy2/cache/org.scala-tools.testing/test-interface/jars/test-interface-0.5.jar, file:/home/ole/.ivy2/cache/org.fluentlenium/fluentlenium-festassert/jars/fluentlenium-festassert-0.7.3.jar, file:/home/ole/.ivy2/cache/org.fluentlenium/fluentlenium-core/jars/fluentlenium-core-0.7.3.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-java/jars/selenium-java-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-android-driver/jars/selenium-android-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-remote-driver/jars/selenium-remote-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/cglib/cglib-nodep/jars/cglib-nodep-2.1_3.jar, file:/home/ole/.ivy2/cache/org.json/json/jars/json-20080701.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-api/jars/selenium-api-2.25.0.jar, file:/home/ole/.ivy2/cache/com.google.guava/guava/jars/guava-12.0.jar, file:/home/ole/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-1.3.9.jar, file:/home/ole/.ivy2/cache/org.apache.httpcomponents/httpclient/jars/httpclient-4.1.2.jar, file:/home/ole/.ivy2/cache/org.apache.httpcomponents/httpcore/jars/httpcore-4.1.3.jar, file:/home/ole/.ivy2/cache/org.apache.commons/commons-exec/jars/commons-exec-1.1.jar, file:/home/ole/.ivy2/cache/net.java.dev.jna/jna/jars/jna-3.4.0.jar, file:/home/ole/.ivy2/cache/net.java.dev.jna/platform/jars/platform-3.4.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-chrome-driver/jars/selenium-chrome-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-htmlunit-driver/jars/selenium-htmlunit-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/net.sourceforge.htmlunit/htmlunit/jars/htmlunit-2.9.jar, file:/home/ole/.ivy2/cache/xalan/xalan/jars/xalan-2.7.1.jar, file:/home/ole/.ivy2/cache/xalan/serializer/jars/serializer-2.7.1.jar, file:/home/ole/.ivy2/cache/xml-apis/xml-apis/jars/xml-apis-1.3.04.jar, file:/home/ole/.ivy2/cache/commons-collections/commons-collections/jars/commons-collections-3.2.1.jar, file:/home/ole/.ivy2/cache/commons-lang/commons-lang/jars/commons-lang-2.6.jar, file:/home/ole/.ivy2/cache/org.apache.httpcomponents/httpmime/jars/httpmime-4.1.2.jar, file:/home/ole/.ivy2/cache/net.sourceforge.htmlunit/htmlunit-core-js/jars/htmlunit-core-js-2.9.jar, file:/home/ole/.ivy2/cache/xerces/xercesImpl/jars/xercesImpl-2.9.1.jar, file:/home/ole/.ivy2/cache/net.sourceforge.nekohtml/nekohtml/jars/nekohtml-1.9.15.jar, file:/home/ole/.ivy2/cache/net.sourceforge.cssparser/cssparser/jars/cssparser-0.9.5.jar, file:/home/ole/.ivy2/cache/org.w3c.css/sac/jars/sac-1.3.jar, file:/home/ole/.ivy2/cache/commons-io/commons-io/jars/commons-io-2.0.1.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-firefox-driver/jars/selenium-firefox-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-ie-driver/jars/selenium-ie-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-iphone-driver/jars/selenium-iphone-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-safari-driver/jars/selenium-safari-driver-2.25.0.jar, file:/home/ole/.ivy2/cache/org.webbitserver/webbit/jars/webbit-0.4.6.jar, file:/home/ole/.ivy2/cache/org.seleniumhq.selenium/selenium-support/jars/selenium-support-2.25.0.jar, file:/home/ole/.ivy2/cache/org.easytesting/fest-assert/jars/fest-assert-1.4.jar, file:/home/ole/.ivy2/cache/org.easytesting/fest-util/jars/fest-util-1.1.6.jar, file:/home/ole/.ivy2/cache/org.mongodb/casbah-commons_2.10/jars/casbah-commons_2.10-2.5.0.jar, file:/home/ole/.ivy2/cache/com.github.nscala-time/nscala-time_2.10/jars/nscala-time_2.10-0.2.0.jar, file:/home/ole/.ivy2/cache/org.mongodb/mongo-java-driver/jars/mongo-java-driver-2.10.1.jar, file:/home/ole/.ivy2/cache/org.mongodb/casbah-core_2.10/jars/casbah-core_2.10-2.5.0.jar, file:/home/ole/.ivy2/cache/org.mongodb/casbah-query_2.10/jars/casbah-query_2.10-2.5.0.jar, file:/home/ole/.ivy2/cache/org.mongodb/casbah-gridfs_2.10/jars/casbah-gridfs_2.10-2.5.0.jar, file:/home/ole/.ivy2/cache/net.sf.opencsv/opencsv/jars/opencsv-2.1.jar, file:/home/ole/.ivy2/cache/com.typesafe.play.plugins/play-statsd_2.10/jars/play-statsd_2.10-2.1.0.jar, file:/home/ole/.ivy2/cache/com.github.scopt/scopt_2.10/jars/scopt_2.10-2.1.0.jar), using parent: Common ClassLoader: ] whereas object of type

as you can see, the target/scala-2.10/classes dir is not on the classpath.

In prod-mode (via 'sbt start'), the following ClassLoader is used:

11:14:49,241 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@4f2d26d2 - The class "ch.qos.logback.core.filter.Filter" was loaded by 
11:14:49,241 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@4f2d26d2 - [sun.misc.Launcher$AppClassLoader@3326b249] whereas object of type 
11:14:49,241 |-ERROR in ch.qos.logback.core.joran.util.PropertySetter@4f2d26d2 - "ch.qos.logback.classic.turbo.MarkerFilter" was loaded by [sun.misc.Launcher$AppClassLoader@3326b249].

and the filter loads fine and does its job.

This is an example of how we define the filter in our application-logger.xml:

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <filter class="de.di.log.MarkerFilter">
      <Marker>PERFORMANCE</Marker>
      <OnMatch>DENY</OnMatch>
    </filter>
    <encoder>
      <pattern>%date %coloredLevel %marker %logger\n%message%n%xException{5}\n</pattern>
    </encoder>
  </appender>

We have a couple of these filters in different appenders.

More info here: http://play.lighthouseapp.com/projects/82401/tickets/1023-210-Regression-Dev-Mode-ClassLoader-does-not-contain-app-classes
@Gissues:{"order":94.87179487179486,"status":"backlog"}

PropertiesEnhancer doesn't work when multiple setter exists

A simple Java class in a Play project fails to compile (DuplicateMemberException) due to the way sbt-link's PropertiesEnhancer is implemented:

class Test {
  public int ByteBuffer value;
  // ...
  public byte [] getValue() { return value.array(); }
  public Test setValue(byte [] value) { return setValue(ByteBuffer.wrap(value)); }
  public Test setValue(ByteBuffer buffer) { this.value = value; return this; }
}

This kind of Java code gets automatically generated by Apache Thrift for instance. It's not an option to rewrite the class in question and it's a valid Java code anyway.

After investigating the method PropertiesEnhancer.generateAccessors() I found a way to solve the issue by explicitly asking for a setter with one parameter of the same type as the property being "enhanced":

line 97: CtMethod ctMethod = ctClass.getDeclaredMethod(setter, new CtClass [] { ctField.getType() });

instead of (currently):

line 97: CtMethod ctMethod = ctClass.getDeclaredMethod(setter);

It's quite wrong to assume that only one "setXyz" method exist in a given class. It solves the compilation error and I haven't noticed any drawbacks so far. Though I am not 100% sure what is the purpose of the property enhancer in the Play framework so I can't guarantee that this fix won't break other use cases.

Cheers.
@Gissues:{"order":89.74358974358972,"status":"backlog"}

Comet.onDisconnected() callback is never getting called

Like in the link below, this issue is never really solved and I don't know why. Any reasons why not?

http://play.lighthouseapp.com/projects/82401/tickets/654-cometondisconnected-callback-is-never-executed

Anyway, in version 2.1 (Java), the onDisconnected() callback won't get called which keeps the server sending messages to disconnected clients, which isn't very useful, especially when a lot of users connect to the server.

Example:

public static Result comet() {
Comet comet = new Comet("parent.cometMessage") {
@OverRide
public void onConnected() {
sendMessage("Connected");
}
@OverRide
public void onDisconnected(Callback0 arg0) {
// Never gets called
System.out.println("Disconnected");
}
};

return ok(comet);

}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.