I wrote a simple application to parse an rss feed and store it into database. I am using Hibernate mapping to store the rss data objects into into mysql DB.
The application worked fine until I changed the application to use Threads. After implementing threads I have started getting the following errors:
[java] Exception in thread "ReaderThread Number4" java.lang.NullPointerException
[java] 1119438564
[java] at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
[java] 1119438564
[java] at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:557)
[java] Title=Coffee Table (Trussville) $50
[java] at org.hibernate.context.ThreadLocalSessionContext.buildOrObtainSession(ThreadLocalSessionContext.java:142)
[java] 1119487285
[java] at org.hibernate.context.ThreadLocalSessionContext.currentSession(ThreadLocalSessionContext.java:103)
[java] 1119487285
[java] at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
[java] at com.closebyme.feeds.reader.CraigslistFeed.createPosting(Unknown Source)
[java] at com.closebyme.feeds.reader.CraigslistFeed.processFeed(Unknown Source)
[java] at com.closebyme.craigslist.manager.CraigslistManager$ReaderThread.run(Unknown Source)
[java] at java.lang.Thread.run(Thread.java:595)
[java] Exception in thread "ReaderThread Number1" java.lang.NullPointerException
[java] at org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge.nextTimestamp(RegionFactoryCacheProviderBridge.java:85)
[java] at org.hibernate.impl.SessionFactoryImpl.openSession(SessionFactoryImpl.java:557)
[java] at org.hibernate.context.ThreadLocalSessionContext.buildOrObtainSession(ThreadLocalSessionContext.java:142)
[java] at org.hibernate.context.ThreadLocalSessionContext.currentSession(ThreadLocalSessionContext.java:103)
[java] at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:574)
I have been trying to find good examples on implementing multi-threaded application using hibernate but I haven't been able to find good examples. I am not sure if there are specific caveats or guidelines for implementing multithreaded apps with hibernate.
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html