java.lang.BootstrapMethodError:雅典娜java类调用站点初始化异常

RCode:

我在AWS端有一个Athena数据库。我想访问它并进行一些查询。这是我的.java类

客户建设者

public class athenaCodeFactory {
    private final AthenaClientBuilder builder = AthenaClient.builder()
            .region(Region.US_WEST_2).credentialsProvider(EnvironmentVariableCredentialsProvider.create());

public AthenaClient createClient() {
        return builder.build();
    }
}

叫做java类

public class athenaReportsClient {

    private static String solutionId=null;
    private static String bucketName=null;
    private static String tenantId=null;
    private static String ATHENA_OUTPUT_BUCKET=null;
    private static String ATHENA_DEFAULT_DATABASE=null;
    private static String ATHENA_SAMPLE_QUERY=null;
    private static String tenantDb=null;

    public static final long SLEEP_AMOUNT_IN_MS = 1000;
    public athenaReportsClient(String solutionId, String tenantId,String bucketName){
        this.solutionId=solutionId;
        this.tenantId=tenantId;
        this.bucketName=bucketName; 
        this.ATHENA_OUTPUT_BUCKET="s3://"+bucketName+"/"+solutionId;
        System.out.println("bucketloc"+ATHENA_OUTPUT_BUCKET);

        this.tenantDb="xyz";



        System.out.println("tenanentDB:"+tenantDb); 



    }

     public static final int CLIENT_EXECUTION_TIMEOUT = 100000;

            /**
             * AthenaClientClientBuilder to build Athena with the following properties:
             * - Set the region of the client
             * - Use the instance profile from the EC2 instance as the credentials provider
             * - Configure the client to increase the execution timeout.
             */


     public void executeQuery(String tableType) throws InterruptedException {
            // Build an AthenaClient client

         athenaCodeFactory factory = new athenaCodeFactory ();
            AthenaClient athenaClient = factory.createClient();

            String queryExecutionId = submitAthenaQuery(athenaClient,tableType);

            waitForQueryToComplete(athenaClient, queryExecutionId);

            processResultRows(athenaClient, queryExecutionId);
        }
     /**
      * @tableType: "events", "reports"
      */
     private static void getDBName(String tableType){
         switch(tableType){
            case "events": ATHENA_DEFAULT_DATABASE=tenantDb;
                            ATHENA_SAMPLE_QUERY="select * from "+tenantDb+".all_"+solutionId+";";
                            break;
            case "reports": ATHENA_DEFAULT_DATABASE=solutionId;
                            ATHENA_SAMPLE_QUERY="select * from "+solutionId+".reports"+";";
                            break;
            case "default": new RuntimeException("No such table type"+tableType);
         }
     }

        /**
         * Submits a sample query to Athena and returns the execution ID of the query.
         */
        private static String submitAthenaQuery(AthenaClient athenaClient,String tableType) {
            // The QueryExecutionContext allows us to set the Database.
            getDBName(tableType);
            System.out.println("Athena Data base:"+ATHENA_DEFAULT_DATABASE);
            System.out.println("Athena Query:"+ATHENA_SAMPLE_QUERY);
            System.out.println("Athena output bucket:"+ATHENA_OUTPUT_BUCKET);

            QueryExecutionContext queryExecutionContext = QueryExecutionContext.builder()
                    .database(ATHENA_DEFAULT_DATABASE).build();

            // The result configuration specifies where the results of the query should go in S3 and encryption options
            ResultConfiguration resultConfiguration = ResultConfiguration.builder()
                    // You can provide encryption options for the output that is written.
                    // .withEncryptionConfiguration(encryptionConfiguration)
                    .outputLocation(ATHENA_OUTPUT_BUCKET).build();

            // Create the StartQueryExecutionRequest to send to Athena which will start the query.
            StartQueryExecutionRequest startQueryExecutionRequest = StartQueryExecutionRequest.builder()
                    .queryString(ATHENA_SAMPLE_QUERY)
                    .queryExecutionContext(queryExecutionContext)
                    .resultConfiguration(resultConfiguration).build();

            StartQueryExecutionResponse startQueryExecutionResponse = athenaClient.startQueryExecution(startQueryExecutionRequest);
            return startQueryExecutionResponse.queryExecutionId();
        }

