0

I'm trying to use Hibernate with jasperreports, using jasersoft studio (6.10.0),

I'm using hibernate 5 in my project, so I'm using annotations to map classes.

When I'm creating the Hibernate Data Adapter, I chose to use "Annotations" but I got the following error:

java.lang.ClassNotFoundException: 
org.hibernate.cfg.AnnotationConfiguration cannot be found by 
net.sf.jasperreports_6.10.0.final

Am I missing some jar files?

menteith
  • 596
  • 14
  • 51
  • 1
    Note hibernate is an optional dependance of jasper report, please check that first that you have hibernate in class path. – Petter Friberg Oct 04 '19 at 16:18

1 Answers1

0

In Hibernate 3.6, “org.hibernate.cfg.AnnotationConfiguration” is deprecated, and all its functionality has been moved to “org.hibernate.cfg.Configuration“.

So , you can safely replace your “AnnotationConfiguration” with “Configuration” class.

Taken from Hibernate – The type AnnotationConfiguration is deprecated

In practical terms, it means you need to use other version of jasperreports that doesn't use deprecated API or downgrade Hibernate.

menteith
  • 596
  • 14
  • 51
  • 1
    This is pretty much the same as this other [answer](https://stackoverflow.com/a/23850005/5292302) and as information [jasper reports 6.10](https://mvnrepository.com/artifact/net.sf.jasperreports/jasperreports/6.10.0) have Hibernate 5.4.1.Final as a dependency. Hence it does not in itself use deprecated api and it is the latest version, hence "need to use other version" is not a feasible answer. Furthermore deprecated methods do not throw java.lang.ClassNotFoundException – Petter Friberg Oct 04 '19 at 16:23
  • @PetterFriberg `Furthermore deprecated methods do not throw java.lang.ClassNotFoundException`. This is not correct. Simply write a method that throws `ClassNotFoundException` when it doesn't find its dependency and annotate it a `@Deprecated`. – menteith Oct 04 '19 at 18:59