?
Solved

Hibernate JPA error

Posted on 2011-05-01
38
Medium Priority
?
615 Views
Last Modified: 2012-05-11

Hello there,

i am using Netbean 6.9.1 to learn hibernate JPA. i have added the jar files,but i get some error.what am i doing wrong.please see the image.

cheers
zolf
02-05-2011-10-12-17.gif
0
Comment
Question by:zolf
  • 16
  • 12
  • 10
38 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 35502880
You are probably  lacking dom4j.jar
0
 
LVL 92

Expert Comment

by:objects
ID: 35502885
add dom4j-1.6.1.jar to your buildpath
0
 
LVL 92

Expert Comment

by:objects
ID: 35502888
you'll find it in the required directory
Add the others from that directory while you are it
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 35502895
the red line is just showing you where (probably) 80 characters is
0
 
LVL 92

Expert Comment

by:objects
ID: 35502898
AnnotationConfiguation is deprecated btw, should use org.hibernate.cfg.Configuration
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502900
0
 

Author Comment

by:zolf
ID: 35502905
>>the red line is just showing you where (probably) 80 characters is

can i config this or disable it.by the way what help does this 80 character gives a coder
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502913
You can adjust red line
http://forums.netbeans.org/topic11829.html
Tools > Options > Editor > Formatting.
0
 

Author Comment

by:zolf
ID: 35502918
please see image
e1.gif
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502920
In some old languages like Fortran you could not have longer lines
(that was the number of columns in punch cards originally).
Nowadays - don't know waht is the value of that line
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502926
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502928
0
 
LVL 92

Expert Comment

by:objects
ID: 35502932
> can i config this or disable it.by the way what help does this 80 character gives a coder

sure, its a bit of a relic from the past.
though sometimes coding standards can have rules about the max length of a line
0
 
LVL 92

Expert Comment

by:objects
ID: 35502935
regards the slf4j error, you need to also install add a logging implementation.
all you have is the api
0
 
LVL 92

Expert Comment

by:objects
ID: 35502939
you can grab bindings here
http://www.slf4j.org/download.html
0
 
LVL 92

Expert Comment

by:objects
ID: 35502942
for logging I'd suggest using log4j or logback
0
 

Author Comment

by:zolf
ID: 35502957

can you please tell me were i can download log4j
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502961
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502965
0
 

Author Comment

by:zolf
ID: 35502972

for_yan

what are these two.do i need to put both or only one.please guide
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35502979
No those are different loggers - log4j is used mostly.
logback is a relatively new - they say it will eventually be better.
If Iwere you, I'd rather use log4j for now
0
 
LVL 92

Expert Comment

by:objects
ID: 35502980
> what are these two.do i need to put both or only one.please guide

see my earlier comment. You just need a single logging implementation.
you can pick what you prefer.
0
 
LVL 92

Expert Comment

by:objects
ID: 35502982
0
 
LVL 92

Expert Comment

by:objects
ID: 35502989
> can you please tell me were i can download log4j

you can grab log4j here
http://logging.apache.org/log4j/1.2/download.html
0
 

Author Comment

by:zolf
ID: 35503009

i have added the log4j jar,but still i get error

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
drop table Users
create table Users (id numeric(19,0) identity not null, password varchar(255) null, primary key (id))
BUILD SUCCESSFUL (total time: 0 seconds)
0
 

Author Comment

by:zolf
ID: 35503018

i got rid of the slf4j.jar from my netbean and added log4j,now i get another error

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
        at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:197)
        at com.exam.main.Main.main(Main.java:20)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        ... 2 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
0
 
LVL 92

Expert Comment

by:objects
ID: 35503027
> i got rid of the slf4j.jar from my netbean and added log4j,now i get another error

I didn't tell you to get rid of it. you need both
0
 
LVL 47

Accepted Solution

by:
for_yan earned 1000 total points
ID: 35503034
Failedto load class org.slf4j.impl.StaticLoggerBinder

This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

As of SLF4J version 1.6, in the absence of a binding, SLF4J will default to a no-operation (NOP) logger implementation.

You can download SLF4J bindings from the project download page.

http://www.slf4j.org/download.html

0
 

Author Comment

by:zolf
ID: 35503035

I didn't tell you to get rid of it. you need both

oh is it,let me add it gain and run it
0
 
LVL 92

Expert Comment

by:objects
ID: 35503036
> i have added the log4j jar,but still i get error

you need to add the *binding* as I explained earlier

you can grab bindings here
http://www.slf4j.org/download.html
0
 

Author Comment

by:zolf
ID: 35503037

now i get this error

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
drop table Users
create table Users (id numeric(19,0) identity not null, password varchar(255) null, primary key (id))
BUILD SUCCESSFUL (total time: 1 second)
0
 

Author Comment

by:zolf
ID: 35503041

what is this jar used for
0
 

Author Comment

by:zolf
ID: 35503043

there are many jar in there.which one do i put in my lib file
0
 
LVL 92

Expert Comment

by:objects
ID: 35503050
> what is this jar used for

Its a slf4j binding
but you don't need it

> there are many jar in there.which one do i put in my lib file

in your case you're using log4j so you would add slf-log4j.....
0
 
LVL 92

Assisted Solution

by:objects
objects earned 1000 total points
ID: 35503053
and only add one that, not the others
0
 

Author Comment

by:zolf
ID: 35503055

appreciate all your helps
0
 

Author Closing Comment

by:zolf
ID: 35503058
cheers
0
 
LVL 92

Expert Comment

by:objects
ID: 35503085
accepted comment actually repeats what I had already posted. Make sure you read all my posts :)

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question