Akka configuration classloader issue in Scala console

1,677 views
Skip to first unread message

Alexander Temerev

unread,
Apr 26, 2012, 7:09:47 AM4/26/12
to Akka User List
(Akka 2.0.1, Scala 2.9.2)

Let's assume I just want to play with Akka actors in Scala console.

(~) -> scala -classpath ~/.ivy2/cache/com.typesafe.akka/akka-actor/
jars/akka-actor-2.0.1.jar
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM,
Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.

I am trying to create a new actor system, as described in the manual:

scala> val system1 =
ActorSystem("first")
com.typesafe.config.ConfigException$Missing: No configuration setting
found for key 'akka.version'
at com.typesafe.config.impl.SimpleConfig.findKey(SimpleConfig.java:
115)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:137)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:108)
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:146)

Whooops!

After literally days of scooping Akka docs, StackOverflow, following
wrong tracks (I have thought that this problem is part of something
much more complicated, like merging reference.conf from many jar
files) and as a last resort, reading Akka source code, I came up with
this workaround:

scala> val cl = ActorSystem.getClass.getClassLoader
...
scala> val system2 = ActorSystem("second",
com.typesafe.config.ConfigFactory.load(cl), cl)
system2: akka.actor.ActorSystem = akka://second

This probably means that classloading stuff in
https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/akka/actor/ActorSystem.scala
is, er, suboptimal.

The same thing is happening in web context, e.g. in
ServletContextListener#contextInitialized, if I want to use Akka in a
servlet container.

I now can continue with the workaround, but is this the right thing?
Why Akka doesn't work properly even within Scala console?

Alexander Temerev

unread,
Apr 26, 2012, 7:48:41 AM4/26/12
to Akka User List
Correction: In web context, this problem appears only when I use Jetty
8 (which I have to, because of its WebSocket support). In Jetty 7,
everything appears to be OK.
> This probably means that classloading stuff inhttps://github.com/akka/akka/blob/master/akka-actor/src/main/scala/ak...

√iktor Ҡlang

unread,
Apr 26, 2012, 7:52:06 AM4/26/12
to akka...@googlegroups.com
Akka by default uses the Thread.currentThread.getContextClassloader (if any) if you don't specify your own.



Cheers,

--
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.




--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Alexander Temerev

unread,
Apr 26, 2012, 8:39:45 AM4/26/12
to Akka User List
Yes, it is. Still, shouldn't at least the Scala console be considered
as a special case in classloading code in ActorSystem?

I would submit a pull request, but I am afraid to break something
else.

On Apr 26, 1:52 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Akka by default uses the Thread.currentThread.getContextClassloader (if
> any) if you don't specify your own.
>
> This is well-documented IMHO:http://doc.akka.io/docs/akka/2.0.1/general/configuration.html#A_Word_...
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

√iktor Ҡlang

unread,
Apr 26, 2012, 8:52:05 AM4/26/12
to akka...@googlegroups.com
But it works with Jetty7? So the change that broke things is in Jett8?
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Eugene Burmako

unread,
Apr 26, 2012, 8:50:28 AM4/26/12
to Akka User List
REPL sets its classloader as a context classloader:
https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/interpreter/IMain.scala#L323

This means that Akka should work out of the box, right?

On Apr 26, 2:52 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Akka by default uses the Thread.currentThread.getContextClassloader (if
> any) if you don't specify your own.
>
> This is well-documented IMHO:http://doc.akka.io/docs/akka/2.0.1/general/configuration.html#A_Word_...
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

Bruce Mitchener

unread,
Apr 26, 2012, 9:16:36 AM4/26/12
to akka...@googlegroups.com
2012/4/26 √iktor Ҡlang <viktor...@gmail.com>

Akka by default uses the Thread.currentThread.getContextClassloader (if any) if you don't specify your own.



While the docs have improved a lot, for those of us who didn't write them, it can still be unclear where to find some details.

This is where the index generation support in Sphinx is really nice.  It can be easy to not realize that classloader docs are covered in the configuration section, but when there's an index entry for "classloader" that points directly there, life is a lot better for everyone.


