![](/img/trans.png)
[英]java.lang.NoSuchMethodError: org/apache/http/conn/scheme/Scheme.<init>(Ljava/lang/String;ILorg/apache/http/conn/scheme/SchemeSocketFactory;)V
[英]MACOSX - java.lang.NoSuchMethodError: org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
所以這有點笨拙,我很樂意提供幫助。
這是我得到的錯誤
getS3Client(): Exception: 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"
...
}
現在是關鍵,它可以在幾乎所有其他開發人員機器上運行,除了我自己的機器之外,我還無法弄清楚為什么。
這是grails項目的常規,而我正在使用的構建引擎是Java的gradle。
這是我的版本,盡管我已經測試了其他一些可以在我的同事的機器上工作的軟件,但是由於某些原因卻沒有被我的
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依賴關系,以強制重新下載所有存儲庫 /gradlew clean build
沒有成功 這是我的MAC OSX版本macOS High Sierra Version 10.13.6
因此,在我發揮作用之際,我們將不勝感激。 該應用程序在幾乎所有其他情況下都可以正常運行,但是在該方法上只是中斷了。
我遇到過同樣的問題。 就我而言,該波紋管可以幫助我解決問題。 在此處輸入鏈接說明
我有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>
似乎此錯誤: etS3Client(): Exception: java.lang.NoSuchMethodError: org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
通常是由類路徑中的JAR沖突引起的。
您可以檢查此鏈接以獲取示例: https : //community.hortonworks.com/content/supportkb/150327/error-javalangnosuchmethoderror-orgapachehttpimplc.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.