• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception At hibernate.cfg.xml

 
swapnilw wadaganve
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying for simple program of hibernate and using postgresql as database.But getting exception as,
invalid configuration
Exception in thread "main" java.lang.NullPointerException

Do you have nay idea about this? My hibernate.config.xml details
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc ostgresql://localhost:5432/firsthibernate</property>;
<property name="connection.username">dev</property>
<property name="connection.password">1234</property>

<property name="connection.driver_class">org.postgresql.Driver</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.show_sql">false</property>
<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">net.sf.hibernate.transaction.JTATransactionFactory</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<property name="mappingResources">
<value>/contact.hbm.xml</value>
</property>
</session-factory>


</hibernate-configuration>
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the problem is that you've got a gremlin sticking his tongue out at you in your hibernate.cfg.xml file.

Is this exception being triggered during the creation of the Hibernate SessionFactory, when you get a Hibernate Session, or when you try and use the Hibernate Session to save the state of a POJO to the database?

Here's a little tutorial of mine on how to get started with Hibernate. It might help you out a little bit as you get yourself up and running:

Getting Started with Hibernate - Installation, Configuration and Connecting to a Database

-Cameron McKenzie
 
swapnilw wadaganve
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks For Replying.
I sort out problem but now i am getting exception at
Configuration cfg = new Configuration();
cfg.configure();
sessionFactory = cfg.buildSessionFactory();//exception here as failed.java.lang.IllegalAccessError

what may be reason i dont know.I have used cglib-2.1.3.jar in class path.

And can you suggest me any good books which help me for Hibernate with postgresql and Wickets Framework.
 
swapnilw wadaganve
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am successfull to run the program.But in datbase records are not get added and i m not getting any exception also.

I am using postgresql for database .

Any idea.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you begin the transaction and also commit the transaction.

If you need some help in Hibernate, you can look at my signature links for some tutorials. And keep posting quesitons and we will try to help.

-Cameron McKenzie
 
piotr kalwasinski
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Cameron McKenzie,

I am trying to set Hibernate in order to learn about that technology, but I came across the exception I can't figure. I also went through your tutorial, I downloaded all the files and I'm using MySQL database. After setting all the libraries there was a missing class exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
...

To fix it I used jar finder and added:

slf4j-jdk14-1.0.1.jar

But after that I get the exception:

Exception in thread "main" java.lang.AbstractMethodError: org.slf4j.impl.JDK14LoggerAdapter.isTraceEnabled()Z
at org.hibernate.type.NullableType.<clinit>(NullableType.java:59)
at org.hibernate.Hibernate.<clinit>(Hibernate.java:103)
at org.hibernate.type.TypeFactory.<clinit>(TypeFactory.java:69)
at org.hibernate.mapping.ManyToOne.getType(ManyToOne.java:49)
at org.hibernate.mapping.ManyToOne.createForeignKey(ManyToOne.java:62)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2213)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2170)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
at org.hibernate.cfg.Configuration.add(Configuration.java:716)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)

I have no idea how to fix it, please help me!

Piotr Kalwasinski
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic