Title: Issues with View Resolution in Spring MVC Application on WebLogic 12c
Body:
I’m facing an issue with view resolution in my Spring MVC application when deployed on WebLogic 12c. The same application works fine on Tomcat, but on WebLogic, the view is not getting resolved correctly.
Spring Configuration:
- Spring Version: 5.3
- WebLogic Version: 12c
JSP Code:
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="CommonInclude.jsp"%>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
<%-- <%@include file="header.jsp"%> --%>
<%@include file="homeHeader.jsp"%>
<div class="content-wrapper" id="divWrapper">
<br>
<h2 class="animate-charcter" align="center">Welcome to Integra KYC Retrieval Application</h2>
</div>
<footer class="main-footer">
<div class="float-right d-none d-sm-block">
<b>Version </b>1.0.0
</div>
<strong>Copyright © <a href="#">Integra Micro Systems</a>.</strong> All rights reserved.
</footer>
</div>
</body>
</html>
HTML to append:
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html; charset=UTF-8"%>
<input type="hidden" id="ctxPath" name="ctxPath" value="<c:out value="${pageContext.request.contextPath}"/>" />
<input type="hidden" id="strMenuId" name="strMenuId" value="<c:out value="${strMenuId}"/>" />
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="<c:url value="/js/kycInfo.js"/>"></script>
<title>KYC Retrieval</title>
<style>
body {
overflow-x: hidden;
}
</style>
</head>
<div class="wrapper">
<div class="container-fluid">
<div id="kycList">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<br>
<div class="card card-primary card-outline">
<div class="card-header">
<label class="card-title">KYC Details</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
JavaScript Function:
function loadView(url) {
url = $("#ctxPath").val() + url;
var response = loadDetailsByAjax(url, "GET", null);
$("#divWrapper").html(response.respBuffer);
// Additional initialization if needed
}
Controller Method:
@RequestMapping(value = {"/reqForKycData"}, method = {RequestMethod.GET})
@ResponseBody
public BaseResponseDTO reqForkycData(HttpServletRequest request) {
log.info("[EkycController][reqForkycData]");
BaseResponseDTO baseResponseDTO = new BaseResponseDTO();
try {
baseResponseDTO.setRespBuffer(Common.resolveView(request, this.viewResolver, "KycInfo", null));
baseResponseDTO.setStatus("00");
} catch (Exception ex) {
log.error("Error ", ex);
baseResponseDTO = Common.getFailureResponse("INTERNAL_ERROR", "Internal Server Error");
}
return baseResponseDTO;
}
View Resolver Method:
public static String resolveView(HttpServletRequest request, ViewResolver viewResolver, String screenName, Map<String, Object> map) {
try {
MockHttpServletResponse mockResp = new MockHttpServletResponse();
View resolvedView = viewResolver.resolveViewName(screenName, LocaleContextHolder.getLocale());
resolvedView.render(map, request, (HttpServletResponse) mockResp);
return mockResp.getContentAsString();
} catch (Exception e) {
log.error("Error while resolving view :: " + screenName + " :: ", e);
return null;
}
}
Issue:
The view is resolved correctly and rendered when the application is deployed on Tomcat. However, when deploying the same application on WebLogic 12c, the view does not render correctly, and I get an error or an empty response.
Steps Taken:
- Verified that the Spring and WebLogic configurations are correct.
- Ensured all dependencies are packaged correctly in the WAR file.
- Reviewed WebLogic server logs but didn’t find specific errors pointing to the cause.
Questions:
- What could be causing the view resolution to fail on WebLogic but work on Tomcat?
- Are there any specific configurations or settings needed for WebLogic to properly handle Spring view resolution?
- How can I debug this issue further to identify the root cause?
Any insights or suggestions would be greatly appreciated. Thank you!