Java – run akka with runnable jar
I'm trying to use NetBeans to implement akka. Net in the Java Maven project When I run it from NetBeans, it works normally, but when I run runnable jar from NetBeans, it generates an error
Exception in thread "main" com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'akka.remote.log-received-messages'
When I add log received message to the configuration, it will require another configuration This is the plug - in I use to generate jar files
<plugin> <artifactId>maven-assembly-plugin</artifactId> </plugin>
My dependence is
<dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-actor_2.10</artifactId> <version>2.3.7</version> </dependency> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-remote_2.10</artifactId> <version>2.3.7</version> </dependency>
The configuration of akka is
akka10300{ akka{ actor{provider = "akka.remote.RemoteActorRefProvider"} remote { enabled-transports = ["akka.remote.netty.tcp"] netty.tcp { hostname="127.0.0.1" port=10300 } } } }
Solution
About in http://doc.akka.io/docs/akka/snapshot/general/configuration.html Run akka's warning from "fat tank" The problem is that there are multiple references The default behavior of the conf configuration file, Maven assembly, or tree shade plug-in is to overwrite the previous instance of the configuration file
To solve this problem, the recommended method is to use the Maven shade plug-in to generate an executable jar and configure it to store all resources The conf file is attached to a single file instead of overwriting it The recommended Maven shade plug-in configuration is as follows:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.5</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <shadedArtifactAttached>true</shadedArtifactAttached> <shadedClassifierName>allinone</shadedClassifierName> <artifactSet> <includes> <include>*:*</include> </includes> </artifactSet> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>reference.conf</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <manifestEntries> <Main-Class>akka.Main</Main-Class> </manifestEntries> </transformer> </transformers> </configuration> </execution> </executions> </plugin>