We've been using the "deploy fat jars, restart processes" philosophy
with all of our apps for simplicity. It was working well with Akka 1.x
but we're now running into this reference.conf issue with Akka 2.0.
I'll try to convince sbt assembly plugin to generate the single
overall reference.conf file and include it in the fat jar.
Or is it more recommended to use the Microkernel instead of fat jars?
Thanks,
Zach
On Thu, Feb 2, 2012 at 12:50 AM, Patrik Nordwall
<patrik....@gmail.com> wrote:
> You have already found the other thread that is the best way to solve it, if
> fat jar is to be used. The problem is that all reference.conf files are not
> know at akka build time, since additional modules can have their own. So the
> reference.conf files must be merged at application build time. I don't know
> how that works together with that specific plugin. May I ask why you need to
> use fat jar?
>
>
> On Thu, Feb 2, 2012 at 6:37 AM, Zach Cox <zco...@gmail.com> wrote:
>>
>> Hi - I have a very simple app using 2.0-M3 to test out remote actors,
>> using the same .conf settings as the Remoting docs. If I just sbt run the
>> app, or if I use sbt console, then everything works great. But when I sbt
>> assembly up a fat jar and run the app using java -jar, I get exceptions
>> about missing config settings, like this:
>>
>> Exception in thread "main" com.typesafe.config.ConfigException$Missing: No
>> configuration setting found for key 'akka.remote.failure-detector.threshold'
>>
>> If I add akka.remote.failure-detector.threshold into application.conf,
>> then I just get another exception about a different missing setting.
>>
>> I'm guessing that multiple resource.conf files are conflicting in the fat
>> jar, as in this thread:
>>
>>
>> https://groups.google.com/forum/#!searchin/akka-user/conf$20jar/akka-user/P6QkNsYEw5c/7OZuwEsXseIJ
>>
>> I'm not really seeing how to use the solution in that thread with the sbt
>> 0.7 assembly plugin. Is there any standard procedure for creating fat jars
>> with Akka 2.0 to avoid this resource.conf conflict problem?
>>
>> Thanks,
>> Zach
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Akka User List" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/akka-user/-/1kNgEk5098EJ.
>> To post to this group, send email to akka...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> akka-user+...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/akka-user?hl=en.
>
>
>
>
> --
>
> Patrik Nordwall
> Typesafe - The software stack for applications that scale
> Twitter: @patriknw
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To post to this group, send email to akka...@googlegroups.com.
> To unsubscribe from this group, send email to
> akka-user+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/akka-user?hl=en.
2 feb 2012 kl. 16:21 skrev Zach Cox <zco...@gmail.com>:
> Could reference.conf files be located further down the package dir
> structure to avoid conflicts? /akka/actor/reference.conf,
> /akka/remote/reference.conf, etc?
Those locations are not known. The design reason for having a predefined location is to be able to support modules which add their own config, with default values (reference.conf).
>
> We've been using the "deploy fat jars, restart processes" philosophy
> with all of our apps for simplicity. It was working well with Akka 1.x
> but we're now running into this reference.conf issue with Akka 2.0.
>
> I'll try to convince sbt assembly plugin to generate the single
> overall reference.conf file and include it in the fat jar.
It is possible to load them and write the merged to a new file.
>
> Or is it more recommended to use the Microkernel instead of fat jars?
Personally I prefer explicit jar files with version numbers so I know exactly what is running.
To Josh's points, it would be awesome to just make this a non-issue
somehow. But at the least, maybe there should be a section in
http://akka.io/docs/akka/2.0-M3/intro/deployment-scenarios.html that
describes this fat jar issue as well as configuration for the various
sbt (and maven?) fat jar plugins to generate the one big
reference.conf and get it included in the fat jar.
Thanks,
Zach
On Thu, Feb 2, 2012 at 10:16 AM, Patrik Nordwall
I'm open to solutions.
V
Thanks,
Zach
In some dir /path/to/your/conf put these files:
- application.conf that has whatever custom conf your app needs
- reference.conf that contains all the individual reference.conf your app needs
First line of application.conf:
include "reference"
$ java -Dconfig.file=/path/to/your/conf/application.conf -jar
/path/to/your/fat.jar
That seems to load both the .conf files in /path/to/your/conf, so you
get all the defaults from reference.conf as well as your custom
application.conf.
So this seems to allow both a single fat jar as well as external akka
.conf files. Again, this is with 2.0-M3.
Here's another question: if the Microkernel includes all akka jars,
isn't any app deployed in Microkernel loading up every possible
reference.conf file? If so, then why not just have akka-actor.jar have
one single reference.conf with all of those default config settings
already in it?
Badass it is...
--
Jonas Bonér
CTO
Typesafe - The software stack for applications that scale
Phone: +46 733 777 123
Twitter: @jboner
Blog: letitcrash.com
I agree it is brittle to build that fat reference.conf by hand. I'll have to rebuild it whenever 1) we add/remove akka dependencies, or 2) we upgrade to a newer akka version.
However, so far I have not been able to convince the sbt assembly plugin, either in sbt 0.7 or 0.11.2, to merge all of the reference.conf files from my project's dependencies and use that in the fat jar.
I would love more than anything for someone to prove me wrong by
posting code samples to the mailing list. :) #hinthint
At this point we have to move forward with using a manually-generated
fat reference.conf file. Got these deadlines.
This would not be an issue if every module used a unique name for its
default config file, like reference-{module}.conf. Why again is this
not possible?
Thanks,
Zach
4 feb 2012 kl. 06:52 skrev Zach Cox <zco...@gmail.com>:
> After sinking 2 days into this, I have reached the conclusion that 1)
> the sbt assembly plugin, in its current state, is incapable of
> including a generated fat reference.conf file in the fat jar, and 2)
> sbt may not even be capable of generating that fat reference.conf
> using the jars in the project's dependencies.
>
> I would love more than anything for someone to prove me wrong by
> posting code samples to the mailing list. :) #hinthint
>
> At this point we have to move forward with using a manually-generated
> fat reference.conf file. Got these deadlines.
>
> This would not be an issue if every module used a unique name for its
> default config file, like reference-{module}.conf. Why again is this
> not possible?
If the locations are not known the config library doesn't know from where to load them. Now it loads all /reference.conf from all jars/directories/whatever in classpath and merges them in run/parse time.
Could the config library load all /reference-*.conf files?
>> This would not be an issue if every module used a unique name for itsCould the config library load all /reference-*.conf files?
>> default config file, like reference-{module}.conf. Why again is this
>> not possible?
>
> If the locations are not known the config library doesn't know from where to load them. Now it loads all
> /reference.conf from all jars/directories/whatever in classpath and merges them in run/parse time.
On Sat, Feb 4, 2012 at 8:50 AM, Zach Cox <zco...@gmail.com> wrote:
>>> This would not be an issue if every module used a unique name for its
>>> default config file, like reference-{module}.conf. Why again is this
>>> not possible?
>>
>> If the locations are not known the config library doesn't know from where to load them. Now it loads all
>> /reference.conf from all jars/directories/whatever in classpath and merges them in run/parse time.
>
> Could the config library load all /reference-*.conf files?
>
(belatedly reading this thread)
The reason it can't load /reference-*.conf is that the Java
ClassLoader class doesn't have a "list directory" feature. You can
only load things by name, not enumerate which things exist.
However, it does have a way to load all things with the name
/reference.conf, if there are multiple. So that's what the config
library does.
There are hacks out there to "list directory" on the classpath but
they are really ugly stuff (ugly like: locate the jar files and unpack
them manually, puke entirely on custom classloaders).
Another thought, maybe more related to the older thread: there is no
need to use the config library to merge multiple reference.conf. A
simple textual concatenation should work fine, I think. The only trick
is that in theory, the order could matter (you might want each
dependency's reference.conf to appear before the reference.conf of the
jar depending on the dependency, in case one overrides the other). In
practice I bet the order doesn't matter for any of the actual
reference.conf out there, since having your reference.conf redefine
stuff from another one is sort of kooky.
So, the plugins that build fat jars could do something very simple I
think: concat all the reference.conf, in dependency order for bonus
points, and put the result in the fat jar. Or more generally, for any
*.conf, if they have the same name, concat them.
This also eliminates the issues with having system props in the merged
config and so on.
Hmm: well, I thought of one exception. If the .conf file has root
braces {} (begins and ends with { and }), then concat would not work.
However, you could just send pull requests to anyone who pointlessly
specifies root braces, since they are completely optional clutter in
the .conf format. The assembly plugins could maybe pretty easily check
for a brace as first thing in the file, the only trick is to skip both
"#" and "//" comments, and all whitespace, that may appear before the
opening brace. If there's no opening brace then there can't be a close
brace, so it's only necessary to check for an initial brace. If root
braces are found it could either be an error or they can just be
stripped off.
Havoc
Another thought, maybe more related to the older thread: there is no
need to use the config library to merge multiple reference.conf. A
simple textual concatenation should work fine, I think. The only trick
is that in theory, the order could matter (you might want each
dependency's reference.conf to appear before the reference.conf of the
jar depending on the dependency, in case one overrides the other). In
practice I bet the order doesn't matter for any of the actual
reference.conf out there, since having your reference.conf redefine
stuff from another one is sort of kooky.
On Tue, Feb 7, 2012 at 9:44 PM, Josh Marcus <jma...@azavea.com> wrote:
> It's actually the case that my library *does* currently redefine
> configuration parameters. I'm using your config file library, and users of
> my library can override parameters using their own application.conf. But I
> have akka configuration parameters that I need to set for all users, so I
> override akka configuration in my library's reference.conf. Do you have an
> alternate suggestion?
>
Without knowing the particulars, you may be able to use the "lift a
subtree" approach.
Say your library is "foo", do this:
foo {
akka {
// your akka stuff here, matching akka's normal config file
}
// your other foo-specific settings
whatever = something
bar = baz
}
Now, copying the simple-lib example,
https://github.com/typesafehub/config/blob/master/examples/simple-lib/src/main/scala/simplelib/SimpleLib.scala
you might have a constructor for your library's main object or
whatever that takes a Config. In there you lift up your foo-specific
akka config and then provide it to Akka:
class FooContext(config: Config) {
val system = new ActorSystem("Foo",
config.getConfig("foo").withFallback(config))
}
That is the general idea anyway. So foo.akka.* is now just akka.*, for
purposes of your ActorSystem. But for someone else's actor system, you
won't be messing with akka.*
Also, in application.conf, people can now separately configure akka.*
and foo.akka.* depending on their intent.
One somewhat lame feature of the above is that foo.whatever and
foo.akka were both "lifted out" by getConfig("foo"), so in the final
config, a toplevel "whatever" exists identical to "foo.whatever",
which is namespace pollution. Not the end of the world but could cause
trouble. At the moment you'd have to fix that by hand-building a
Config object containing foo.akka as just akka, and I don't think
there's a very nice API for that in the config lib. It might be nice
to have a Config.filter or other API in the library that would fix
this, in Scala it could be
config.getConfig("foo").filter({ kv => kv._1 == "akka" })
but since it's a Java library I'm not sure. Maybe just a hardcoded
"filterPath(String pathToKeep)" kind of thing, or just methods to add
parent/child nodes.
val akkaOverrides = ConfigFactory.empty().put("akka", getConfig("foo.akka"))
("put" doesn't work since it conflicts with j.u.Map though)
Another thing that could be tricky in the above pattern is that system
properties are in "config" already, so if someone specifies a system
property -Dakka.something, but in the config file there's a
foo.akka.something, the foo.akka.something will always end up
overriding the -Dakka.something for purposes of library foo. Whether
this is a bug or a feature probably varies by context. You could
change the behavior by adding the overrides again on top:
ConfigFactory.defaultOverrides().withFallback(config.getConfig("foo").withFallback(config))
I'm not sure whether to suggest doing that or not, fortunately it
probably doesn't matter that much in practice.
This is a pattern I'm hoping will work well, since we had it in mind
when designing the config lib. But if it doesn't maybe we will need
more ideas...
Havoc
On Tue, Feb 7, 2012 at 10:37 PM, Havoc Pennington <h...@pobox.com> wrote:
> One somewhat lame feature of the above is that foo.whatever and
> foo.akka were both "lifted out" by getConfig("foo"), so in the final
> config, a toplevel "whatever" exists identical to "foo.whatever",
> which is namespace pollution.
An alternative solution to this is:
foo {
actor-system.akka {
}
}
config.getConfig("foo.actor-system").withFallback(config)
i.e. introduce a superfluous "actor-system" node just so you have a
"clean" node containing the "akka" node.
Havoc
To address the below issue I got around to adding withOnlyPath,
withoutPath methods to Config, in the master branch:
https://github.com/typesafehub/config
Havoc
--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.
nothing urgent it's just a nice to have API addition related to the earlier thread.though, there's also a serialization fix on master so it might be good to update Akka's copy.
On Tue, Feb 21, 2012 at 12:58 AM, Havoc Pennington <havoc.pe...@gmail.com> wrote:nothing urgent it's just a nice to have API addition related to the earlier thread.though, there's also a serialization fix on master so it might be good to update Akka's copy.We updated it just prior to RC1 (last tuesday)
On Tue, Feb 21, 2012 at 12:58 AM, Havoc Pennington <havoc.pe...@gmail.com> wrote:
nothing urgent it's just a nice to have API addition related to the earlier thread.though, there's also a serialization fix on master so it might be good to update Akka's copy.We updated it just prior to RC1 (last tuesday)this is a new fix since then. a couple of serialVersionUID were missing.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---You received this message because you are subscribed to the Google Groups "Akka User List" group.To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/p6C0Stlgbe0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
--
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.