grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.59k stars 765 forks source link

Incompatible version of org.apache.tomcat.util.compat.JreCompat #977

Open haymant opened 3 years ago

haymant commented 3 years ago

sprint-boot-starter-web can't start after adding latest grpcweb-java.

2.2.4.RELEASE ``` An attempt was made to call a method that does not exist. The attempt was made from the following location: org.apache.catalina.startup.Tomcat.(Tomcat.java:1393) The following method did not exist: org.apache.tomcat.util.compat.JreCompat.isGraalAvailable()Z The method's class, org.apache.tomcat.util.compat.JreCompat, is available from the following locations: jar:file:/home/xxx/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.40/apache-jsp-8.5.40.jar!/org/apache/tomcat/util/compat/JreCompat.class jar:file:/home/xxx/.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.30/tomcat-embed-core-9.0.30.jar!/org/apache/tomcat/util/compat/JreCompat.class It was loaded from the following location: file:/home/xxx/.m2/repository/org/mortbay/jasper/apache-jsp/8.5.40/apache-jsp-8.5.40.jar ```
stanley-cheung commented 3 years ago

@vnorigoog Can you please take a look? Thanks.

vnorigoog commented 3 years ago

grpcweb-java code at src/connector/src doesn't refer to Tomcat. What specific code are you referring to when you say "adding latest grpcweb-java".

haymant commented 3 years ago

grpcweb-java refers to apache-jsp. Not sure why old 8.5.40 is used: image

spring-boot-starter-web calls org.apache.tomcat.util.compat.JreCompat from apache-jsp after grpcweb-java is added to the pom.xml, which conflicts with spring-boot-starter-web's tomcat version: image

vnorigoog commented 3 years ago

oh ok. I see it now. we don't directly refer to Apache-jsp. I can try to upgrade jetty-maven-plugin to more recent one (from the Jan/2020 release) but thats no guarantee that it would use the more recent apache-jsp.

The problem here is that spring is referring to a version that is different from what grpcweb-java code indirectly refers to. I am not sure if there is universal fix for this. Different frameworks can use different versions of the imported plugin's...

vnorigoog commented 3 years ago

upgrading to latest jetty plugins in https://github.com/grpc/grpc-web/pull/979

but I can't say it will fix this issue. anytime we mix multiple libraries importing their own versions of the commonly used apache plugins, this kind of issue will appear unless maven is told to take the latest version of conflicting versions..

haymant commented 3 years ago

yes, confirmed it does not work. jetty-maven-plugin refers to org.eclipse.jetty:apache-jsp 9.4 and at end both org.eclipse.jetty:apache-jsp versions refer to org.mortbay.jasper.apache-jsp 8.5.40. Considering popularity of spring boot, it'd be helpful to solve it, even it isn't universal.

colltoaction commented 3 years ago

This seems to solve the issue from an end user perspective (i.e I have a Spring Boot + grpc project):

configurations {
    runtime.exclude group: 'org.mortbay.jasper', module: 'apache-jsp'
}