Hibernate JPA error


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
zolfAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
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
 
for_yanCommented:
You are probably  lacking dom4j.jar
0
 
objectsCommented:
add dom4j-1.6.1.jar to your buildpath
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
objectsCommented:
you'll find it in the required directory
Add the others from that directory while you are it
0
 
objectsCommented:
the red line is just showing you where (probably) 80 characters is
0
 
objectsCommented:
AnnotationConfiguation is deprecated btw, should use org.hibernate.cfg.Configuration
0
 
zolfAuthor Commented:
>>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
 
for_yanCommented:
You can adjust red line
http://forums.netbeans.org/topic11829.html
Tools > Options > Editor > Formatting.
0
 
zolfAuthor Commented:
please see image
e1.gif
0
 
for_yanCommented:
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
 
objectsCommented:
> 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
 
objectsCommented:
regards the slf4j error, you need to also install add a logging implementation.
all you have is the api
0
 
objectsCommented:
you can grab bindings here
http://www.slf4j.org/download.html
0
 
objectsCommented:
for logging I'd suggest using log4j or logback
0
 
zolfAuthor Commented:

can you please tell me were i can download log4j
0
 
zolfAuthor Commented:

for_yan

what are these two.do i need to put both or only one.please guide
0
 
for_yanCommented:
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
 
objectsCommented:
> 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
 
objectsCommented:
> 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
 
zolfAuthor Commented:

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
 
zolfAuthor Commented:

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
 
objectsCommented:
> 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
 
zolfAuthor Commented:

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
 
objectsCommented:
> 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
 
zolfAuthor Commented:

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
 
zolfAuthor Commented:

what is this jar used for
0
 
zolfAuthor Commented:

there are many jar in there.which one do i put in my lib file
0
 
objectsCommented:
> 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
 
objectsConnect With a Mentor Commented:
and only add one that, not the others
0
 
zolfAuthor Commented:

appreciate all your helps
0
 
zolfAuthor Commented:
cheers
0
 
objectsCommented:
accepted comment actually repeats what I had already posted. Make sure you read all my posts :)

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.