0

I'm doing Hibernate migration.

Just changed Hibernate.3.jar to Hibernate.4.3.1.jar which gave me 2 errors

1)Why Hibernate STRING can not be resolved?

2)While calling sessionFactory.openSession()

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
at com.nextenders.other.HibernateFactory.openSession(HibernateFactory.java:50)
at com.nextenders.server.BaseFilter.setOrgAndPortalIdToSession(BaseFilter.java:122)
at com.nextenders.server.BaseFilter.doFilter(BaseFilter.java:61)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:66)
at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)

Did research and found the link

java.lang.NoSuchMethodError: org.hibernate.SessionFactory.openSession()Lorg/hibernate/classic/Session

But the I'm not using Spring in my project and it's plain hibernate. Still the error exists .. Any help or Idea on this ?

Thanks for any clue.

Community
  • 1
  • 1
Suresh Atta
  • 120,458
  • 37
  • 198
  • 307
  • I imagine the error is the same _`SessionFactory.openSession` no longer returns an `org.hibernate.classic.Session`, rather it returns an `org.hibernate.Session`_. If you control the class `com.nextenders.other.HibernateFactory` you will need to refactor it. If you do not you will need to revert to Hibernate < 3.6. This many break **loads** of things if you were referring to `Session` by the previous package in other places. – Boris the Spider Feb 12 '14 at 11:42
  • @BoristheSpider Then It would be an compile time error right ? – Suresh Atta Feb 12 '14 at 11:53
  • Yes. Unless you have something fishy going on, like compiling against different versions of libraries. I have had that a few times in Maven (for example) when there are dependency clashes. – Boris the Spider Feb 12 '14 at 11:59
  • @BoristheSpider This time it's eclipse turn :) – Suresh Atta Feb 12 '14 at 12:16

1 Answers1

0

Really weird as Boris pointed.

I just deleted Hibernate3.jar from lib folder and done.

What happened so far is I just removed Hibernate3.jar from classpath and not deleted it. Actually there is no need to delete it, Since I disconnected it from classpath. Even after I clean the project it still pointing to same old jar. After the deletion of that jar, it's working fine.

It's compiled with HIbernate4.3.jar and running with Hibernate3.jar . So incompatibilty as pointed in Docs of NoSuchMethodError

Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

Suresh Atta
  • 120,458
  • 37
  • 198
  • 307