EDITED
i have a problem with my application. I am using glassfish 4 and java 8, because my environment can't take spring 5, so i'm using spring 4 instead. I just need a few libraries to access API from another server. One of the function is RestTemplate. Everytime restTemplate.exchange is triggered, it always give HTTP 500 Error. But no exception at all. I know this is HTTP 500 error by looking at web.xml. There is no Exception message, even i've tried to add try-catch. It happens on my production server, in my development server, it's running well. In my laptop, it's running well. Can you please help me with this?
Here is my log4j
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.logger.org.hibernate=DEBUG, stdout
log4j.logger.com.opensymphony.xwork2=INFO,stdout
log4j.logger.org.apache.struts2=INFO,stdout
log4j.logger.uk.ltd.getahead.dwr=WARN, stdout
log4j.logger.freemarker.cache=INFO,stdout
log4j.logger.com.jwebs=DEBUG, stdout
log4j.logger.org.springframework=WARNING, stdout
log4j.appender.R.File=application.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
log4j.appender.stdout.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.logger.com.opensymphony.xwork2.util.OgnlUtil=error
log4j.logger.com.opensymphony.xwork2.ognl.OgnlValueStack=error
Here i attach my code
RestTemplate templatet = new RestTemplate();
String url = "http:someurl";
HttpHeaders headers = new HttpHeaders();
headers.set("Some header to get", "get");
headers.add("Some authorization", "authorization");
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Object> request = new HttpEntity<Object>(headers);
ResponseEntity<String> sapSecurity = templatet.exchange(url, HttpMethod.GET, request, String.class);
Thank you
SOLVED
Seems like there is a crash in the library. Java read the same library but different version. I have spring.jar and spring-web.4.3.6-RELEASE.jar, that's why it's crashed and didn't show any exception. The only way to extract the exception, is through the servlet. You can see the following tutorial by Tutorialspoint:
https://www.tutorialspoint.com/servlets/servlets-exception-handling.htm