Incerteza
Incerteza

Reputation: 34914

Unable to make Global class work properly

I keep facing to the same error at runtime again and again:

Cannot initialize the custom Global object (%s) (perhaps it's a wrong reference?)
In me/myapp/conf/application.conf at line 5.
application.global=common.Global

Where

package common

object Global extends GlobalSettings {
  //...
}

I use Global in a Contoller's action, by the way.

And oddly enough, if I comment out the line application.global=common.Global in /conf/application.conf

# application.global=common.Global  

then the error will disappear.

I'm using Scala 2.10.3, Play 2.1.3 and sbt.version=0.12.4

//project/build.properties
sbt.version=0.12.4


//project/Build.scala
object ApplicationBuild extends Build {
  //.....
  lazy val buildSettings = Seq(
    organization := "myapp",
    version := "1.0-SNAPSHOT123",
    scalaVersion := "2.10.3"
  )
}



//project/plugins.sbt

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository 
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.3")

Your thoughts?

Upvotes: 0

Views: 1312

Answers (2)

Chris Beach
Chris Beach

Reputation: 4392

Also may relate to this issue with circular references from app configuration calls:

https://github.com/playframework/playframework/issues/883

Upvotes: 0

biesior
biesior

Reputation: 55798

Make sure your common package is placed inside of app folder and/or check for typos in names. Works like a charm.

Error disappears because it's default behaviour of Play - if there's no Global object in default path it just considers that doesn't exists at all.

Upvotes: 3

Related Questions