RSSAll Entries Tagged With: "java"

Issue configuring log4j in Tomcat

Hi Friends,

Issue 1 :

I was trying to set up log4j for a REST application I wrote and got the below exception. [ I’m not pasting the complete exception ]

Apache Tomcat/7.0.64 – Error report HTTP Status 500 – Servlet.init() for servlet Jersey Web Application threw exceptiontype Exception reportmessage Servlet.init() for servlet Jersey Web Application threw exceptiondescription The server encountered an internal error that prevented it from fulfilling this request.exception javax.servlet.ServletException: Servlet.init() for servlet Jersey Web Application threw exception org.apache.catalina.authenticator.AuthenticatorBase.invoke( org.apache.catalina.valves.ErrorReportValve.invoke( org.apache.catalina.valves.AccessLogValve.invoke( org.apache.catalina.connector.CoyoteAdapter.service( org.apache.coyote.http11.AbstractHttp11Processor.process( org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process($ java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$ Source) org.apache.tomcat.util.threads.TaskThread$ Source) root cause java.lang.NoClassDefFoundError: Lorg/apache/log4j/Logger; java.lang.Class.getDeclaredFields0(Native Method) java.lang.Class.privateGetDeclaredFields(Unknown Source) java.lang.Class.getDeclaredFields(Unknown Source) org.glassfish.jersey.internal.util.ReflectionHelper$ org.glassfish.jersey.internal.util.ReflectionHelper$ Method) org.glassfish.jersey.server.model.IntrospectionModeller.checkResourceClassFields( org.glassfish.jersey.server.model.IntrospectionModeller.doCreateResourceBuilder(

I was able to resolve the above issue using the below steps :-

Right Click on the Project -> Properties -> Deployment Assembly -> Add -> Java Build Path Entries ( Make sure you add log4j jar to the Build Path ) & select the logj4 jar.

Note : By using the above steps what you are doing is putting the log4j jar in the classpath, specifically in the WEB-INF/lib of your deployed application.

Issue 2 :

The second issue what I faced is; the project was not able to find the file which I had created.

Solution : Place the file under src -> main -> resources folder & you can use




Hibernate Project Errors – Java – MYSQL 5.0

In this article I am sharing my experience on running my first Hibernate Project.


I started with my first Hibernate project and followed the steps as instructed within the Tutorial. But on running it I was getting the below error.


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread “main” org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(
at org.hibernate.cfg.Configuration.getConfigurationInputStream(
at org.hibernate.cfg.Configuration.configure(
at org.hibernate.cfg.AnnotationConfiguration.configure(
at org.hibernate.cfg.AnnotationConfiguration.configure(
at org.hibernate.cfg.Configuration.configure(
at org.hibernate.cfg.AnnotationConfiguration.configure(
at com.hibernate.chapter.HelloEmployee.main(



I had to spent some time to figure out what I missed and finally the issue was resolved.

The mistake I did was I pasted hibernate.cfg.xml and files thru Eclipse IDE and file got placed within the project root path as you see below.


The classpath would be SET to src and the project will search for these files within the scr folder on compile time; so you would need to move the two files manually into the src folder which will resolve the issue.

Hope this helped !

Eclipse – Failed to load the JNI shared library “C:/JDK/bin/client/jvm.dll”

Hello Team,

I found something interesting on configuring my new laptop for JAVA & Eclipse.

I followed the normal procedure and installed JAVA and Eclipse but when I tried launching Eclipse got the below error.


Error Message – Failed to load the JNI shared Library !

Issue : The issue is caused due to the mismatch between the JAVA & Eclipse bit versions. I installed 64 bit jdk and tried launching Eclipse built for x86 version. :)

Resolution : Install the same version of JAVA & Eclipse too resolve the issue. Recommended version is x86.

Hope this helps !