tomcat-logo

Find out Tomcat is using which JDK or JAVA_HOME

In this article, we will show you how to find out which JRE / JDK or JAVA_HOME is used by the Tomcat container. Environment : Debian 7.5 Tomcat 7, installed via apt-get JDK 6 and JDK 7 Note To understand how Tomcat pick up which JDK to run, refer toContinue Reading

eclipse-logo

Eclipse – red-x icon didn’t display on project explorer

In Eclipse IDE, If a project contains errors, a small “red-x” icon will be displayed in the files that are causing the error. This useful feature is supported in Java related perspectives only, for example, “Package Explorer”. 1. Problem Personally, I prefer to use the “Project Explorer” perspective (pure folderContinue Reading

mongoDB-logo

MongoDB : write Aggregation result into a new collection

This article shows you 2 ways to export a MongoDB “aggregation” result into another new collection. 1. $out Example This $out operator is New in version 2.6. 1.1 Review a simple grouping example, it writes the result to a new variable “result”. > var result = db.hc_hosting.aggregate( { $group :Continue Reading

ubuntu-logo

Ubuntu : Status 14: The disk contains an unclean file system

Dual boot Windows and Ubuntu, but Ubuntu is unable to access the Windows partition /dev/sdb3, shows the following error message : Error mounting /dev/sdb3 … status 14: The disk contains an unclean file system (0, 0). Metadata kept in Windows cache, refused to mount. Failed to mount ‘/dev/sdb3′: Operation notContinue Reading

linux-logo

Linux : How to gzip a folder

On Linux, gzip is unable to compress a folder, it used to compress a single file only. To compress a folder, you should use tar + gzip, which is tar -z. Note $ tar –help -z, -j, -J, –lzma Compress archive with gzip/bzip2/xz/lzma For example, tar -zcvf outputFileName folderToCompress 1.Continue Reading

mongoDB-logo

mongoimport unable to import $numberLong

A collection with NumberLong type data as follows : > db.hc_whois.findOne(); { "_id" : NumberLong(3000001), "startIpInLong" : NumberLong(1543503872), "endIpInLong" : NumberLong(1544552447), "name" : "ap-net-1", //… } Export it with mongoexport : server1 $ mongoexport -d mydb -c hc_whois -o whois.json whois.json { "_id" : { "$numberLong" : "3000001" }, "startIpInLong"Continue Reading

java_logo_100

Java : Unsupported major.minor version 51.0

1. Problem Run a “jar” on Debian 7.5, and hits the following error messages : $ java -jar ripecrawler.jar Exception in thread "main" java.lang.UnsupportedClassVersionError: com/mkyong/whois/job/RipeCrawlJob : Unsupported major.minor version 51.0   at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:643) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:277) at java.net.URLClassLoader.access$000(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:212) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) atContinue Reading

java_logo_100

servlet-api-2.5.jar – jar not loaded

Deployed a “war” file on Tomcat, and hits following error messages : Jul 17, 2014 7:59:55 PM org.apache.catalina.loader.WebappClassLoader validateJarFile INFO: validateJarFile(D:\apache-tomcat-7.0.53\webapps\hc\WEB-INF\lib\servlet-api-2.5.jar) – jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class Tools used : JDK1.7 Maven 3 Tomcat 7 1. Reason The Tomcat’s container comes with ownContinue Reading

jsf log4j logo

JSF 2 + Log4j Integration Example

In this tutorial, we will show you how to integrate the log4j framework with the JSF 2.x web application. JSF is using java.util.logging, you need extra works to redirect the logging from JSF’s java.util.logging to log4j, with a serious penalty of performance, make sure use this trick only during localContinue Reading

log4j logo

Log4j hello world example

In this tutorial, we will show you how to use the classic log4j 1.2.x to log a debug or error message in a Java application. 1. Project Directory Review the final project structure, a standard Maven style Java project. 2. Get Log4j Declares the following dependencies : pom.xml <dependency> <groupId>log4j</groupId>Continue Reading

scp data transfer

Download file from server using SSH

Normally, you use Secure copy or SCP to download a file from another server via SSH connection. For example, scp username@remotehost:remoteFileToDownload localFolderNameToSaveTheFile 1. SCP Examples 1.1 Download File From Server Example to download a log file (hc.audit.log) from server (198.58.x.x), into your current local folder. scp [email protected]:/var/log/tomcat7/hc.audit.log . 1.2 UploadContinue Reading

debian-logo

Debian : Change default Java version

Deployed a Debian 7.5 on Linode server, but the default is using OpenJDK 1.6. How can I upgrade the alternative path to OpenJDK 1.7? $ java -version java version "1.6.0_31" OpenJDK Runtime Environment (IcedTea6 1.13.3) (6b31-1.13.3-1~deb7u1) OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode) Tracing the java, it’s using theContinue Reading

log4j logo

log4j.xml Example

Here’s an XML version of log4j properties file, just for sharing. 1. Output to Console Redirect the logging to console. log4j.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration debug="true" xmlns:log4j=’http://jakarta.apache.org/log4j/’>   <appender name="console" class="org.apache.log4j.ConsoleAppender"> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L – %m%n" /> </layout> </appender>  Continue Reading

spring-logo

Spring Security + Hibernate Annotation Example

In this tutorial, previous Spring Security + Hibernate4 XML example will be reused, and convert it to a annotation-based example. Technologies used : Spring 3.2.8.RELEASE Spring Security 3.2.3.RELEASE Hibernate 4.2.11.Final MySQL Server 5.6 Tomcat 7 (Servlet 3.x container) Quick Note : Create a session factory with LocalSessionFactoryBuilder Inject session factoryContinue Reading

spring-logo

Spring Security + Hibernate XML Example

In this tutorial, we will show you how to integrate Hibernate 4 in Spring Security, XML configuration example. Note For annotation version, please read this Spring Security + Hibernate Annotation Example. Technologies used : Spring 3.2.8.RELEASE Spring Security 3.2.3.RELEASE Hibernate 4.2.11.Final MySQL Server 5.6 JDK 1.6 Maven 3 Eclipse 4.3Continue Reading

Page 1 of 9612345...102030...Last »