Cheers,

 - Bruce

√iktor Ҡlang

unread,
Apr 26, 2012, 9:23:27 AM4/26/12
to akka...@googlegroups.com
Just download the PDF and then you can search the entirety of the docs.

Cheers,

 

Cheers,

 - Bruce

--
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.

Patrik Nordwall

unread,
Apr 26, 2012, 2:31:35 PM4/26/12
to akka...@googlegroups.com
I have heard that google is a badass search engine!

site:http://doc.akka.io/docs/akka/2.0.1/ classloader


/Patrik

√iktor Ҡlang

unread,
Apr 26, 2012, 4:06:59 PM4/26/12
to akka...@googlegroups.com
On Thu, Apr 26, 2012 at 8:31 PM, Patrik Nordwall <patrik....@gmail.com> wrote:
I have heard that google is a badass search engine!

site:http://doc.akka.io/docs/akka/2.0.1/ classloader

It does search also? I M P R E S S E D

OlegYch

unread,
Apr 26, 2012, 4:28:46 PM4/26/12
to akka...@googlegroups.com
BTW, this is also broken in intellij console, so i ended up passing classloader expicitly

i.e.
val classLoader = getClass.getClassLoader
val system = ActorSystem("MySystem", ConfigFactory.load(classLoader), classLoader)

√iktor Ҡlang

unread,
Apr 26, 2012, 4:33:20 PM4/26/12
to akka...@googlegroups.com
On Thu, Apr 26, 2012 at 10:28 PM, OlegYch <oleg...@gmail.com> wrote:
BTW, this is also broken in intellij console, so i ended up passing classloader expicitly

i.e.
val classLoader = getClass.getClassLoader
val system = ActorSystem("MySystem", ConfigFactory.load(classLoader), classLoader)

Is there any fix for us to make? If the currentThread's context-classloader is broken, how can we tell?

Cheers,
 
--
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/-/gj46nWDxlMoJ.

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.

Roland Kuhn

unread,
Apr 26, 2012, 4:44:45 PM4/26/12
to akka...@googlegroups.com
Sorry, I’m late to this thread: I tried to reproduce and at first did not succeed, i.e. everything was working in scala 2.9.0.1 (the latest dist I actually had laying around unzipped without using SBT). However, I get exactly the failure shown in the original post with 2.9.2, so this is a regression within the REPL.

Concerning IntelliJ, you should maybe file a bug with them:

“The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources.” — from JavaSE 6 API docs

which I take to mean that if a context class loader is set, then it is meant to be used (which we do).

Regards,

Roland

Roland Kuhn
Typesafe – The software stack for applications that scale.
twitter: @rolandkuhn


Alexander Temerev

unread,
Apr 27, 2012, 3:30:14 AM4/27/12
to Akka User List
Just checked: the same thing happens in REPL with Scala 2.9.1.
> >https://github.com/akka/akka/blob/master/akka-actor/src/main/scala/ak...
> > is, er, suboptimal.
>
> > The same thing is happening in web context, e.g. in
> > ServletContextListener#contextInitialized, if I want to use Akka in a
> > servlet container.
>
> > I now can continue with the workaround, but is this the right thing?
> > Why Akka doesn't work properly even within Scala console?
>
> > --
> > You received this message because you are subscribed to the Google Groups "Akka User List" group.
> > To view this discussion on the web visithttps://groups.google.com/d/msg/akka-user/-/gj46nWDxlMoJ.
>
> > 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 athttp://groups.google.com/group/akka-user?hl=en.
>
> > --
> > Viktor Klang
>
> > Akka Tech Lead
> > Typesafe - The software stack for applications that scale
>
> > Twitter: @viktorklang
>
> > --
> > 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 athttp://groups.google.com/group/akka-user?hl=en.

√iktor Ҡlang

unread,
Apr 27, 2012, 3:54:13 AM4/27/12
to akka...@googlegroups.com

Thanks Alex,

