Combining multiple transactional method in one transaction

Method with @Transactional commits the transaction when it returns. If you want to combine multiple transactional method in one transaction, propagation policy is the solution. Solution A To make a parent method with @Transactional To delete @Transactional at sub methods to combine the transaction Solution B To make a parent method with @Transactional (default propagation … Continue reading Combining multiple transactional method in one transaction

Spring Transaction with @Transactional explained

The most easy way to Spring Transaction is to use @Transactional. The following is basic step to use it. Required spring component spring-context.jar, spring-tx.jar, spring-jdbc.jar and additional dependencies Spring context <tx:annotation-driven> must be declared to enable @Transactional TransactionManager must be declared. If the id is not "transactionManager", it must be set with <tx:annotation-driven>'s transaction-manager attribute … Continue reading Spring Transaction with @Transactional explained

About Spring ViewResolver

ViewResolver is very important component of Spring MVC. Without proper understanding, it is difficult to analyze MVC components, especially when taking over other's source code. The following explanations is based on Spring Framework 4.3.18. What is ViewResolver? (org.springframework.web.servlet.ViewResolver) ViewResolver is the translator which converts view name into View object View is the component which renders … Continue reading About Spring ViewResolver

Oracle JDBC slow connection on some virtual server

This issue is found on Oracle JDBC driver 11.2.x. Environment : Linux virtual server, Oracle JDBC driver 11.2.x Issue : Oracle connection takes long time or occurs timeout error Cause : Oracle JDBC driver, when it connect to database server, calls java.security.SecureRandom class. SecureRandom uses /dev/random on Linux or Unix server. /dev/random pseudo device uses … Continue reading Oracle JDBC slow connection on some virtual server

Java runtime parameters to enable JMX

To enable JMX for some java process, the following option is required. -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.port=9099 -Dcom.sun.management.jmxremote.rmi.port=9199 The important two ports are com.sun.management.jmxremote.port and com.sun.management.jmxremote.rmi.port. If JMX client is connecting through firewall, the two ports must be opened.

The inner working of DispatcherServlet

The main program of Spring MVC is DispatcherServlet. Most Spring MVC webapp's web.xml is as follows. <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- The definition of the Root Spring Container shared by all Servlets and Filters --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/root-context.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> … Continue reading The inner working of DispatcherServlet