You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/10/30 08:10:27 UTC

[GitHub] [servicecomb-java-chassis] sxcooler opened a new issue #2629: not allow complex type for header parameter

sxcooler opened a new issue #2629:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2629


   背景是想要获得一次请求里的所有header参数
   于是尝试使用@RequestHeader Map<String, String> headers
   或者@RequestHeader HttpHeaders headers (HttpHeaders本身就是MultiValueMap和Serializable的实现)
   但是得到如标题的报错:not allow complex type for header parameter,部分日志如下
   ```
   2021-10-30 16:00:28,652 |-ERROR[restartedMain] LINE: 771 TraceId:- ServiceName:- in org.springframework.boot.SpringApplication : Application startup failed
   java.lang.IllegalStateException: ServiceComb init failed.
   	at org.apache.servicecomb.core.SCBEngine.init(SCBEngine.java:217)
   	at org.apache.servicecomb.core.CseApplicationListener.onApplicationEvent(CseApplicationListener.java:81)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
   	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
   	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
   	at org.springframework.boot.context.event.EventPublishingRunListener.finished(EventPublishingRunListener.java:101)
   	at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:79)
   	at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
   	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
   	at com.xxx.xxx.business.Application.main(Application.java:26)
   	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.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
   Caused by: java.lang.Error: generate operation swagger failed, com.xxx.xxx.business.api.OrderApiController:confirmOrder
   	at org.apache.servicecomb.swagger.generator.core.SwaggerGenerator.scanMethods(SwaggerGenerator.java:280)
   	at org.apache.servicecomb.swagger.generator.core.SwaggerGenerator.generate(SwaggerGenerator.java:140)
   	at org.apache.servicecomb.core.definition.schema.AbstractSchemaFactory.generateSwagger(AbstractSchemaFactory.java:102)
   	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.createSchema(ProducerSchemaFactory.java:115)
   	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.createSchema(ProducerSchemaFactory.java:54)
   	at org.apache.servicecomb.core.definition.schema.AbstractSchemaFactory.getOrCreateSchema(AbstractSchemaFactory.java:58)
   	at org.apache.servicecomb.core.definition.schema.ProducerSchemaFactory.getOrCreateProducerSchema(ProducerSchemaFactory.java:76)
   	at org.apache.servicecomb.provider.rest.common.RestProducerProvider.init(RestProducerProvider.java:45)
   	at org.apache.servicecomb.core.provider.producer.ProducerProviderManager.init(ProducerProviderManager.java:54)
   	at org.apache.servicecomb.core.SCBEngine.doInit(SCBEngine.java:235)
   	at org.apache.servicecomb.core.SCBEngine.init(SCBEngine.java:206)
   	... 18 common frames omitted
   Caused by: java.lang.Error: not allow complex type for header parameter, method=com.xxx.xxx.business.api.OrderApiController:confirmOrder, paramIdx=1, type=org.springframework.http.HttpHeaders
   	at org.apache.servicecomb.swagger.generator.core.utils.ParamUtils.setParameterType(ParamUtils.java:138)
   	at org.apache.servicecomb.swagger.generator.core.processor.parameter.AbstractParameterProcessor.setParameterType(AbstractParameterProcessor.java:47)
   	at org.apache.servicecomb.swagger.generator.core.processor.parameter.AbstractParameterProcessor.fillParameter(AbstractParameterProcessor.java:41)
   	at org.apache.servicecomb.swagger.generator.springmvc.processor.annotation.RequestHeaderAnnotationProcessor.fillParameter(RequestHeaderAnnotationProcessor.java:46)
   	at org.apache.servicecomb.swagger.generator.springmvc.processor.annotation.RequestHeaderAnnotationProcessor.fillParameter(RequestHeaderAnnotationProcessor.java:28)
   	at org.apache.servicecomb.swagger.generator.core.processor.parameter.AbstractParameterProcessor.process(AbstractParameterProcessor.java:33)
   	at org.apache.servicecomb.swagger.generator.core.OperationGenerator.processByParameterAnnotation(OperationGenerator.java:324)
   	at org.apache.servicecomb.swagger.generator.core.OperationGenerator.scanMethodParameters(OperationGenerator.java:289)
   	at org.apache.servicecomb.swagger.generator.core.OperationGenerator.generate(OperationGenerator.java:181)
   	at org.apache.servicecomb.swagger.generator.core.SwaggerGenerator.scanMethods(SwaggerGenerator.java:276)
   	... 28 common frames omitted
   ```
   
   我搜到一个类似issue: https://github.com/apache/servicecomb-java-chassis/issues/1737
   但是它的解决方法对我不适用。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2629: not allow complex type for header parameter

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2629:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2629#issuecomment-955842299


   servicecomb不支持这样的用法,接口参数需要满足swagger定义要求,不能使用“不确定”的参数信息。 
   你可以考虑使用 `HttpServerFilter`, 将HTTP的headers编码后存储到 `InvocationContext` 里面, 然后从  `InvocationContext`  读取所有 header。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] sxcooler commented on issue #2629: not allow complex type for header parameter

Posted by GitBox <gi...@apache.org>.
sxcooler commented on issue #2629:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2629#issuecomment-962370871


   > servicecomb不支持这样的用法,接口参数需要满足swagger定义要求,不能使用“不确定”的参数信息。 你可以考虑使用 `HttpServerFilter`, 将HTTP的headers编码后存储到 `InvocationContext` 里面, 然后从 `InvocationContext` 读取所有 header。
   
   谢谢


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] sxcooler closed issue #2629: not allow complex type for header parameter

Posted by GitBox <gi...@apache.org>.
sxcooler closed issue #2629:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2629


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org