How to get 'mvn lagom:runAll' to get my service listening on a port?

471 views Asked by At

I was having problems getting my first service to run and decided to add the hello-api and hello-impl projects from the lagom Maven archtype project to see if it would work. It did but mine do not.

Background

Since other team members are pure Java developers, I was trying to avoid leveraging sbt and activator. Thus, the objective is that everything works in maven.

Here's a snippet of the 'mvn install' script output to show the other services built.

$ mvn install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Archetype - mai-svcs
[INFO] mai-svc-common
[INFO] mai-actors-api               <======= WANT THE SERVICE FOR THIS ONE TO RUN
[INFO] mai-namespace-api
[INFO] mai-actors-impl
[INFO] mai-namespace-impl
[INFO] mai-i18n-phrases-api
[INFO] hello-api
[INFO] hello-impl
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Archetype - mai-svcs 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Archetype - mai-svcs ............................... SUCCESS [  2.774 s]
[INFO] mai-svc-common ..................................... SUCCESS [  7.190 s]
[INFO] mai-actors-api ..................................... SUCCESS [ 24.706 s]
[INFO] mai-namespace-api .................................. SUCCESS [ 12.628 s]
[INFO] mai-actors-impl .................................... SUCCESS [ 29.061 s]
[INFO] mai-namespace-impl ................................. SUCCESS [ 21.294 s]
[INFO] mai-i18n-phrases-api ............................... SUCCESS [ 22.091 s]
[INFO] hello-api .......................................... SUCCESS [  3.546 s]

NOTES: An MAIActorsModule class analogous to the HelloModule class was created and the application.conf file added in the src/main/resources folder.

When the command 'mvn lagom:runAll' is issued, initially, the services are the hello service port is logged but no other service's port is.

$ mvn lagom:runAll
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Archetype - mai-svcs
[INFO] mai-svc-common
[INFO] mai-actors-api
[INFO] mai-namespace-api
[INFO] mai-actors-impl
[INFO] mai-namespace-impl
[INFO] mai-i18n-phrases-api
[INFO] hello-api
[INFO] hello-impl
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Archetype - mai-svcs 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- lagom-maven-plugin:1.2.1:runAll (default-cli) @ mai-svcs ---
[INFO] Starting Kafka
[INFO] Starting Cassandra
.[INFO] Did not find Netty's native epoll transport in the classpath, defaulting to NIO.
....[INFO] Using data-center name 'datacenter1' for DCAwareRoundRobinPolicy (if this is incorrect, please provide the correct datacenter name with DCAwareRoundRobinPolicy constructor)
[INFO] New Cassandra host /127.0.0.1:4000 added

[INFO] Cassandra server running at 127.0.0.1:4000
[INFO] Service locator is running at http://localhost:8000
[INFO] Service gateway is running at http://localhost:9000
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\lusp\mai_svcs\mai-svcs\hello-api\src\main\resources
[INFO] Nothing to compile - all classes are up to date
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
**[INFO] Nothing to compile - all classes are up to date
[INFO] Service hello-impl listening for HTTP on 0:0:0:0:0:0:0:0:57797
//           ----- NO ENTRY FOR mai-actors-impl!!!  -----
[INFO] (Service started, press enter to stop and go back to the console...)**

What step(s) did I miss?

1

There are 1 answers

0
Tim Moore On BEST ANSWER

Each of your <service>-impl projects need to:

  1. Invoke the lagom-maven-plugin
  2. Configure it with the property <lagomService>true</lagomService>

Here's an example snippet of what you need to add to your pom.xml file in each service implementation project:

<build>
    <plugins>
        <plugin>
            <groupId>com.lightbend.lagom</groupId>
            <artifactId>lagom-maven-plugin</artifactId>
            <configuration>
                <lagomService>true</lagomService>
            </configuration>
        </plugin>
    </plugins>
</build>

The Lagom documentation has more details in the page titled Defining a Lagom build