2

I've used the maven-shade-plugin given in the akka docs and it creates a shaded jar as evidenced by the following output from maven build:

[INFO] --- maven-shade-plugin:2.4.2:shade (default) @ remoting.example ---
[INFO] Including com.typesafe.akka:akka-remote_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including org.scala-lang:scala-library:jar:2.11.8 in the shaded jar.
[INFO] Including com.typesafe.akka:akka-protobuf_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including io.netty:netty:jar:3.10.6.Final in the shaded jar.
[INFO] Including org.uncommons.maths:uncommons-maths:jar:1.2.2a in the shaded jar.
[INFO] Including com.typesafe.akka:akka-actor_2.11:jar:2.4.8 in the shaded jar.
[INFO] Including com.typesafe:config:jar:1.3.0 in the shaded jar.
[INFO] Including org.scala-lang.modules:scala-java8-compat_2.11:jar:0.7.0 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing /home/dschulze/src/java/akka/remoting.example/target/remoting.example-0.0.1-SNAPSHOT.jar with /home/dschulze/src/java/akka/remoting.example/target/remoting.example-0.0.1-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: /home/dschulze/src/java/akka/remoting.example/dependency-reduced-pom.xml

When I run the jar-with-dependencies I still get

Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.version'

I've also tried several other that I've found on various posts on the web, but none of them create a jar-with-dependencies that works. How can I create a jar-with-dependencies that uses akka?

Dean Schulze
  • 9,633
  • 24
  • 100
  • 165
  • Tried with `-Dakka.version`? – Alex Aug 03 '16 at 20:17
  • Adding `-Dakka.version` gives `No configuration setting found for key 'akka.actor.provider'`. So it looks like it just move the problem to the next property. Is your approach documented anywhere? How many properties am I going to have to override on the command line like this? – Dean Schulze Aug 03 '16 at 21:13
  • See my answer. I suspect you need to provide an application.conf on the classpath that'll provide the minimum configuration. – Alex Aug 04 '16 at 07:24
  • Did my answer help? If so can you be a good citizen and accept? – Alex Sep 29 '16 at 19:37

2 Answers2

1

According to the documentation regarding using a jar or bundle:

Akka's configuration approach relies heavily on the notion of every module/jar having its own reference.conf file, all of these will be discovered by the configuration and loaded. Unfortunately this also means that if you put/merge multiple jars into the same jar, you need to merge all the reference.confs as well. Otherwise all defaults will be lost and Akka will not function.

You can provide a custom application.conf as described here:

akka {

  # Loggers to register at boot time (akka.event.Logging$DefaultLogger logs
  # to STDOUT)
  loggers = ["akka.event.slf4j.Slf4jLogger"]

  # Log level used by the configured loggers (see "loggers") as soon
  # as they have been started; before that, see "stdout-loglevel"
  # Options: OFF, ERROR, WARNING, INFO, DEBUG
  loglevel = "DEBUG"

  # Log level for the very basic logger activated during ActorSystem startup.
  # This logger prints the log messages to stdout (System.out).
  # Options: OFF, ERROR, WARNING, INFO, DEBUG
  stdout-loglevel = "DEBUG"

  # Filter of log events that is used by the LoggingAdapter before
  # publishing log events to the eventStream.
  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"

  actor {
    provider = "akka.cluster.ClusterActorRefProvider"

    default-dispatcher {
      # Throughput for default Dispatcher, set to 1 for as fair as possible
      throughput = 10
    }
  }

  remote {
    # The port clients should connect to. Default is 2552.
    netty.tcp.port = 4711
  }
}

This covers the akka.actor.provider setting it's complaining about, amongst others.

Alex
  • 8,093
  • 6
  • 49
  • 79
0

In you are using the plugin settings provided by Akka, there should be a new jar available that ends in -allinone.jar. This jar is the shaded jar.