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 : 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( at at at$000( at$ at Method) at atContinue 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


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=’’>   <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 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 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

hibernate logo

java.lang.ClassNotFoundException: org.hibernate.service.jta.platform.spi.JtaPlatform

Spring 3.2.x + Hibernate 4.3.x integration, hits JtaPlatform ClassNotFoundException, search the project classpath, find out that JtaPlatform is at different package? hibernate-core.4.3.5.Final.jar org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform Error message shows org.hibernate.service.jta.platform.spi.JtaPlatform Caused by: java.lang.NoClassDefFoundError: org/hibernate/service/jta/platform/spi/JtaPlatform at org.springframework.orm.hibernate4.SpringSessionContext.<init>( ~[spring-orm-3.2.8.RELEASE.jar:3.2.8.RELEASE] … 40 common frames omitted Caused by: java.lang.ClassNotFoundException: org.hibernate.service.jta.platform.spi.JtaPlatform //… pom.xml <!– Hibernate ORM –> <dependency>Continue Reading


Spring Security : Encoded password does not look like BCrypt

In Spring Security, database authentication with bcrypt password hashing. import; import; //… String password = “123456″; PasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); String hashedPassword = passwordEncoder.encode(password); spring-security.xml <authentication-manager> <authentication-provider> <password-encoder hash="bcrypt" /> //… </authentication-provider> </authentication-manager> CREATE TABLE users ( username VARCHAR(45) NOT NULL , password VARCHAR(45) NOT NULL ,Continue Reading


Spring Security Remember Me Example

In this tutorial, we will show you how to implement “Remember Me” login feature in Spring Security, which means, the system will remember the user and perform automatic login even after the user’s session is expired. Technologies and tools used : Spring 3.2.8.RELEASE Spring Security 3.2.3.RELEASE Spring JDBC 3.2.3.RELEASE EclipseContinue Reading


Google Chrome displays pink color screen

Problem After upgrading from Windows 8 Enterprise to Windows 8.1, Google Chrome displays pink color screen like this : Windows Environment Chrome 34.0.1847.137 m Windows 8.1 NVIDIA 331.58 Chrome GPU : NVIDIA To get the Chrome GPU, type chrome://gpu in the browser URL, refer to the driver version. DriverContinue Reading


ClassNotFoundException: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException

Spring + Hibernate4 integration, and transaction are managed by Spring AOP, example : spring-hibernate.xml <beans xmlns="" xmlns:xsi="" xmlns:aop="" xmlns:tx="" xsi:schemaLocation="">   <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean>   <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true" /> <tx:method name="*" /> </tx:attributes> </tx:advice>   <aop:config> <aop:pointcutContinue Reading


Spring Security : Check if user is from remember me cookie

This Spring Security example shows you how to check if a user is login from a “remember me” cookie. private boolean isRememberMeAuthenticated() {   Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); if (authentication == null) { return false; }   return RememberMeAuthenticationToken.class.isAssignableFrom(authentication.getClass()); }   @RequestMapping(value = "/admin/update**", method = RequestMethod.GET) public ModelAndView updatePage()Continue Reading


Spring + Hibernate : No Session found for current thread

Integrates Spring 3 and Hibernate 4, the system shows the following message while performing database operation : org.hibernate.HibernateException: No Session found for current thread The sessionFactory is injected like this : spring-hibernate4.xml <beans xmlns="" xmlns:xsi="" xsi:schemaLocation="">   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/test"Continue Reading

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