In this Spring Security Quick Start post I show you how to use Spring Security framework to secure Spring MVC web application. I will demo simple protect on web application it will force users must login with appropriate user before can access specific page. I also demo how to customize login page and access denied page. Continue reading Spring Security Quick Start Tutorial
When development web application in eclipse and use maven to manage dependency we usually face with some problem as missing library at runtime cause maven dependency issues. In this post i show you how to dianostic that issue.
Step 1. Enable/disable Maven feature
On Eclipse IDE, right click on the project, choose
maven->Disable Maven Nature
After that right click on project choose
Configure-> Convert to maven project
If you already do this step but no luck, move to step 2
Step 2. Clean and update project
Some time you get exception cause library download by maven get corrupt cause network issue. Check log on console tab carefully to find what library have issue and go to maven local repository to delete that library(you can also delete all). Normal maven local repository lay on
Next, In Eclipse IDE right click choose
If your project still not work when run, go to next step.
Step 3. Checking Deployment Assembly
Right click on project in Eclipse IDE, choose properties and choose
Deployment Assembly. Please make sure your project have minimal as below if you don’t using any other library in
WEB-INF/lib. If you using more you can manuall add to
Deployment Assembly by click Add button.
When using Java application to access server that using invalid certificate or self-signed certificate, you maybe will get below exception:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1747) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241) at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235) at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1209) at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:135)
To make Java trust those certificate we must manual import that cert into java trust store. In this post i will guide you how to import certificate into trust store. In default Java lookup trust store in
$JAVA_HOME/jre/lib/security/cacerts. So you must import certificate that you need to trust to that keystrore using keytool utility that ship with Java using below syntax
#move currency directory to $JAVA_HOME/jre/lib/security/cacerts # default password of cacerts file is changeit # in linux maybe you should not use -storepass option and enter direct on console keytool -import -alias ca -file path_and_cert_name.cer -keystore cacerts –storepass changeit
When integration with third party using HttpsURLConnection in java you usually get following issue if your third party use self signed certificate:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed:sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
This issue happen cause java cannot verify that certificate and you must import it manual to trust store so java can trust site. But how you can get that certificate? In this post i will guide you how to get certificate from a https site. Continue reading how to get certificate from a https site
When running application using mysql as database with high load you maybe get following exception
Caused by: java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction
This happend cause your application try to lock resource on database but cannot get that before reach to lock wait time configure of your database.
To fix this issue once quick solution before you can tunning your application is increase lock wait time of mysql database.
- Find mysql configuration file( in linux it usually in /etc/my.cnf, if you use windows read this post to find it)
- Increase below value if exist or add parameter with approriate value
In this tutorial, i will show you how to configure mysql to log mysql slow query. This is a important feature we always use when tuning application using mysql database.
We do following config in file my.cnf (in linux OS you can find it on /etc/my.cnf, if you using windows can check on this post to find this file):
slow_query_log to turn on log slow query
slow_query_log_file to configure file mysql will write log.
Today i got a question about How to logging hibernate sql, include parameters binging for that sql statement. In this post i will guide you how to do that using hibernate config and log4j setting.
I will use code on this link (spring4+JPA+Hibernate integration) to demo. We will modify it and make it works. Continue reading How to enable logging Hibernate sql and parameters binding
On this tutorial i willl guide you how to using jconsole to connect java application and profile. In this sample i use jconsole to monitor database pool c3p0. Continue reading How to profile java web application run on tomcat using jconsole
Continue series tutorial about jersey, today i will guide you how to build a client to consume restful service usign jersey client 2. In this tutorial i also help you how to logging message request on client side. This client application will consume services provide by server side code on part 1:Build RESTful web service with jersey 2
Continue reading Consume Restful service using jersey client 2