title: Can't build working Java app with gRPC, Protobuf and BoringSSL to JAR using Maven
body: <p>I have problem with building my <code>Java</code> app to <code>jar</code> file using <code>Maven</code>. </p>
  
  <p>Application is using <code>gRPC</code> and <code>Protobuf</code>.</p>
  
  <p>When I start my app in <code>IntelliJ</code> everything work just fine, problem is when I want to build <code>jar</code> with <code>Maven</code>... I don't have much experience with creating <code>pom</code> files. </p>
  
  <p>I tried to find some solution but nothing works and I ended up with <code>pom.xml</code> as below:</p>
  
  <pre><code>[...]
  &lt;properties&gt;
      &lt;grpc.version&gt;1.17.1&lt;/grpc.version&gt;
      &lt;protoc.version&gt;3.5.1-1&lt;/protoc.version&gt;
      &lt;netty.tcnative.version&gt;2.0.13.Final&lt;/netty.tcnative.version&gt;
      [...]
  &lt;/properties&gt;
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.grpc&lt;/groupId&gt;
          &lt;artifactId&gt;grpc-protobuf&lt;/artifactId&gt;
          &lt;version&gt;${grpc.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.grpc&lt;/groupId&gt;
          &lt;artifactId&gt;grpc-stub&lt;/artifactId&gt;
          &lt;version&gt;${grpc.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.grpc&lt;/groupId&gt;
          &lt;artifactId&gt;grpc-netty&lt;/artifactId&gt;
          &lt;version&gt;${grpc.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.netty&lt;/groupId&gt;
          &lt;artifactId&gt;netty-tcnative-boringssl-static&lt;/artifactId&gt;
          &lt;version&gt;${netty.tcnative.version}&lt;/version&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      [...]
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;extensions&gt;
          &lt;extension&gt;
              &lt;groupId&gt;kr.motd.maven&lt;/groupId&gt;
              &lt;artifactId&gt;os-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.5.0.Final&lt;/version&gt;
          &lt;/extension&gt;
      &lt;/extensions&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.xolstice.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;protobuf-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.5.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;protocArtifact&gt;com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
                  &lt;/protocArtifact&gt;
                  &lt;pluginId&gt;grpc-java&lt;/pluginId&gt;
                  &lt;pluginArtifact&gt;io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
                  &lt;/pluginArtifact&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;compile&lt;/goal&gt;
                          &lt;goal&gt;compile-custom&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-enforcer-plugin&lt;/artifactId&gt;
              &lt;version&gt;1.4.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.8&lt;/source&gt;
                  &lt;target&gt;1.8&lt;/target&gt;
              &lt;/configuration&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;enforce&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;enforce&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;rules&gt;
                              &lt;requireUpperBoundDeps/&gt;
                          &lt;/rules&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifest&gt;
                          &lt;mainClass&gt;pl.test.Main&lt;/mainClass&gt;
                      &lt;/manifest&gt;
                  &lt;/archive&gt;
                  &lt;descriptorRefs&gt;
                      &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
                  &lt;/descriptorRefs&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>And this is the exception when I try to start <code>gRPC</code> server with <code>SSL</code> context:</p>
  
  <pre><code>Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: failed to load the required native library
          at io.netty.handler.ssl.OpenSsl.ensureAvailability(OpenSsl.java:346)
          at io.netty.handler.ssl.ReferenceCountedOpenSslContext.&lt;init&gt;(ReferenceCountedOpenSslContext.java:202)
          at io.netty.handler.ssl.OpenSslContext.&lt;init&gt;(OpenSslContext.java:43)
          at io.netty.handler.ssl.OpenSslServerContext.&lt;init&gt;(OpenSslServerContext.java:347)
          at io.netty.handler.ssl.OpenSslServerContext.&lt;init&gt;(OpenSslServerContext.java:335)
          at io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:422)
          at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:447)
          at pl.test.grpc.GrpcServer.start(GrpcServer.java:80)
          at pl.test.app.Main.lambda$new$0(Main.java:80)
          at java.lang.Thread.run(Thread.java:748)
  Caused by: java.lang.ClassNotFoundException: io.netty.internal.tcnative.SSL
          at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
          at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
          at java.lang.Class.forName0(Native Method)
          at java.lang.Class.forName(Class.java:348)
          at io.netty.handler.ssl.OpenSsl.&lt;clinit&gt;(OpenSsl.java:85)
          at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:194)
          at pl.test.grpc.GrpcServer.getSslContextBuilder(GrpcServer.java:72)
          ... 3 more
  </code></pre>
  
  <p>I'm building it using command:
  <code>mvn clean compile assembly:single</code></p>
  
  <p>Can someone help with creating working <code>pom</code> file? The result doesn't have to be single jar file, it might be multiple jars.</p>