gpt4 book ai didi

java.lang.reflect.MalformedParameterizedTypeException 试图向 API 发出请求

转载 作者:搜寻专家 更新时间:2023-11-01 00:56:17 26 4
gpt4 key购买 nike

您好,我是编程新手,英语不是我的母语,所以我为错误表示歉意。

尝试向 API 发出 http 请求时出现以下异常

[ERROR   ] SRVE0777E: Exception thrown by application class 'org.springframework.web.servlet.FrameworkServlet.processRequest:973'
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240)
at [internal classes]
Caused by: java.lang.reflect.MalformedParameterizedTypeException
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.validateConstructorArguments(ParameterizedTypeImpl.java:60)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.<init>(ParameterizedTypeImpl.java:53)
at sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl.make(ParameterizedTypeImpl.java:95)
at sun.reflect.generics.factory.CoreReflectionFactory.makeParameterizedType(CoreReflectionFactory.java:105)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:140)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:100)
at java.lang.Class.getGenericInterfaces(Class.java:814)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.getAllContractsFromInterfaces(ReflectionHelper.java:366)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.getAdvertisedTypesFromClass(ReflectionHelper.java:351)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.getAdvertisedTypesFromObject(ReflectionHelper.java:391)
at org.glassfish.hk2.utilities.BuilderHelper.createConstantDescriptor(BuilderHelper.java:392)
at org.glassfish.hk2.utilities.binding.AbstractBindingBuilder$InstanceBasedBindingBuilder.complete(AbstractBindingBuilder.java:286)
at org.glassfish.hk2.utilities.binding.AbstractBinder.resetBuilder(AbstractBinder.java:179)
at org.glassfish.hk2.utilities.binding.AbstractBinder.complete(AbstractBinder.java:189)
at org.glassfish.hk2.utilities.binding.AbstractBinder.bind(AbstractBinder.java:173)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:406)
at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:86)
at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:118)
at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:115)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:322)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:721)
at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:284)
at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:126)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:98)
at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:91)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:408)
at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:308)
at br.com.MyLOL.home.LOLClient.getSummonerInfo(LOLClient.java:23)
at br.com.MyLOL.summoner.SummonerService.getSummonerInfo(SummonerService.java:16)
at br.com.MyLOL.home.HomeController.result(HomeController.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
... 6 more

[ERROR ] SRVE0315E: An execption occurred: com.ibm.ws.webcontainer.webapp.WebAppErrorReport: org.springframework.web.util.NestedServletException: Request processing failed&#59; nested exception is java.lang.reflect.MalformedParameterizedTypeException
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:595)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1240)
at [internal classes]

这是maven pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyLOL</groupId>
<artifactId>MyLOL</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<repositories>

</repositories>

<dependencies>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.14</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.18.3</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>

抛出异常的方法

public Summoner  getSummonerInfo(Summoner summoner) {
javax.ws.rs.client.Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://" + summoner.getSummonerRegion()+".api.pvp.net");
String summonerInfo = target.path("api/lol/"+ summoner.getSummonerRegion() +"/v1.4/summoner/by-name/" + summoner.getSummonerName() + "?api_key=11111111111").request().get(String.class);
System.out.println(summonerInfo);
return new Summoner();
}

我知道还有什么与某人相关以帮助找到解决方案,所以请向我询问您可能需要的任何其他内容

最佳答案

据我所知,无论您尝试获取的字符串是什么,它都不是字符串。也许您正在使用的那个 API(我没有调查那个)试图以一种不可能的方式构造那个字符串。

关于java.lang.reflect.MalformedParameterizedTypeException 试图向 API 发出请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27508315/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com