Something seems fishy with sbt's context loader.
Should we introduce a config option to look aside or let sbt fix it?

Cheers,
V

Alexander Temerev

unread,
Apr 27, 2012, 3:59:50 AM4/27/12
to Akka User List
Dear Viktor,

I understand your desire to mock people who can't use Google (I mock
them myself every day), but here's how the sequence of events looks:

1) I have a small, but working project (twitdo.com) written with Akka
1.2. I use it as my testbed for Scala development mostly. When Akka
2.0 has been released, I have been thoroughly impressed with
dataflows, automatic supervision and other cool features, so I wanted
to migrate my code to 2.0.

2) After the migration has been completed, sbt-web-plugin have failed
to restart the container, giving me nothing except ("Failed to start
the web application") message. This is not the problem of Akka, of
course, but rest assured — I will stalk the poor guy who develops sbt-
web-plugin until the logging problem will be fixed.

3) I tried to reproduce the problem in the console, and discovered the
"No configuration setting found for key 'akka.version'" error message.
OK, _now_ I got something to google, which I did.

4) I discovered the thread about sbt-assembly problems with
reference.conf merging. I knew that sbt-web-plugin first assembles
the .war, then tries to launch it with Jetty (it used to, now it works
differently), so I suspected this might be the same problem, which I
told you. You promptly responded by fixing sbt-assembly plugin, but it
didn't help.

5) I tried just to create a few actors in Scala console and see if
that will work. It didn't, but now I was sure that the problem happens
directly in Akka, not via some interference from my application code.

6) I checked the stack trace, went to Akka source, and only there I
have found out about the classloading code. So, only at this stage I
could google Akka documentation for 'classloader', and could test some
more hypotheses about why reading resources doesn't work properly in
Scala console and in Jetty 8.

OK, Akka is new, it's hard to make it work with sbt-web-plugin and
jetty-8, maybe there are not that many Akka users to check all
combinations and report them. But I expected things to be working at
least in Scala REPL. Everyone uses the REPL.

And this is not like "oh, you should just google 'classloader' in Akka
docs", right?

On Apr 26, 10:06 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> On Thu, Apr 26, 2012 at 8:31 PM, Patrik Nordwall
> <patrik.nordw...@gmail.com>wrote:
>
> > I have heard that google is a badass search engine!
>
> > site:http://doc.akka.io/docs/akka/2.0.1/classloader
>
> It does search also? I M P R E S S E D
>
>
>
>
>
>
>
>
>
>
>
> > /Patrik
>
> > On Apr 26, 2012, at 15:23, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
>
> > On Thu, Apr 26, 2012 at 3:16 PM, Bruce Mitchener <
> > bruce.mitche...@gmail.com> wrote:
>
> >> 2012/4/26 √iktor Ҡlang <viktor.kl...@gmail.com>
>
> >>> Akka by default uses the Thread.currentThread.getContextClassloader (if
> >>> any) if you don't specify your own.
>
> >>> This is well-documented IMHO:
> >>>http://doc.akka.io/docs/akka/2.0.1/general/configuration.html#A_Word_...
>
> >> While the docs have improved a lot, for those of us who didn't write
> >> them, it can still be unclear where to find some details.
>
> >>  This is where the index generation support in Sphinx is really nice.  It
> >> can be easy to not realize that classloader docs are covered in the
> >> configuration section, but when there's an index entry for "classloader"
> >> that points directly there, life is a lot better for everyone.
>
> >>    http://sphinx.pocoo.org/markup/misc.html#index-generating-markup
>
> > Just download the PDF and then you can search the entirety of the docs.
>
> > Cheers,
> > √
>
> >> Cheers,
>
> >>  - Bruce
>
> >>  --
> >> 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.
>
> > --
> > Viktor Klang
>
> > Akka Tech Lead
> > Typesafe <http://www.typesafe.com/> - The software stack for applications
> > that scale
>
> > Twitter: @viktorklang
>
> >  --
> > 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.
>
> >  --
> > 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.
>
> --
> Viktor Klang
>
> Akka Tech Lead
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

Alexander Temerev

