"Hibernate" hibernate3.x failed to load class "Org.slf4j.impl.StaticLoggerBinder" error when running standalone

Source: Internet
Author: User

Supposedly, if Hibernate does not attach to SSH operation, like "struts2+hibernate3+spring3" with SSH integration, complete print user table, user login, registration, Change password system (click to open link) like, After hibernate-distribution-3.6.10.final decompression, the root directory of the Hibernate3.jar,hibernate-distribution-3.6.0.final\lib\ All jar,hibernate-distribution-3.6.0.final\lib\ under the required All the jars under JPA are all the packages under that hibernate-jpa-2.0-api-1.0.1.final.jar,hibernate-distribution-3.6.0.final\lib\optional\c3p0. , which is the C3p0-0.9.1.jar, the copy to the corresponding Java project load can also be run, but why without spring and Struts2 support, will appear as, Failed to load Class " Org.slf4j.impl.StaticLoggerBinder "wrong?"


This problem is not in the hibernate4.x, may realize that it is wrong, in hibernate3.x, Hibernate uses SLF4J API this interface to log logs, but in Hibernate lib, but did not provide log4j package, Do not know what to think about, their own lib package because of fear and other framework of the log packet conflict is not provided, resulting in the inability to run independently!

Therefore, we have to add our own SLF4J API to this interface.

The specific is to open the SLF4J official website (click the Open link), download:


After decompression, such as the structure, the version number is no problem, take away the Slf4j-log4j12-1.7.12.jar, loaded into the standalone run of the hibernate3.x Java project.


Since SLF4J is like hibernate compatible with various connection Mysql,orcale such as database connection jar packages, it is just a compatible variety of generated Java log jar packages. Also want to download a really work log jar package, here use the most popular log4j, although usually we do not usually record the log ... Open Apache's official website (click the Open link) For example, select Log4j-1.2.17.zip (Windows) or log4j-1.2.17.tar.gz (Linux).


After decompression, the apache-log4j-1.2.17 under the Log4j-1.2.17.jar, the same load into the standalone run of the hibernate3.x Java project.

At this point, the independent hibernate3.x has been able to run, but not finished, the operation will also appear as follows Log4j:warn please initialize the log4j system properly warning:


To solve this problem it is very simple to create a log4j configuration file. such as in the SRC directory to create a configuration file, right-click the SRC folder, select Menu new>file, file name Input log4j.properties,


Write the following in the text:

Log4j.rootlogger=warn, Stdoutlog4j.appender.stdout=org.apache.log4j.consoleappenderlog4j.appender.stdout.layout =org.apache.log4j.patternlayoutlog4j.appender.stdout.layout.conversionpattern=%d%p [%c]-%m%n
At this time, hibernate3.x finally can run independently, really is dizzy dead ...

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"Hibernate" hibernate3.x failed to load class "Org.slf4j.impl.StaticLoggerBinder" error when running standalone

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.