【发布时间】:2019-10-22 18:56:13
【问题描述】:
@Service
public class RequestSender {
private static final Logger logger = LoggerFactory.getLogger(RequestSender.class);
@Autowired
private RestTemplate restTemplate;
public MbsFtResponseData sendJsonDataToMBS(final MBSTransactionData transactionData) {
String mbsUrl = MBSConfigConstants.mbsUrl;
try {
logger.info("Sending request method Is Initiated");
HttpEntity<MBSTransactionData> httpEntity = new HttpEntity<>(transactionData);
ResponseEntity<MbsFtResponseData> response = restTemplate.exchange(mbsUrl, HttpMethod.POST, httpEntity,
MbsFtResponseData.class);
if (response != null) {
HttpStatus status = response.getStatusCode();
if (status.is2xxSuccessful()) {
logger.info("Response getting back is succeded with the status code {}", status.value());
return response.getBody();
} else {
logger.error("ERROR Response getting back is with the status code {}", status.value());
throw new BBPSMBSException("Error is while connecting to mBS server", status.value());
}
} else {
logger.error("Null value::::::::::::response is null");
}
} catch (Exception e) {
e.printStackTrace();
logger.error("ERROR :::{}:: is occered ", e.getCause());
}
return new MbsFtResponseData("Server Not responding or Busy", 500, "FAILED");
}
}
java.lang.NullPointerException at com.npst.bbps.middleware.mbs.RequestSender.sendJsonDataToMBS(RequestSender.java:26) at com.npst.bbps.middleware.mbs.MbsftServiceImpl.mbsFundTransfer(MbsftServiceImpl.java:27) at com.npst.bbps.middleware.controller.ThirdPartyIntegrationCtrl.initiateRefund(ThirdPartyIntegrationCtrl.java:64) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
【问题讨论】:
-
代码中的第 26 行是什么?在该行,您的应用程序收到一个它无法处理的 NULL 值。
-
请务必在查询中提供完整信息。无法弄清楚原始帖子中的空值。
-
检查第 26 行的空引用
-
您能否展示一下
restTemplate的 bean 配置? -
它的工作现在@Autowiring 在我身边不起作用
标签: java rest spring-boot