java.lang.IllegalStateException: getAttribute: Session already invalidated

I never worked with WebLogic, but from JavaDoc here I can tell that calling getPortletSession() is already wrong idea if you want to invalidate existing session, because it’s said in JavaDocs: Returns the current portlet session or, if there is no current session, creates one and returns the new session. So, it creates a new … Read more

No WebApplicationContext found: no ContextLoaderListener registered?

You’ll have to have a ContextLoaderListener in your web.xml – It loads your configuration files. <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> You need to understand the difference between Web application context and root application context . In the web MVC framework, each DispatcherServlet has its own WebApplicationContext, which inherits all the beans already defined in the root WebApplicationContext. … Read more

Spring @RequestBody and Enum value

I’ve found what I need. http://chrisjordan.ca/post/50865405944/custom-json-serialization-for-enums-using-jackson. It was 2 steps. Override the toString method of the Reos enum @Override public String toString() { return text; } Annotate with @JsonCreator the fromText method of the Reos enum. @JsonCreator public static Reos fromText(String text) And that’s all. I hope this could help others facing the same problem.

By default, where does Spring Boot expect views to be stored?

The Solution I found the answer via trial-and-error, which turned out rather annoying. I hope someone can correct me if this conclusion is wrong, but it appears that Spring Boot does not like the string WEB-INF. I renamed the WEB-INF directory to view and changed the application.properties to the following and the view loaded successfully. … Read more

Spring’s JdbcTemplate and Transactions

Yes, JdbcTemplate is not a substitute for transaction management. You still benefit from database transactions, so userService.updateUser will operate in a database transaction, but if accountService.updateXXX fails, userService.updateUser will not rollback. If you don’t want to use AOP, you can use TransactionTemplate instead. See programmatic transaction management in the Spring Reference Documentation. One pattern I’ve … Read more

why spring-boot application doesn’t require @EnableWebMvc

@SpringBootApplication is a convenience annotation that adds all of the following: @Configuration tags the class as a source of bean definitions for the application context. @EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings. Normally you would add @EnableWebMvc for a Spring MVC app, but Spring … Read more

How to manually render Spring MVC view to html?

Try autowiring the ViewResolver then calling resolveViewName(“myview”, Locale.US) to get the View. Then call render() on the view, passing it a “mock” HTTP response that has a ByteArrayOutputStream for its output, and get the HTML from the ByteArrayOutputStream. Update Here’s the working example, copied from the question. (so the code is actually with the answer) … Read more