        /**
         * Wait for an Athena query to complete, fail or to be cancelled. This is done by polling Athena over an
         * interval of time. If a query fails or is cancelled, then it will throw an exception.
         */

        private static void waitForQueryToComplete(AthenaClient athenaClient, String queryExecutionId) throws InterruptedException {
            GetQueryExecutionRequest getQueryExecutionRequest = GetQueryExecutionRequest.builder()
                    .queryExecutionId(queryExecutionId).build();

            GetQueryExecutionResponse getQueryExecutionResponse;
            boolean isQueryStillRunning = true;
            while (isQueryStillRunning) {
                getQueryExecutionResponse = athenaClient.getQueryExecution(getQueryExecutionRequest);
                String queryState = getQueryExecutionResponse.queryExecution().status().state().toString();
                if (queryState.equals(QueryExecutionState.FAILED.toString())) {
                    throw new RuntimeException("Query Failed to run with Error Message: " + getQueryExecutionResponse
                            .queryExecution().status().stateChangeReason());
                } else if (queryState.equals(QueryExecutionState.CANCELLED.toString())) {
                    throw new RuntimeException("Query was cancelled.");
                } else if (queryState.equals(QueryExecutionState.SUCCEEDED.toString())) {
                    isQueryStillRunning = false;
                } else {
                    // Sleep an amount of time before retrying again.
                    Thread.sleep(SLEEP_AMOUNT_IN_MS);
                }
                System.out.println("Current Status is: " + queryState);
            }
        }

        /**
         * This code calls Athena and retrieves the results of a query.
         * The query must be in a completed state before the results can be retrieved and
         * paginated. The first row of results are the column headers.
         */
        private static void processResultRows(AthenaClient athenaClient, String queryExecutionId) {
            GetQueryResultsRequest getQueryResultsRequest = GetQueryResultsRequest.builder()
                    // Max Results can be set but if its not set,
                    // it will choose the maximum page size
                    // As of the writing of this code, the maximum value is 1000
                    // .withMaxResults(1000)
                    .queryExecutionId(queryExecutionId).build();

            GetQueryResultsIterable getQueryResultsResults = athenaClient.getQueryResultsPaginator(getQueryResultsRequest);

            for (GetQueryResultsResponse Resultresult : getQueryResultsResults) {
                List<ColumnInfo> columnInfoList = Resultresult.resultSet().resultSetMetadata().columnInfo();
                List<Row> results = Resultresult.resultSet().rows();
                processRow(results, columnInfoList);
            }
        }

        private static void processRow(List<Row> row, List<ColumnInfo> columnInfoList) {
            for (ColumnInfo columnInfo : columnInfoList) {
               System.out.println("Col:"+columnInfo.name());
                }
            for (Row rw : row) {
                   System.out.println(rw.data());
                }
        }


}

现在,该行StartQueryExecutionResponse startQueryExecutionResponse = athenaClient.startQueryExecution(startQueryExecutionRequest);

抛出一些异常

java.lang.BootstrapMethodError:在java.lang.invoke.CallSite.makeSite(CallSite.java:341)处调用网站初始化异常

我检查了很少的资源,他们说这可能是由于某些依赖性问题。我尝试了他们的建议并使用了以下内容

pom.xml

<dependencies>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.5</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.9</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.5.2</version>
        </dependency>
[...]
 <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>auth</artifactId>
        <version>2.8.3</version>
    </dependency>
    <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>athena</artifactId>
        <version>2.8.3</version>
    </dependency> 
    <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>apache-client</artifactId>

        </dependency> 
        <dependency>
        <groupId>software.amazon.awssdk</groupId>
        <artifactId>sdk-core</artifactId>
        <version>2.5.19</version>
    </dependency>