unread,
Apr 27, 2012, 4:05:10 AM4/27/12
to Akka User List
I just started the Scala REPL, it happens even outside SBT.

I thought whether there might be the way to detect that we are in the
REPL and just use ActorSystem.getClass.getClassLoader in that case?

√iktor Ҡlang

unread,
Apr 27, 2012, 4:09:38 AM4/27/12
to akka...@googlegroups.com
On Fri, Apr 27, 2012 at 9:59 AM, Alexander Temerev <sor...@gmail.com> wrote:
Dear Viktor,

I understand your desire to mock people who can't use Google (I mock
them myself every day), but here's how the sequence of events looks:

I was actually genuinely impressed that Google finally had decided to index our docs.
We actually had that as a ticket interally.
 

1) I have a small, but working project (twitdo.com) written with Akka
1.2. I use it as my testbed for Scala development mostly. When Akka
2.0 has been released, I have been thoroughly impressed with
dataflows, automatic supervision and other cool features, so I wanted
to migrate my code to 2.0.

Thanks
 

2) After the migration has been completed, sbt-web-plugin have failed
to restart the container, giving me nothing except ("Failed to start
the web application") message. This is not the problem of Akka, of
course, but rest assured — I will stalk the poor guy who develops sbt-
web-plugin until the logging problem will be fixed.

I'm sad to hear that. Hope he fixes it.
 

3) I tried to reproduce the problem in the console, and discovered the
"No configuration setting found for key 'akka.version'" error message.
OK, _now_ I got something to google, which I did.

 

4) I discovered the thread about sbt-assembly problems with
reference.conf merging. I knew that sbt-web-plugin first assembles
the .war, then tries to launch it with Jetty (it used to, now it works
differently), so I suspected this might be the same problem, which I
told you. You promptly responded by fixing sbt-assembly plugin, but it
didn't help.

Didn't help? I'm pretty sure it does what it says on the box now.
 

5) I tried just to create a few actors in Scala console and see if
that will work. It didn't, but now I was sure that the problem happens
directly in Akka, not via some interference from my application code.

Ok
 

6) I checked the stack trace, went to Akka source, and only there I
have found out about the classloading code. So, only at this stage I
could google Akka documentation for 'classloader', and could test some
more hypotheses about why reading resources doesn't work properly in
Scala console and in Jetty 8.

I think a first step should be to read the docs for the new version, it's not a number-bump it's definitely a whole new Akka.
 

OK, Akka is new, it's hard to make it work with sbt-web-plugin and
jetty-8, maybe there are not that many Akka users to check all
combinations and report them. But I expected things to be working at
least in Scala REPL. Everyone uses the REPL.

Do you mean that Akka does not work in REPL? Because I use that all the time.
If so, please post a sample project (minimized) that has the problem and we'll fix it.
 

And this is not like "oh, you should just google 'classloader' in Akka
docs", right?


Absolutely not. I believe that there might be something wrong in the sbt-web-plugin that doesn't set the correct context classloader.

Cheers,



--
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

√iktor Ҡlang

unread,
Apr 27, 2012, 4:15:13 AM4/27/12
to akka...@googlegroups.com
On Fri, Apr 27, 2012 at 10:05 AM, Alexander Temerev <sor...@gmail.com> wrote:
I just started the Scala REPL, it happens even outside SBT.

I thought whether there might be the way to detect that we are in the
REPL and just use ActorSystem.getClass.getClassLoader in that case?

I would rather fix the problem than putting a bandaid on top of it.
Perhaps we should consider creating a composite classloader that first uses context then delegates to ActorSystem.getClass.getClassLoader. But that won't work if Akka jars are placed in a higher up classloader and application code in a lower one.

The reason we capture context classloader is that Akka wouldn't work in a managed environment see the archive: http://groups.google.com/group/akka-user/search?hl=en_US&group=akka-user&q=getContextClassLoader&qt_g=Search+this+group

Cheers,

Alexander Temerev

