sbt / sbt-atmos

sbt plugin for running Typesafe Console in development
98 stars 11 forks source link

Classpath not recreated on forked JVM/Cannot access Config when using atmos:run #10

Closed levinotik closed 11 years ago

levinotik commented 11 years ago

Some background info on my app's dependencies:

val scalaVersion = "2.10.2" val akkaVersion = "2.2.1" val atmosAkkaVersion = "2.2.0" val atmosVersion = "1.2.0"

My app has a config directory with several subfolders containing alternate application.conf files. When I run my app, I pass the desired config directory as an argument to the run script (as a way of loading different configs). Anyhow, when I run the app using atmos:run instead of a plain run things seem to go berzerk. The simplest symptom is that when I try grabbing a simple String from my config, I get a com.typesafe.config.ConfigException$Missing: No configuration setting found for key.. So I CAN access my config when I use run but NOT when I use atmos:run.

I don't know if my title for this issue is accurate, but it seems like the issue could be the fact then when a JVM is forked for my app in order to allow the typesafe console to monitor it, the classpath is not being recreated correctly.

levinotik commented 11 years ago

I should point out that I CAN read from the config file that I've placed in src/main/resources/ but I cannot read any values that I've placed in myapp/config/somefolder/some.conf. The latter case works just fine with a regular run though.

pvlugter commented 11 years ago

Hi Levi. Yes, the sbt-atmos plugin creates a new classpath, based on a different ivy configuration that also includes the trace jars. It does this for dependency resolution of akka and play dependencies, between the application's versions and the versions supported by atmos.

As a workaround, if you're changing the classpath through sbt settings, you can apply the same changes to the atmos classpath. Use similar changes but scoped to classpaths in Atmos. You can see the classpath that sbt-atmos creates with show atmos:full-classpath.

If you can create a sample application that demonstrates what you want to do, I can work from that and think about how to improve this in future versions.

levinotik commented 11 years ago

Thank you for the prompt reply @pvlugter. I'm trying to add my unmanagedClassPath stuff to an Atmos scope, but when I try that SBT complains about references to undefined settings. Do you know how I can resolve this?

levinotik commented 11 years ago

Nevermind, I mistakenly placed it in the wrong part of my build definition. Adding that didn't seem to help. I will work on creating a project that hopefully recreates the issue I'm seeing.

levinotik commented 11 years ago

Also, I don't setting/task for atmos:full-classpath. I see classpath, but not full-classpath

levinotik commented 11 years ago

My bad, looks like that was because I was using 0.1.2!

pvlugter commented 11 years ago

@levinotik, if you've been adding a config directory with something like:

unmanagedClasspath in Runtime <+= baseDirectory map { bd => Attributed.blank(bd / "config") }

adding to the unmanaged classpath in runtime. This should now be supported in the latest version of sbt-atmos (0.3.0).

You can also add to the unmanagedClasspath in Atmos if needed, but this now defaults to the unmanagedClasspath in Runtime.

Let us know if you still have problems with the classpath.