[...]
</dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>software.amazon.awssdk</groupId>
                <artifactId>bom</artifactId>
                <version>2.5.19</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

堆栈跟踪

java.lang.BootstrapMethodError: call site initialization exception
    at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
    at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
    at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.transformHeaders(ApacheHttpClient.java:269)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.createResponse(ApacheHttpClient.java:254)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:234)
    at software.amazon.awssdk.http.apache.ApacheHttpClient.access$500(ApacheHttpClient.java:102)
    at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:214)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:66)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:51)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:35)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:64)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:36)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:77)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:39)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:113)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:86)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:62)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage.execute(RetryableStage.java:42)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:57)
    at software.amazon.awssdk.core.internal.http.StreamManagingStage.execute(StreamManagingStage.java:37)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.executeWithTimer(ApiCallTimeoutTrackingStage.java:80)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:60)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallTimeoutTrackingStage.execute(ApiCallTimeoutTrackingStage.java:42)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:37)
    at software.amazon.awssdk.core.internal.http.pipeline.stages.ExecutionFailureExceptionReportingStage.execute(ExecutionFailureExceptionReportingStage.java:26)
    at software.amazon.awssdk.core.internal.http.AmazonSyncHttpClient$RequestExecutionBuilderImpl.execute(AmazonSyncHttpClient.java:240)
    at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.invoke(BaseSyncClientHandler.java:96)
    at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:120)
    at software.amazon.awssdk.core.client.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:73)
    at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:44)
    at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:55)
    at software.amazon.awssdk.services.athena.DefaultAthenaClient.startQueryExecution(DefaultAthenaClient.java:1116)
    at com.xyz.dmp.qa.myproject.functional.help.athenaReportsClient.submitAthenaQuery(athenaReportsClient.java:116)
    at com.xyz.dmp.qa.myproject.functional.help.athenaReportsClient.executeQuery(athenaReportsClient.java:70)
    at com.xyz.dmp.qa.myproject.functional.test.myprojectDMTestCsaes.getTransformationJobDeatils(myprojectDMTestCsaes.java:267)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:663)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:849)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1157)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
    at org.testng.TestRunner.privateRun(TestRunner.java:771)
    at org.testng.TestRunner.run(TestRunner.java:621)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
    at org.testng.SuiteRunner.run(SuiteRunner.java:259)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1200)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1125)
    at org.testng.TestNG.run(TestNG.java:1033)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.invoke.LambdaConversionException: Invalid receiver type interface org.apache.http.Header; not a subtype of implementation type interface org.apache.http.NameValuePair
    at java.lang.invoke.AbstractValidatingLambdaMetafactory.validateMetafactoryArgs(AbstractValidatingLambdaMetafactory.java:233)
    at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:303)
    at java.lang.invoke.CallSite.makeSite(CallSite.java:302)
    ... 66 more
sudipn:

httpcore / RELEASE_NOTES
HTTPCORE-499:使接口Header扩展NameValuePair。

更新httpcore到至少版本4.4.9

<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.9</version>
</dependency>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

java.lang.NoClassDefFoundError:无法初始化类javax.media.jai.JAI

java.lang.NoClassDefFoundError:无法初始化类org.bytedeco.javacpp.avutil

原因:java.lang.IllegalStateException:ParsePlugins已经初始化

java.lang.NoClassDefFoundError:无法初始化类java.awt.Toolkit

java.lang.NoClassDefFoundError:无法初始化类XXX

VM初始化期间发生错误(java / lang / NoClassDefFoundError:java / lang / Object)

原因:java.lang.NoClassDefFoundError:无法初始化类com.jayway.restassured.RestAssured

拒绝对先前失败的类java.lang.Class <nt>进行重新初始化:java.lang.NoClassDefFoundError

java.lang.BootstrapMethodError:初始化Retrofit时,调用站点#4引导程序方法发生异常

