1

I'm very new to Hibernate and only have tried to generate mapings via NetBeans. So I've made very simple HQL query to see how it handled, that's what i get:

java.lang.ClassCastException: car_store.entity.Colour_$$_javassist_6 cannot be cast to javassist.util.proxy.ProxyObject at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:147) at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:71) at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:631) java.lang.ClassCastException: car_store.entity.Colour_$$_javassist_6 cannot be cast to javassist.util.proxy.ProxyObject at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:147) at org.hibernate.proxy.pojo.javass ist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:71) and etc.

I've just used NetBeans's tools, so what possibly could go wrong? Thanks in advance.

user3623571
  • 47
  • 1
  • 7
  • You most likely have two versions of Javassist on your classpath. Ensure that you only have single version of Javassist >=3.16 on your classpath. Take a look at [this similar question](http://stackoverflow.com/q/21454931/2071828). – Boris the Spider May 15 '14 at 18:33
  • Javassist library, which was included with Hibernate, has 3.15 version. So if I download a newer version and include it with excluding old one it should solve the problem? – user3623571 May 15 '14 at 18:44
  • You don't say which version of Hibernate you are using, or what "included with Hibernate" means. – Boris the Spider May 15 '14 at 18:45
  • I've just added Hibernate 4.x library from global libraries. One of added files was Javassist 3.15. – user3623571 May 15 '14 at 18:49
  • Again, I am unsure what this means. I assume it's an IDE feature? If so which IDE? Where does this "global library" come from? – Boris the Spider May 15 '14 at 18:50
  • Yes, It's NetBeans feature. – user3623571 May 15 '14 at 18:51
  • And you are sure that that's the **only** version of Javassist on your classpath? I would **strongly** recommend you switch from Ant (the NetBeans default) to Maven as your build tool. NetBeans support of Maven is excellent and the library management is much better. – Boris the Spider May 15 '14 at 18:53
  • Looking at the [Hibernate Maven repo](http://mvnrepository.com/artifact/org.hibernate/hibernate-core/4.0.1.Final), it seems that 3.15 was the correct version for Hibernate 4.0.1.Final to 4.2.6.Final. – Boris the Spider May 15 '14 at 18:58
  • I definitely haven't added any extra libraries if JavaAssist version is correct what else could it be? – user3623571 May 15 '14 at 19:17
  • I've also tried it with Maven. Getting very the same error. – user3623571 May 15 '14 at 20:11
  • So I've deleted JavaAssist library which NetBeans suggested to use and now it works. Coludn't find using of another JavaAssist library and for sure haven't added any. Anyway It helped. Don't have enough reputation to post answer, so please somebody do it. – user3623571 May 15 '14 at 20:50

0 Answers0