unread,
Apr 27, 2012, 4:21:00 AM4/27/12
to Akka User List
> Do you mean that Akka does not work in REPL? Because I use that all the
> time.
> If so, please post a sample project (minimized) that has the problem and
> we'll fix it.

Viktor, have you read my first message? :)

I just started the REPL with the following command line:

$ scala -classpath akka-actor-2.0.1.jar

Then, I did this:

scala> val system1 = ActorSystem("first")

It doesn't work. Neither with Scala 2.9.2, nor 2.9.1. It gives me the
"com.typesafe.config.ConfigException$Missing: No configuration setting
found for key 'akka.version'".

Does it work for you?

Cheers,
Alexander Temerev.

√iktor Ҡlang

unread,
Apr 27, 2012, 4:45:29 AM4/27/12
to akka...@googlegroups.com
On Fri, Apr 27, 2012 at 10:21 AM, Alexander Temerev <sor...@gmail.com> wrote:
> Do you mean that Akka does not work in REPL? Because I use that all the
> time.
> If so, please post a sample project (minimized) that has the problem and
> we'll fix it.

Viktor, have you read my first message? :)

I apologize, I apparently have too much stuff going on at the same time right now ;-)
 

I just started the REPL with the following command line:

$ scala -classpath akka-actor-2.0.1.jar

Then, I did this:

scala> val system1 = ActorSystem("first")

It doesn't work. Neither with Scala 2.9.2, nor 2.9.1. It gives me the
"com.typesafe.config.ConfigException$Missing: No configuration setting
found for key 'akka.version'".

Does it work for you?

Sure does. I understand your frustration, classloader issues are truly opaque to debug.
I'd say that this bug is in the Scala REPL, I'll talk to the scala team and see if they can fix it.

I've opened a ticket to see if we can create a delegating classloader that first checks context classloader and then falls back to getClass.getClassLoader if the user has not provided any explicit classloader.


Cheers,
 

Cheers,
Alexander Temerev.


--
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.

Jason Zaugg

unread,
Apr 27, 2012, 4:49:07 AM4/27/12
to akka...@googlegroups.com
2012/4/27 √iktor Ҡlang <viktor...@gmail.com>:
>
>
> On Fri, Apr 27, 2012 at 10:21 AM, Alexander Temerev <sor...@gmail.com>
> wrote:
>>
>> > Do you mean that Akka does not work in REPL? Because I use that all the
>> > time.
>> > If so, please post a sample project (minimized) that has the problem and
>> > we'll fix it.
>>
>> Viktor, have you read my first message? :)
>
>
> I apologize, I apparently have too much stuff going on at the same time
> right now ;-)
>
>>
>>
>> I just started the REPL with the following command line:
>>
>> $ scala -classpath akka-actor-2.0.1.jar
>>
>> Then, I did this:
>>
>> scala> val system1 = ActorSystem("first")
>>
>> It doesn't work. Neither with Scala 2.9.2, nor 2.9.1. It gives me the
>> "com.typesafe.config.ConfigException$Missing: No configuration setting
>> found for key 'akka.version'".
>>
>> Does it work for you?
>
>
> Sure does. I understand your frustration, classloader issues are truly
> opaque to debug.
> I'd say that this bug is in the Scala REPL, I'll talk to the scala team and
> see if they can fix it.

Try scala -Yrepl-sync

https://github.com/scala/scala/commit/5a711d7a4

-jason

√iktor Ҡlang

unread,
Apr 27, 2012, 4:53:28 AM4/27/12
to akka...@googlegroups.com
Thanks for the tip Jason,

According to Paul, this should work as well:

scala -J-Xbootclasspath/a:/path/to/akka-actor-2.0.1.jar

However, it is as Alexander says, bad that Akka doesn't work by default using a straight REPL.
Question is if we can do anything about that from the Akka side.
 
Cheers,



-jason

--
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.

Alexander Temerev

unread,
Apr 27, 2012, 4:54:55 AM4/27/12
to Akka User List
Thanks!

I will also try talk to Eugene Burmako about this. He might get some
insight on whether this can be fixed. Because it's true, a context
classloader within REPL can't load resources from jars on classpath.
Compare:

scala>
Thread.currentThread.getContextClassLoader.getResource("reference.conf")
res1: java.net.URL = null

scala>
ActorSystem.getClass.getClassLoader.getResource("reference.conf")
res2: java.net.URL = jar:file:/Users/atemerev/.ivy2/cache/
com.typesafe.akka/akka
-actor/jars/akka-actor-2.0.1.jar!/reference.conf
> http://www.assembla.com/spaces/akka/tickets/2026-scala-repl-getcontex...
>
> Cheers,
> √
>
>
>
> > Cheers,
> > Alexander Temerev.
>
> > --
> > 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.
>
> --
> Viktor Klang
>
> Akka Tech Lead
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

Alexander Temerev

unread,
Apr 27, 2012, 4:58:07 AM4/27/12
to Akka User List
Thanks, Jason, it does work with -Yrepl-sync.

$ scala -Yrepl-sync -classpath ~/.ivy2/cache/com.typesafe.akka/akka-
actor/jars/akka-actor-2.0.1.jar
Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM,
Java 1.6.0_31).
Type in expressions to have them evaluated.
Type :help for more information.

scala> import akka.actor._
import akka.actor._

scala> ActorSystem("main")
res0: akka.actor.ActorSystem = akka://main

Alexander Temerev

unread,
Apr 27, 2012, 5:02:25 AM4/27/12
to Akka User List
To quote the famous and now googlable Akka documentation:

"...putting Akka on the boot class path will yield
NullPointerException from strange places: this is simply not
supported."

:)

On Apr 27, 10:53 am, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> On Fri, Apr 27, 2012 at 10:49 AM, Jason Zaugg <jza...@gmail.com> wrote:
> > 2012/4/27 √iktor Ҡlang <viktor.kl...@gmail.com>:
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

√iktor Ҡlang

unread,
Apr 27, 2012, 5:05:23 AM4/27/12
to akka...@googlegroups.com
On Fri, Apr 27, 2012 at 11:02 AM, Alexander Temerev <sor...@gmail.com> wrote:
To quote the famous and now googlable Akka documentation:

"...putting Akka on the boot class path will yield
NullPointerException from strange places: this is simply not
supported."

:)

"...unless all your classes go there" (using invisible pen) ;-)



--
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

√iktor Ҡlang

unread,
Apr 27, 2012, 5:17:06 AM4/27/12
to akka...@googlegroups.com
I'll make a note of the bug in the docs in the ClassLoader section.

2012/4/27 √iktor Ҡlang <viktor...@gmail.com>

√iktor Ҡlang

unread,
Apr 27, 2012, 5:25:23 AM4/27/12
to akka...@googlegroups.com
Done

2012/4/27 √iktor Ҡlang <viktor...@gmail.com>

√iktor Ҡlang

unread,
Aug 1, 2012, 4:45:04 PM8/1/12
to akka...@googlegroups.com
Hi Bryan,

didn't "-Yrepl-sync" as suggested in this thread solve it?

Cheers,


On Wed, Aug 1, 2012 at 9:59 PM, bryan hunt <sentimen...@gmail.com> wrote:
I've got the exact same behaviour here.
Akka 2.0.2
Scala 2.9.1

Problem occurs in Intellij and Scala REPL.

This is my first day of AKKA.

I'd like to use 2.0.2 as I don't want to go through the pain of upgrading to Scala 2.1.0 if it can be avoided.


Is it possible or do I need to play the yak shaving/upgrade game?

Best Regards,

Bryan Hunt

--
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/-/Ut2rApJKdEQJ.

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.

√iktor Ҡlang

unread,
Aug 1, 2012, 5:23:44 PM8/1/12
to akka...@googlegroups.com


On Wed, Aug 1, 2012 at 11:14 PM, bryan hunt <sentimen...@gmail.com> wrote:

Yes, have tried that trick, and I can load and actor context in the REPL.

Excellent!
 

Is there an equivalent trick I can perform when running the fsm-sample within Intellij?

