HTTP 500 Internal Server Error in simple REST based program. Confused in GET and POST while receiving/sending response from server

One way to debug things like this is to create a simple ExceptionMapper to catch exceptions that are not mapped. When there is no mapper, often the exception will bubble up to the container level, which just gives us generic 500 server error (which most of the time is of little help). @Provider public class … Read more

Encoded slash (%2F) with Spring RequestMapping path param gives HTTP 400

for spring-boot, the following did the trick @SpringBootApplication public class Application extends WebMvcConfigurerAdapter { public static void main(String[] args) throws Exception { System.setProperty(“org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH”, “true”); SpringApplication.run(Application.class, args); } @Override public void configurePathMatch(PathMatchConfigurer configurer) { UrlPathHelper urlPathHelper = new UrlPathHelper(); urlPathHelper.setUrlDecode(false); configurer.setUrlPathHelper(urlPathHelper); } }

Sharing a persistence unit across components in a .ear file

Here are the relevant sections of the JPA 2.0 specification: 8.2 Persistence Unit Packaging … A persistence unit is defined by a persistence.xml file. The jar file or directory whose META-INF directory contains the persistence.xml file is termed the root of the persistence unit. In Java EE environments, the root of a persistence unit must … Read more

Using .html files as JSPs

With 2 simple steps you can achieve this: Add this servletmapping for the JSP servlet: <servlet-mapping> <servlet-name>jsp</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> This tells the application container to use the the JSP servlet when serving html files. Comment out the <mime-mapping> for text/html mime type (*.html) files so that the container won’t handle HTML files as static content. … Read more

Java 8 Lambda Expression Within REST Service not working

I found the solution! I was using Jersey 1.17.1. When I upgraded to 2.7 it worked. My pom file had the following: <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-bundle</artifactId> <version>1.17.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> <version>1.17.1</version> <scope>compile</scope> </dependency> I removed those and added: <dependency> <groupId>org.glassfish.jersey.containers</groupId> <artifactId>jersey-container-servlet</artifactId> <version>2.7</version> </dependency> And of course I had to modify the web.xml file to … Read more

Location of GlassFish Server Logs

In general the logs are in /YOUR_GLASSFISH_INSTALL/glassfish/domains/domain1/logs/. In NetBeans go to the “Services” tab open “Servers”, right-click on your Glassfish instance and click “View Domain Server Log”. If this doesn’t work right-click on the Glassfish instance and click “Properties”, you can see the folder with the domains under “Domains folder”. Go to this folder -> … Read more