Search code examples
postgresqlscalah2slickakka-http

Message 'No configuration setting found for key' Akka-Http


In my project, I can compile and run without problems, my project is a project in akka-http and I provide services of type json, but when calling the service this error appears:

> run
[info] Running net.claritysales.api.Main
[DEBUG] [11/02/2017 11:08:32.360] [run-main-0] [EventStream(akka://default)] logger log1-Logging$DefaultLogger started
[DEBUG] [11/02/2017 11:08:32.361] [run-main-0] [EventStream(akka://default)] Default Loggers started
[DEBUG] [11/02/2017 11:08:33.253] [run-main-0] [AkkaSSLConfig(akka://default)] Initializing AkkaSSLConfig extension...
[DEBUG] [11/02/2017 11:08:33.258] [run-main-0] [AkkaSSLConfig(akka://default)] buildHostnameVerifier: created hostname verifier: com.typesafe.sslconfig.ssl.DefaultHostnameVerifier@5160a3bd
[DEBUG] [11/02/2017 11:08:34.687] [default-akka.actor.default-dispatcher-5] [akka://default/system/IO-TCP/selectors/$a/0] Successfully bound to /127.0.0.1:9000
[DEBUG] [11/02/2017 11:08:40.607] [default-akka.actor.default-dispatcher-5] [akka://default/system/IO-TCP/selectors/$a/0] New connection accepted
[ERROR] [11/02/2017 11:08:41.795] [default-akka.actor.default-dispatcher-5] [akka.actor.ActorSystemImpl(default)] Error during processing of request: 'No configuration setting found for key 'c
ors''. Completing with 500 Internal Server Error response.
[ERROR] [11/02/2017 11:08:43.467] [default-akka.actor.default-dispatcher-5] [akka.actor.ActorSystemImpl(default)] Error during processing of request: 'No configuration setting found for key 'c
ors''. Completing with 500 Internal Server Error response.
[DEBUG] [11/02/2017 11:09:49.232] [default-akka.actor.default-dispatcher-5] [akka://default/user/StreamSupervisor-0/flow-1-0-unknown-operation] Aborting tcp connection to /127.0.0.1:64741 beca
use of upstream failure: HTTP idle-timeout encountered, no bytes passed in the last 1 minute. This is configurable by akka.http.[server|client].idle-timeout.

since insomnia this appears:

enter image description here

My application.conf is:

akka {
  loglevel = DEBUG
}

http {

  interface = "localhost"
  interface = ${?HTTP_INTERFACE}
  port = 9000
  port = ${?HTTP_PORT}

}

database = {
     cs {
         profile = "slick.jdbc.PostgresProfile$"
       db {
         url = "jdbc:postgresql://localhost:5432/cs2_company"
         url = ${?PSQL_URL}
         user = "postgres"
         user = ${?PSQL_USER}
         password = "qwerty"
         password = ${?PSQL_PASSWORD}
       }
     }
}

I read my configuration from a trait called Config, it has:

 package net.cs.api.utils

import com.typesafe.config.ConfigFactory

trait Config {
  private val config = ConfigFactory.load()
  private val httpConfig = config.getConfig("http")
  private val databaseConfig = config.getConfig("database.cs")

  val httpHost = httpConfig.getString("interface")
  val httpPort = httpConfig.getInt("port")

  val jdbcUrl = databaseConfig.getString("db.url")
  val dbUser = databaseConfig.getString("db.user")
  val dbPassword = databaseConfig.getString("db.password")
}

additionally I have another application.conf file in the test resources, because I want to perform the tests with H2 and execute the application with Postgres

enter image description here

My application.conf for the test is:

akka {
  loglevel = WARNING
}

database = {
  cs {
    profile = "slick.jdbc.H2Profile$"
    db {
      driver = "org.h2.Driver"
      url = "jdbc:h2:mem:cs2_company;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;IGNORECASE=TRUE;DATABASE_TO_UPPER=false"
      url = ${?PSQL_TEST_URL}
      user = "sales"
      user = ${?PSQL_TEST_USER}
      password = "sales"
      password = ${?PSQL_TEST_PASSWORD}
    }
  }
}

What is the error? any help I would appreciate it. Thanks!


Solution

  • it seems that something was looking for a key called cors in the configuration and can not find it, in my configuration I added:

      cors.allowed-origin = "*"
    

    everything works!