I have no idea, that's probably best answered by the IDEA folks.

Cheers,
 

Cheers,

Bryan

--
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/-/AGBa-h_Uro4J.

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.

√iktor Ҡlang

unread,
Aug 1, 2012, 5:48:51 PM8/1/12
to akka...@googlegroups.com
Hi Bryan,

On Wed, Aug 1, 2012 at 11:37 PM, bryan hunt <sentimen...@gmail.com> wrote:
Is there an equivalent trick I can perform when running the fsm-sample within Intellij?

I have no idea, that's probably best answered by the IDEA folks.

Hi Viktor,

I don't want to appear flippant - but what environment does one typically need in order to run the Akka sample projects?

Oh, there's a very nice getting started guide for Akka with the Typesafe Stack: http://typesafe.com/stack/download#template

You can also run the Akka Sample projects straight from SBT: http://doc.akka.io/docs/akka/2.0.2/intro/getting-started.html
 

Getting the Akka equivalent of HelloWorld to boot would be a huge boost to my confidence and self esteem.

Right now I know they neither run in ScalaIDE (file-names don't match classes) or Intellij.

It sounds like some pretty fragile classloading, considering it's just trying to load a boot properties file.

Problem is that SBT / Scala REPL has a bug in the context class loader it sets if you don't specify -Y-repl-sync,
you could also manually provide the correct classloader to the ActorSystem: 

defapply(name: Stringconfig: ConfigclassLoader: ClassLoader)ActorSystem

Creates a new ActorSystem with the name "default", the specified Config, and specified ClassLoader

 

What's wrong with just loading from the classpath, or providing an option to override - à la log4j?

It loads from the context classloader if there is one set (as per JDK spec) but you can also provide one (see above).
 

Asking the Intellij 'folks', why an Akka application won't run, is much like asking the Eclipse guys why a Jetty application won't boot.

No, I meant, I do not know how they form their classpaths/how their REPL integration is constructed, so I wouldn't be much help in trying to give advice how to configure that. Hopefully my suggestions above can help out though.


Haven't had this sort of problem, since my J2EE days - while I'm at it, should I go looking for the glass hammer?

In this case I can only apologize that the Scala REPL's context classloader has a bug, I can't really fix that in Akka though.

Thanks for your perseverence, let me know if any of the tips work and if not, I'll try to come up something that does.

Cheers,
 

Cheers,

Bryan Hunt



--
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/-/_IQyHKdX2NEJ.

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.

√iktor Ҡlang

unread,
Aug 2, 2012, 5:20:07 AM8/2/12
to akka...@googlegroups.com


On Thu, Aug 2, 2012 at 11:04 AM, bryan hunt <sentimen...@gmail.com> wrote:

Hi Viktor,

I already downloaded the docs and paid for them to be printed - last week.

So I've been reading through them the last 5 days or so, familiarizing myself with the system.

Now it's time to fire up a couple of Hello World type apps, so that's where I'm at.

Thanks for the Scala REPL tip, it works!

It seems from what you are saying it is not possible to run Akka in an IDE, only in SBT.

What led you to that conclusion? I have not said that in any way, shape or form.

Did you try any of the ideas I provided? What were the results? Have you've verified that you have a correct classpath for your "run" command in your IDE?

Since it works in the REPL I can only conclude that it is an IDE misconfiguration issue, which I'll be glad to try to help you out with, but oyu'll need to both report back the results from my suggestions, and be a bit more detailed in exactly what doesn't work and what error output you get.

Thanks,

 

To my mind it seems a bit of a shame.

It's a big API to learn by rote, and my social life isn't exactly stellar to start with.

Bryan




--
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/-/TsPPgL1bs7gJ.

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.

bryan hunt

unread,
Aug 2, 2012, 7:08:22 AM8/2/12
to akka...@googlegroups.com

> It seems from what you are saying it is not possible to run
> Akka in an IDE, only in SBT.
>
> Did you try any of the ideas I provided? What were the results? Have
> you've verified that you have a correct classpath for your "run"
> command in your IDE?
>
The only idea, at lest with my limited understanding of the domain, was
to contact Intellij to find out why AKKA's configuration loading
mechanism wouldn't work.

> Since it works in the REPL I can only conclude that it is an IDE
> misconfiguration issue, which I'll be glad to try to help you out
> with, but oyu'll need to both report back the results from my
> suggestions, and be a bit more detailed in exactly what doesn't work
> and what error output you get.
>
I've checked in all the Intellij configuration files, forked, and pushed
to my github repo.

https://github.com/sentimentalbryan/akka/tree/bryan


I've figured it out.

I had the entire Akka 2.0.2 project checked out.

I generated Idea configuration using sbt gen-idea.

The akka-sample-fsm project had a module dependency on akka-actors
module.

So the whole classpath of akka-actors module was available, thus
compilation worked.

But it was not using akka-actors-2.0.2 jar file.

I suspect the configuration mechanism only works (by default) when the
reference.conf is stored in a jar file.

I'd like to familiarize myself with Akka internals, rather than only
using the jar file.

Is there a means of loading the reference.conf directly as an Input
Stream?

My understanding so far is that it can be overridden, and I tried that
unsuccessfully, can I just manually specify it? Or is that not
idiomatic?

Regards,

Bryan Hunt
































>

√iktor Ҡlang

unread,
Aug 2, 2012, 7:27:24 AM8/2/12
to akka...@googlegroups.com

  1. def
    apply(name: Stringconfig: ConfigclassLoader: ClassLoader)ActorSystem

    Creates a new ActorSystem with the name "default", the specified Config, and specified ClassLoader

  1. defapply(name: Stringconfig: Config)ActorSystem

    Creates a new ActorSystem with the name "default", and the specified Config, then obtains the current ClassLoader by first inspecting the current threads' getContextClassLoader, then tries to walk the stack to find the callers class loader, then falls back to the ClassLoader associated with the ActorSystem class.

 

Here's the docs for the Config lib: http://typesafehub.github.com/config/latest/api/

Happy hAkking,



Regards,

Bryan Hunt

































>

--
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.

Roland Kuhn

unread,
Aug 2, 2012, 7:38:42 AM8/2/12
to akka...@googlegroups.com
No, reference.conf is loaded from the root of the classpath, no matter how it got there. I guess your problem is that the resource folders are not included in the build path, which means that reference.conf is not copied to the project’s output folder.

Regards,

Roland Kuhn
Typesafe – The software stack for applications that scale.
twitter: @rolandkuhn


bryan hunt

unread,
Aug 2, 2012, 8:59:16 AM8/2/12
to akka...@googlegroups.com
Argh! Intellij didn't include it in resources to copy!

Now all is sane again.

find ./ -name "*.conf" | grep akka-actor
./akka-actor/target/classes/reference.conf
./akka-actor/src/main/resources/reference.conf

Thanks for helping me resolve this!

Bryan Hunt

bryan hunt

unread,
Aug 2, 2012, 9:11:07 AM8/2/12
to akka...@googlegroups.com

Thanks for your help guys, I've blogged about getting started with Akka source distribution, it's rushed and messy but might help others.



On Thursday, August 2, 2012 12:38:42 PM UTC+1, rkuhn wrote:

Roland Kuhn

unread,
Aug 2, 2012, 9:21:36 AM8/2/12
to akka...@googlegroups.com
Good that you wrote it down … but … I must heavily protest the statement that ScalaIDE does not work with Akka’s sources: for the past year I have used nothing but it to do all my work, and that included refactorings which literally touched every single file in the repository. So, I think ScalaIDE is perfectly suited for working with Akka (or any Scala project, for that matter).

Which versions are you using? And I mean all of

- Eclipse
- ScalaIDE
- sbt-eclipse
- Java
- O/S
- which filesystem

It would be nice if you could remove that statement from the blog post after we found out what you are doing wrong.

Regards,

Roland

--
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/-/g2z8tU4AVgUJ.

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.
Reply all
Reply to author
Forward
0 new messages