Re: [akka-user] Akka config file with a jar used as dependency

51 views
Skip to first unread message

Dragisa Krsmanovic

unread,
Jun 9, 2015, 1:07:30 PM6/9/15
to akka...@googlegroups.com
Akka uses Typesafe config.

You should rename application.conf  to reference.conf in you library to allow user of your library to override configuration. Typesafe config automatically includes all reference.conf and application.conf it finds in the classpath. With the later having precedence.


On Tue, Jun 9, 2015 at 9:55 AM Maatary Okouya <maatar...@gmail.com> wrote:
Hi, 

I'm developing a lib that use akka. When the main program that will use my lib will run, how to make sure that the application.conf that is inside my lib is actually used ?

I have a red the configuration topic of the doc, but i think i need more detail to understand how an actor system fetch for configuration. 


Although i am clear on how it would work in a standalone application, it is less clear how that will work, when integrated to a Web app of the Tomcat model.  That is, my app is in tomcat, and my lib is about to be an external dependency of the app. I have trouble with how to manage the config file. Can it be shipped with my lib, shall the webapp define a new one, if so, where should it be set (with respect to the TomCat webapp model i.e. its resource folder). 

When developing my lib, obviously application.conf is in the src/resource folder, and therefore get added at the head of the jar.


What happens, if no config file is provided ? is there some hardwired default value ? 

When the web-app is started, would the Actor system magically look for the application.conf that is in my jar ? 


I think to a certain degree there is the more general question of understanding what happens to libs that get shipped with their default configuration in their jar. 

I hope some can give me some heads up on that. 


Many thanks,

Daniel

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> 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/d/optout.

Maatary Okouya

unread,
Jun 9, 2015, 2:42:58 PM6/9/15
to akka...@googlegroups.com
Thanks for the tip. 

I'm readying the typeSafe config doc now. 

However i am confused between what is said in akka doc and typesafe doc. 

When fetching config file in the classpath, does it only fetch what is at the root or in all folder in the classpath such as inside jars ?

Concerning your advise, it is indeed in line with what is said in the doc of typesafe. However i'm curious to understand what would happen. Akka as a reference conf, if my application add a reference conf, what will happen? Presumably from what i red, a merge, but what value is taken from my app, vs akka. More generally what is the merge strategy when there are multiple reference.conf. 

Best
M

Dragisa Krsmanovic

unread,
Jun 9, 2015, 3:51:45 PM6/9/15
to akka...@googlegroups.com
If there are multiple reference.conf files in class path, there is no way to predict in which order Typesafe config will read these files.

It's important to namespace your custom configuration so there is no chance of some other library stepping over your settings.


Guido Medina

unread,
Jun 9, 2015, 5:10:02 PM6/9/15
to akka...@googlegroups.com
The class loader effect, precedence, naming and how to load a custom configuration is very well explained at the end of the Akka documentation general section:


HTH

Brian Topping

unread,
Jun 10, 2015, 5:11:15 AM6/10/15
to akka...@googlegroups.com
Hi Daniel,

What have you tried so far? What specifically isn't working?

Two documentation sources that you'll want to be familiar with are http://doc.akka.io/docs/akka/2.3.0/general/configuration.html and  https://github.com/typesafehub/config. You'll note the first one covers the difference between "application.conf" and "reference.conf", the latter for loaded libraries. That seems appropriate for your usage.

I haven't run an ActorSystem from within a J2EE webapp, but I can't imagine that it would have any problem running like that. If you have problems discovering the configuration because of classpath issues, you could build the configuration yourself and pass it to the ActorSystem instantiation. 

Hope that helps some... Brian
signature.asc

Patrik Nordwall

unread,
Jun 15, 2015, 10:50:59 AM6/15/15
to akka...@googlegroups.com
A library should use reference.conf file to define its configuration properties. All reference.conf files in the classpath will be merged. End application can override by defining properties in its application.conf.

/Patrik
--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Maatary Okouya

unread,
Jun 15, 2015, 1:54:11 PM6/15/15
to akka...@googlegroups.com
Understood. Many thanks

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/xwdeWvquXPM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages