We install iostat to check input/output statistics by follow command
yum install sysstat
We install iostat to check input/output statistics by follow command
yum install sysstat
In this tutorial i guide you fix a below issue on encrypt/decrypt in java using jasypt library
Encryption raised an exception. A possible cause is you are using strong encryption algorithms and you have not installed the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files in this Java Virtual Machine
To fix this issue you need download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files and replace the files in $JAVA_HOME\jre\lib\security or $JRE_HOME\lib\security depend on what java you use to run your application
In normal install tomcat use JULI for logging and this logging framework has issues on some advance rotation log file configuration. I got issue with my hard disk always full after tomcat run for a couple of week cause log files. So i wonder if i can limit number of log files generate and tomcat reuse the old one when limit is reach.
After some research i find a solution. Tomcat allow us integration with log4j logging framework so we can handle above issue so easy.
If you have same problem i can guide you through.
Steps to make Tomcat work with log4j
We download two files from extras on tomcat download section
Copy tomcat-juli.jar to $CATALINA_HOME\bin to replace old one
Copy tomcat-juli-adapters.jar to $CATALINA_HOME\lib
Delete logging.properties in $CATALINA_HOME\conf
Create log4j.properties in $CATALINA_HOME\libs. This is sample of mine:
log4j.rootLogger=INFO, CATALINA log4j.appender.CATALINA=org.apache.log4j.RollingFileAppender #log4j.appender.CATALINA.File=${catalina.base}/logs/catalina.log log4j.appender.CATALINA.File=D:/catalina.log log4j.appender.CATALINA.Encoding=UTF-8 log4j.appender.CATALINA.MaxBackupIndex=15 log4j.appender.CATALINA.layout=org.apache.log4j.PatternLayout log4j.appender.CATALINA.layout.ConversionPattern=%d [%t] %-5p %c- %m%n log4j.appender.CATALINA.MaxFileSize=10MB
Download log4j version greater than 1.2 and copy to $CATALINA_HOME\lib
After that restart tomcat.
1. Symptom
when import large file database into mysql you get follow error:
ERROR 2006 (HY000) at line 1197: MySQL server has gone away
2. Cause
You get above error cause mysql terminal connection between mysql client and mysql server cause reach to limit handle data transmission
3. Solution
Find mysql configuration file add and increase below parameter in [mysqld] section and restart mysql server:
max_allowed_packet
For example: my.cnf
[mysqld] max_allowed_packet=40M
Sometime you want to edit default settings for your mysql server and don’t know where it is in windows 7, windows 8. If so this guide will help you get over come that problem.
This tutorial show you how to integration Spring mvc, JPA and Hibernate. You can check my previous post http://devjav.com/spring-mvc-4-hibernate-4-example/ for further info about spring mvc integration with hibernate.
Continue reading Spring MVC, JPA, Hibernate integration
1. Problem
When you create maven web project it default using version servlet 2.3. Now you want change servlet 2.5 or 3.0. You come and manual change on web.xml as below
<web-app 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_3_0.xsd" version="3.0"> ...
And now your project on eclipse alway has red mark and with problem show error:
Cannot change version of project facet Dynamic Web Module to 3.0.
2. Solution
Right click on project in eclipse project explorer, choose properties-> Project facets-> uncheck on Dynamic Web Module and click Apply. Right click on project and choose maven-> update project the project will automatic update and resolve above issue.
This quick guide will help you on start with Spring MVC and Hibernate. In this tutorial i will make a simple insert form and a list form. This web application will do follow thing:
Well, let’s start
Continue reading Spring MVC 4 + hibernate 4 integration example
1. Problem
EL expression on JSP page not working
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <html> <body> <% pageContext.setAttribute("name", "thinh"); %> <h2>Hello ${name}!</h2> </body> </html>
Output become
Hello ${name}!
the content of web.xml
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>SpringMVC4-Hibernate4</display-name> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/servlet/servlet-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
2. Cause
This is cause EL feature not enable on this application. Web servlet 2.3 not enable EL by default.
3. Solution
We have two solutions to solve this issue:
<?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">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" <code>isELIgnored="false"</code>%>
1. Problem
When build maven web application, and after that added spring mvc dispatcherServlet for spring 4 i got this issue
"org.springframework.web.servlet.DispatcherServlet" that does not implement interface javax.servlet.Servlet
This is web.xml file
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>SpringMVC4-Hibernate4</display-name> <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> </web-app>
2. Cause
You are missing servlet-api in maven dependency
3. Solution
Add following lines to your pom.xml
<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> <scope>provided</scope> </dependency>
the element <scope>provided</scope>
that mean: this lib will provide at runtime by container check this link for more detail