Jaspersoft Studio - net.sf.jasperreports.engine.JRException: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration

user2845946 picture user2845946 · Mar 8, 2014 · Viewed 7.8k times · Source

I am using the Data Adapter Wizard in Jaspersoft Studio 5.5.1 in order to set up a Hibernate connection.

The wizard asks for the Hibernate configuration (hibernate.cfg.xml) which is what I supply. My Hibernate configuration is functional in other settings...

When I test the connection in the wizard, I get the following error:

net.sf.jasperreports.engine.JRException: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:137)
    at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:129)
    at com.jaspersoft.studio.data.wizard.AbstractDataAdapterWizard$3.run(AbstractDataAdapterWizard.java:163)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at net.sf.jasperreports.engine.util.JRClassLoader.loadClassForRealName(JRClassLoader.java:175)
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:79)
    ... 3 more

It seems that the wizard is missing the Hibernate binaries. My question is; how to properly attach these binaries to the classpath of Jaspersoft Studio?

EDIT

One may add JARs to the classpath with 'The Database JDBC Connection' option:

enter image description here

But this isn't possible with the 'Hibernate Session' option:

enter image description here

Answer

Raul Cacacho picture Raul Cacacho · Jun 14, 2016

I worked my pom was added to this line

 <dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.6.0</version>
<type>jar</type>
</dependency>