MACOSX-java.lang.NoSuchMethodError:org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
所以这是一个傻瓜,我想得到一些帮助 这是我得到的错误MACOSX-java.lang.NoSuchMethodError:org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V,java,gradle,grails,amazon-s3,groovy,Java,Gradle,Grails,Amazon S3,Groovy,所以这是一个傻瓜,我想得到一些帮助 这是我得到的错误 getS3Client():异常:java.lang.NoSuchMethodError:org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V 当我尝试运行这段代码时 GrailsApplication grailsApplication // Amazon AWS S3 properties private awsProps = [ "loaded" :
getS3Client():异常:java.lang.NoSuchMethodError:org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
当我尝试运行这段代码时
GrailsApplication grailsApplication
// Amazon AWS S3 properties
private awsProps = [ "loaded" : false
, "S3Bucket" : ""
, "AccessKeyId" : ""
, "AccessKeyPsw": ""
]
def getS3Client ( ) {
try {
if ( ! awsProps.loaded ) {
loadAwsProperties()
}
def awsCreds = new BasicAWSCredentials( awsProps.AccessKeyId, awsProps.AccessKeyPsw )
AmazonS3 s3Client
s3Client = AmazonS3ClientBuilder.standard()
.withCredentials( new AWSStaticCredentialsProvider( awsCreds ) )
.withRegion( Regions.US_EAST_1 )
.build()
return s3Client
} catch ( Throwable t ) {
log.error ( "getS3Client(): Exception: ${t}" )
return null
}
}
在文件的顶部是我的依赖项
import com.amazonaws.HttpMethod
import com.amazonaws.auth.AWSStaticCredentialsProvider
import com.amazonaws.auth.BasicAWSCredentials
import com.amazonaws.regions.Regions
import com.amazonaws.services.s3.AmazonS3
import com.amazonaws.services.s3.AmazonS3ClientBuilder
import com.amazonaws.services.s3.model.*
import com.burris.portal.utils.Utils
import grails.core.GrailsApplication
import javax.imageio.ImageIO
import javax.imageio.ImageReader
import javax.imageio.stream.ImageInputStream
import java.awt.Graphics2D
import java.awt.RenderingHints
import java.awt.image.BufferedImage
import grails.gorm.transactions.Transactional
import groovy.util.logging.Log4j
这是我的build.gradle
文件依赖项
* FOR AMAZON S3 force these org.apache.httpcomponents to the top of the classpath
*/
configurations.all {
resolutionStrategy.force 'org.apache.httpcomponents:httpcore:4.4.9', 'org.apache.httpcomponents:httpclient:4.5.5'
}
/* Continue with other necessary dependencies */
dependencies {
/* FOR AMAZON S3 */
compile 'org.apache.httpcomponents:httpcore:4.4.9'
compile "org.apache.httpcomponents:httpclient:4.5.5"
compile "com.amazonaws:aws-java-sdk-s3:1.11.328"
/* FOR GROOVY HTTP */
compile "org.codehaus.groovy.modules.http-builder:http-builder:0.6"
...
}
现在是kicker,它在除了我自己的开发人员机器之外的几乎所有其他开发人员机器上都能工作,我还不知道为什么
这是一个groovy on grails项目,我使用的构建引擎是gradle with java
以下是我的版本,尽管我已经测试了其他几个在我同事的机器上工作的版本,但由于某些原因,它们不是我的
java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
gradle --version
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_181 (Oracle Corporation 25.181-b13)
OS: Mac OS X 10.13.6 x86_64
grails --version
| Grails Version: 3.2.11
| Groovy Version: 2.4.11
| JVM Version: 1.8.0_181
gradle dependencies --configuration=testRuntime | grep httpcore
+--- org.apache.httpcomponents:httpcore:4.4.9
| +--- org.apache.httpcomponents:httpcore:4.4.9
| | | +--- org.apache.httpcomponents:httpcore:4.3 -> 4.4.9
| | | \--- org.apache.httpcomponents:httpcore-nio:4.3
| | | \--- org.apache.httpcomponents:httpcore:4.3 -> 4.4.9
这是我试过的
rm-rf~/.gradle
和rm-rf./gradle
和rm build/.dependencies
取消了我对全局主目录和本地repo目录的gradle依赖,以强制重新下载所有repo,但没有成功/gradlew clean build
,但没有成功macOS High Sierra版本10.13.6
因此,任何和所有的帮助都将不胜感激,因为我在这里已经绞尽脑汁了。应用程序在几乎所有其他情况下都可以正常运行,但在该方法下会出现错误。似乎此错误:
etS3Client():异常:java.lang.NoSuchMethodError:org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
通常是由类路径中的JAR冲突引起的
您可以查看此链接以获取示例:我也遇到了同样的问题。在我的情况下,下面这个帖子帮助我解决了我的问题。 我有httpclient:4.5.9和httpclient:4.3。然后我将httpcore更新到高于4.4的版本
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.5.9</version>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.11</version>
</dependency>
org.apache.httpcomponents
httpasyncclient
4.5.9
org.apache.httpcomponents
httpcore
org.apache.httpcomponents
httpcore
4.4.11
能否提供此异常的堆栈跟踪?e、 g.您可以将catch
块中的日志语句更改为log.error(“getS3Client():Exception:${t}”,t)
-1链接-唯一指向付费墙的答案。请始终引用重要链接中最相关的部分,以防外部资源无法访问或永久脱机。好吧,当时(2年前^^^^)它不是在付费墙后面,但我必须承认,理论上你是对的。最后,上面已经引用了“相关部分”:通常是由类路径中的JAR冲突引起的。据我记忆所及,这篇KB文章中没有更多内容。。。