title: Is it possible to run a gRPC server in a Java application using WildFly?
body: <p>I'm trying to run a gRPC server in our WildFly application to connect to from a client Java microservice using Quarkus.
  I was able to set up a running server on port 9002 for gRPC where the client microservice can connect to.<br />
  When doing a call to the running gRPC service, I can see the rpc function is executed inside the WildFly application. I'm running into 2 issues however.
  For the Server and Service setup, I used <a href="https://github.com/grpc/grpc-java/blob/master/examples/src/main/java/io/grpc/examples/routeguide/RouteGuideServer.java" rel="nofollow noreferrer">this code</a> as an example.</p>
  <p><strong>Issues</strong></p>
  <ol>
  <li>Dependency injection does not work in this service. The bean is created in WildFly but whatever object I @Inject into the gRPC Service, it always has a <code>null</code> value.</li>
  <li>The server executes the code and replies with an appropriate gRPC message but this message never arrives at client side. No error is displayed whatsoever.</li>
  </ol>
  <p><em>Does anyone have experience with these issues or knows if it is even possible to run a gRPC server within a WildFly application?</em></p>
  <p><strong>What I tried:</strong></p>
  <p>I tried to find an existing gRPC integration with WildFly but this is currently in the works as I could derive from <a href="https://github.com/grpc/grpc-java/pull/4738" rel="nofollow noreferrer">this open pull request</a>.<br />
  From <a href="http://wildfly-development.1055759.n5.nabble.com/GRPC-subsystem-proof-of-concept-td5718293.html" rel="nofollow noreferrer">this mailing list</a> it seems that someone made a Proof Of Concept and made changes to the WildFly code to make it work, however this is not the solution that we are looking for since we'd prefer not to change the WildFly code.</p>
  <p><strong>Relevant code</strong><br />
  The client code hangs on the <code>blockingStub.updateBalance(request)</code> call because no reply is ever received:</p>
  <pre><code>BalanceUpdateGrpc.BalanceUpdateBlockingStub blockingStub = BalanceUpdateGrpc.newBlockingStub(channel);
  var request = BalanceUpdateRequest.newBuilder()
      .setContractNumber(&quot;111&quot;)
      .setBalance((float) 100.2)
      .setDate(BalanceUpdateRequest.Date
              .newBuilder()
              .setDay(3)
              .setMonth(11)
              .setYear(2020)
              .build())
      .build();
  var reply = blockingStub.updateBalance(request);
  </code></pre>
  <p>The service code:</p>
  <pre><code>@Singleton
  public class BalanceUpdateService extends BalanceUpdateGrpc.BalanceUpdateImplBase {
      @Inject
      private DossierDAO dossierDAO;
  
  
      @Override
      public void updateBalance(BalanceUpdateRequest balanceUpdateRequest, StreamObserver&lt;BalanceUpdateReply&gt; responseObserver) {
          //Just reply with true
          //dossierDAO is always null when used in this code block
          responseObserver.onNext(BalanceUpdateReply.newBuilder().setSuccess(true).build());
      }
  }
  </code></pre>