嗨,我是初学者,英语不是我的母语,所以我为错误道歉。
我在尝试向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; 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>
方法trowing异常
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();
}
}
Idk还有什么与某些人有关,以帮助找到解决方案,所以请向我询问你可能需要的任何其他东西
答案 0 :(得分:0)
据我所知,无论你想要获得什么字符串,它都不是字符串。也许您正在使用的API(我没有考虑过)尝试以不可能的方式构造该String。