java.lang.NoClassDefFoundError:无法初始化类xxx.xxx.xxx.HibernateUtil

春季:java.lang.NoClassDefFoundError:无法初始化类

java.lang.NoClassDefFoundError:无法初始化com.datastax.driver.core.Cluster类

Zeppelin java.lang.NoClassDefFoundError:无法初始化类org.apache.spark.rdd.RDDOperationScope $

关于java.lang.NoClassDefFoundError:无法初始化类org.xerial.snappy.Snappy

java.lang.IllegalStateException:无法初始化插件:MockMaker

java.lang.NoClassDefFoundError:无法初始化com.googlecode.objectify.ObjectifyService类

Corda-无法初始化主类胶囊(引起原因:java.lang.NoClassDefFoundError:java / lang / instrument / Instrumentation)

原因:java.lang.NoClassDefFoundError:无法初始化类javassist.util.proxy.DefineClassHelper

java.lang.IllegalStateException:CameraX尚未初始化

java.lang.BootstrapMethodError:CameraX(1.0.0-alpha06)上的调用站点#2引导程序方法异常

java.lang.NoClassDefFoundError:无法初始化类org.springframework.mail.javamail.SmartMimeMessage

java.lang.NoClassDefFoundError:无法初始化类sun.nio.ch.FileChannelImpl

VM初始化期间发生错误:java.lang.UnsatisfiedLinkError:java.lang.Class.desiredAssertionStatus0(Ljava / lang / Class;)

java.lang.OutOfMemory异常

Java,线程“主”中的异常java.lang.NullPointerException由于未初始化对象而导致

java.lang.NoClassDefFoundError:无法初始化类org.apache.commons.logging.LogFactory

使用Spring Boot时未初始化java.lang.IllegalState异常LifecylceProcessor和ApplicationEventMulticaster

java.lang.IllegalStateException:ServletConfig尚未初始化

线程“主”中的异常java.lang.NoClassDefFoundError无法初始化类org.bytedeco.javacpp.avutil

TOP 榜单

  1. 1

    来自Microsoft Office加载项taskpane.js的MySQL驱动程序模块的空引用

  2. 2

    使用AWS Cognito和React的仅限Facebook / Google的登录名(无用户名/密码)

  3. 3

    创建Windows Phone 8应用并将其连接到数据库的最佳方法(最好是SQL Server)

  4. 4

    为什么Java中的System.out.println()打印到控制台?

  5. 5

    卷曲函数无法解析来自bash中变量的代理

  6. 6

    是什么在Android的consumer-rules.pro和proguard-rules.pro之间的区别?

  7. 7

    设置与Apache POI Excel表散点图标记图标的颜色

  8. 8

    将Qt Pyside2与asyncio await语法一起使用?

  9. 9

    崇高的文字+蟒蛇的蟒蛇

  10. 10

    任务':app:minifyReleaseWithR8'.java.lang.NullPointerException的执行失败(无错误消息)

  11. 11

    OpenJDK的和AdoptOpenJDK的区别

  12. 12

    大型数据集缓存到Spark内存中时,“超出了GC开销限制”(通过sparklyr和RStudio)

  13. 13

    “执行测试CMAKE_HAVE_LIBC_PTHREAD”失败实际上是什么意思?

  14. 14

    使用Core 2.2中的Identity,如何在关闭浏览器15分钟后保持会话活动?

  15. 15

    React中的ForwardRefExoticComponent和ForwardRefRenderFunction有什么区别?

  16. 16

    猫鼬查找结果,然后将字段替换为findOne

  17. 17

    如何降级Google Colab的Torch版本

  18. 18

    Keras提前停止回调错误,val_loss指标不可用

  19. 19

    如何避免VSCode中的“导入路径不能以.ts扩展名结尾”错误?

  20. 20

    Nuxt.JS:如何在页面中获取路由URL参数

  21. 21

    是否有为什么会AccessibilityManager.sInstance导致内存泄漏的一个原因?

热门标签

归档