Google Java API 与 ColdFusion CFHTTP 冲突?
Google Java API conflicted with ColdFusion CFHTTP?
我尝试将所有在 google-api-client-assembly-1.20.0-1.20.01.zip
中找到的 JAR(从 https://developers.google.com/api-client-library/java/google-api-java-client/download 下载)复制到 {cf_root}/lib
,重新启动 ColdFusion,一切都正常加载。但是,当我使用 <cfhttp>
:
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [CfmServlet] in context with path [/] threw exception [org.apache.http.impl.client.DefaultHttpClient.setRedirectStrategy(Lorg/apache/http/client/RedirectStrategy;)V] with root cause
java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.setRedirectStrategy(Lorg/apache/http/client/RedirectStrategy;)V
at coldfusion.tagext.net.HttpTag.createConnection(HttpTag.java:1728)
at coldfusion.tagext.net.HttpTag.connHelper(HttpTag.java:928)
at coldfusion.tagext.net.HttpTag.doEndTag(HttpTag.java:1219)
当我从 {cf_root}/lib
中删除所有 google 罐子时,它再次按预期工作。我的解决方法是使用 tokeninfo 端点而不是 com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier
,但 Google 建议不要将其用于生产。
The easiest way to validate an ID token is to use the tokeninfo
endpoint. Calling this endpoint involves an additional network request
that does most of the validation for you, but introduces some latency
and the potential for network errors. For these reasons, it is
suitable only for deployments with fewer than 100 monthly active
users, as well as for debugging and informational purposes.
https://developers.google.com/identity/sign-in/ios/backend-auth
一旦将 google 中的 Jar 加载到 ColdFusion 中,是否有更好的解决方案来解决 org.apache.http.impl.client.DefaultHttpClient
被解析为其他内容的问题?
(来自评论)
听起来有冲突的 jar 是 httpclient-4.0.1.jar
。删除它应该可以解决 specific 错误。但是,它可能不会是唯一的 conflict/error。很多罐子都很常见,也可以被 CF 使用,例如 commons-logging-1.1.1.jar
.
由于您使用的是 CF10,您是否尝试过使用新功能 this.javaSettings? It is basically a rip of Mark Mandel's JavaLoader.cfc 在 Application.cfc 中加载 jar。只需指定您要加载的 jar 的路径,或要检查 jar 的目录,即
THIS.javaSettings = {LoadPaths = [".\folder\",".\folder\someLib.jar"] };
显然,在使用此功能时,不要将 jar 放在 {cf_root}\lib
、 或 CF class 路径 中的任何其他位置,因为它会破坏动态 class 加载的目的。
我尝试将所有在 google-api-client-assembly-1.20.0-1.20.01.zip
中找到的 JAR(从 https://developers.google.com/api-client-library/java/google-api-java-client/download 下载)复制到 {cf_root}/lib
,重新启动 ColdFusion,一切都正常加载。但是,当我使用 <cfhttp>
:
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [CfmServlet] in context with path [/] threw exception [org.apache.http.impl.client.DefaultHttpClient.setRedirectStrategy(Lorg/apache/http/client/RedirectStrategy;)V] with root cause
java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.setRedirectStrategy(Lorg/apache/http/client/RedirectStrategy;)V
at coldfusion.tagext.net.HttpTag.createConnection(HttpTag.java:1728)
at coldfusion.tagext.net.HttpTag.connHelper(HttpTag.java:928)
at coldfusion.tagext.net.HttpTag.doEndTag(HttpTag.java:1219)
当我从 {cf_root}/lib
中删除所有 google 罐子时,它再次按预期工作。我的解决方法是使用 tokeninfo 端点而不是 com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier
,但 Google 建议不要将其用于生产。
The easiest way to validate an ID token is to use the tokeninfo endpoint. Calling this endpoint involves an additional network request that does most of the validation for you, but introduces some latency and the potential for network errors. For these reasons, it is suitable only for deployments with fewer than 100 monthly active users, as well as for debugging and informational purposes.
https://developers.google.com/identity/sign-in/ios/backend-auth
一旦将 google 中的 Jar 加载到 ColdFusion 中,是否有更好的解决方案来解决 org.apache.http.impl.client.DefaultHttpClient
被解析为其他内容的问题?
(来自评论)
听起来有冲突的 jar 是 httpclient-4.0.1.jar
。删除它应该可以解决 specific 错误。但是,它可能不会是唯一的 conflict/error。很多罐子都很常见,也可以被 CF 使用,例如 commons-logging-1.1.1.jar
.
由于您使用的是 CF10,您是否尝试过使用新功能 this.javaSettings? It is basically a rip of Mark Mandel's JavaLoader.cfc 在 Application.cfc 中加载 jar。只需指定您要加载的 jar 的路径,或要检查 jar 的目录,即
THIS.javaSettings = {LoadPaths = [".\folder\",".\folder\someLib.jar"] };
显然,在使用此功能时,不要将 jar 放在 {cf_root}\lib
、 或 CF class 路径 中的任何其他位置,因为它会破坏动态 class 加载的目的。