bazel-maven-proxy icon indicating copy to clipboard operation
bazel-maven-proxy copied to clipboard

java.lang.NoSuchMethodError thrown when using TLS

Open ddelnano opened this issue 3 years ago • 3 comments

I'm trying to use this project and I ran into an issue when checking to see if I had it set up correctly. The following steps detail how to reproduce my issue:

  1. Create ~/.m2/repositories with the following config (modified from the example provided in the repo)
vagrant@vagrant:/code/bazel-maven-proxy$ cat ~/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings
  xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
>

  <servers>
    <server>
      <id>server1</id>
      <username>abc</username>
      <password>def</password>
    </server>

    <server>
      <id>central</id>
      <username>123</username>
      <password>456</password>
    </server>

    <server>
      <id>incomplete</id>
    </server>

    <server>
      <id>mirror1</id>
      <username>bar</username>
      <password>foo</password>
    </server>

  </servers>

  <mirrors>
    <mirror>
      <mirrorOf>*,!releases,!snapshots</mirrorOf>
      <id>mirror1</id>
      <url>https://repo.maven.apache.org/maven2</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>myprofile</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo.maven.apache.org/maven2</url>
        </repository>
        <repository>
          <id>releases</id>
          <url>https://www.releases-repo.com/</url>
        </repository>
        <repository>
          <id>snapshots</id>
          <url>https://repo.maven.apache.org/maven2</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>incomplete</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

</settings>
  1. Apply the following git diff to the simplelogger.properties file to ensure more verbose logs are printed
diff --git a/server/src/main/resources/simplelogger.properties b/server/src/main/resources/simplelogger.properties
index 1bf764d..b0b76da 100644
--- a/server/src/main/resources/simplelogger.properties
+++ b/server/src/main/resources/simplelogger.properties
@@ -1,10 +1,9 @@
-org.slf4j.simpleLogger.defaultLogLevel=info
+org.slf4j.simpleLogger.defaultLogLevel=debug

 org.slf4j.simpleLogger.logFile=System.out
 org.slf4j.simpleLogger.cacheOutputStream=true

 org.slf4j.simpleLogger.log.com.salesforce.bazel=debug
-org.slf4j.simpleLogger.log.org.eclipse.jetty=warn

 org.slf4j.simpleLogger.showDateTime=true
 org.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss:SSS
  1. Run the maven proxy
$ bazel run //:maven_proxy
  1. Verify that the request fails and see the java.lang.NoSuchMethodError exception is thrown in the logs
vagrant@vagrant:/code/bazel-maven-proxy$ curl  -k   https://localhost:8499/maven
curl: (52) Empty reply from server

# See the following in the 'bazel run' output
java.lang.NoSuchMethodError: 'void org.eclipse.jetty.http2.parser.ServerParser.<init>(org.eclipse.jetty.io.ByteBufferPool, org.eclipse.jetty.http2.parser.ServerParser$Listener, int, int)'
        at org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory.newServerParser(AbstractHTTP2ServerConnectionFactory.java:252)
        at org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory.newConnection(AbstractHTTP2ServerConnectionFactory.java:238)
        at org.eclipse.jetty.server.NegotiatingServerConnection.onFillable(NegotiatingServerConnection.java:124)
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:319)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:523)
        at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:372)
        at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:158)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
        at org.eclipse.jetty.io.SocketChannelEndPoint$1.run(SocketChannelEndPoint.java:101)
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:791)
        at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:913)
        at java.base/java.lang.Thread.run(Thread.java:834)

I would greatly appreciate if you could help me resolve this issue. This project would be very useful and I'm unsure how to resolve this specific exception.

ddelnano avatar May 24 '22 02:05 ddelnano

Thanks for reporting. It looks like this is a TLS specific error.

Can you try starting with --unsecure-port=8099 and then use http://localhost:8099/maven (without TLS)? This is a workaround but I need to see what got mixed up in the Jetty update.

guw avatar May 24 '22 10:05 guw

Access over http seems to work 👍

vagrant@vagrant:/code/netty-tcnative$ curl  localhost:8099/maven
Repository Mappings
-------------------
central --> https://repo.maven.apache.org/maven2
releases --> https://www.releases-repo.com/
snapshots --> https://repo.maven.apache.org/maven2

I assume there should be a way to surface this error at compile time. I was surprised to find out that identifying this error required verbose logging to uncover.

ddelnano avatar May 24 '22 12:05 ddelnano

I have to do some research. I'm using only the non TLS access. Thus, I haven't recognize. I think it's a bug somewhere in the dependency graph. We are consuming incompatible Jetty bits.

guw avatar May 24 '22 12:05 guw