编者注
要编写unity请求文件,首先应当通过jmeter测试文件请求。但是创建了线程组,在线程组下面挂载HTTP请求和查看结果树,点击运行,一直显示错误。
服务端日志
Spring服务端仅仅回复说json转换出现问题,但是通过浏览器能够正常下载。
11:20:35,175 DEBUG DispatcherServlet:869 - DispatcherServlet with name 'Spring MVC Dispatcher Servlet' processing GET request for [/assets/2017-11-20/2017-11-20%2017-40-10-054_2017-11-20_05-40-09.unity]
11:20:35,196 DEBUG RequestMappingHandlerMapping:310 - Looking up handler method for path /assets/2017-11-20/2017-11-20 17-40-10-054_2017-11-20_05-40-09.unity
11:20:35,216 DEBUG RequestMappingHandlerMapping:317 - Returning handler method [public org.springframework.http.ResponseEntity org.aicfve.asset.AssetController.download(javax.servlet.http.HttpServletRequest)]
11:20:35,219 DEBUG DispatcherServlet:955 - Last-Modified value for [/assets/2017-11-20/2017-11-20%2017-40-10-054_2017-11-20_05-40-09.unity] is: -1
run logger... All OK
11:20:35,382 DEBUG ExceptionHandlerExceptionResolver:133 - Resolving exception from handler [public org.springframework.http.ResponseEntity org.aicfve.asset.AssetController.download(javax.servlet.http.HttpServletRequest)]: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.core.io.InputStreamResource["inputStream"]->java.io.FileInputStream["fd"])
11:20:35,385 DEBUG ResponseStatusExceptionResolver:133 - Resolving exception from handler [public org.springframework.http.ResponseEntity org.aicfve.asset.AssetController.download(javax.servlet.http.HttpServletRequest)]: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.core.io.InputStreamResource["inputStream"]->java.io.FileInputStream["fd"])
11:20:35,385 DEBUG DefaultHandlerExceptionResolver:133 - Resolving exception from handler [public org.springframework.http.ResponseEntity org.aicfve.asset.AssetController.download(javax.servlet.http.HttpServletRequest)]: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.core.io.InputStreamResource["inputStream"]->java.io.FileInputStream["fd"])
11:20:35,386 WARN DefaultHandlerExceptionResolver:407 - Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class java.io.FileDescriptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: org.springframework.core.io.InputStreamResource["inputStream"]->java.io.FileInputStream["fd"])
11:20:35,386 DEBUG DispatcherServlet:1048 - Null ModelAndView returned to DispatcherServlet with name 'Spring MVC Dispatcher Servlet': assuming HandlerAdapter completed request handling
11:20:35,387 DEBUG DispatcherServlet:1000 - Successfully completed request
响应数据
点击查看接过树的响应数据才发现真正的异常问题
org.apache.http.ConnectionClosedException: Premature end of Content-Length delimited message body (expected: 18017; received: 9365
at org.apache.http.impl.io.ContentLengthInputStream.read(ContentLengthInputStream.java:178)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:135)
at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:148)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.readResponse(HTTPSamplerBase.java:1814)
at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.readResponse(HTTPAbstractImpl.java:440)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:474)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1189)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1178)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:498)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:424)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:255)
at java.lang.Thread.run(Unknown Source)
解决方法
点击HTTP请求,点击标签栏Advanced。在Client implementation下的Implementation选择Java