MappingNotFoundException when testing a Hibernate Session data adapter

0

Hi,

I created a Hibernate Session data adapter in Jaspersoft Studio from a Hibernate configuration file (hibernate.cfg.xml) that works correctly on a very simple JSF application.

When I test the adapter in Jaspersoft Studio I get an InvocationTargetException because one of the resources is not found.

These are the contents of the configuration file:

<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
    <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
    <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
    <property name="hibernate.connection.username">course</property>
    <property name="hibernate.connection.password">course</property>
    <mapping resource="com/standoutdev/jasper/Employee.hbm.xml"/>
    <mapping resource="com/standoutdev/jasper/Department.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

Both resources (Employee and Department) exist in the relative path specified in the above configuration, but Jaspersoft Studio doesn't find them. I have tried specifying the absolute path to the resouces in the configuration but it doesn't solve the problem. I have also tried moving all the files to the same path where the configuration file resides, and removing the path from the configuration file, but it didn't help either.

This is what the official documentation about Hibernate data adapters says:

"JasperReports provides a way to use HQL directly in your report. To do so, first set up a Hibernate connection. Expand your classpath to include all classes, JARs, and configuration files used by your Hibernate mapping. In other words, Jaspersoft Studio must be able to access all the *.hbm.xml files you plan to use, the JavaBeans declared in those files, the hibernate.cfg.xml file, and any other JARs used (for example, JARs that access the database under Hibernate)."

But, the data adapter wizard doesn't provide a method to add a classpath for Hibernate Session data adapters, and the example used in the documentation doesn't make sense to me, as it is an example of an hibernate data adapter but the image actually shows a wizard where a JDBC data adapter is being created (which does have a classpath option).

I have tried manually adding a <classpath> tag to the adapter's XML file to define the path, but it didn't make any difference.

Can someone shed some light on this?

This is the stacktrace I get when testing the adapter:

net.sf.jasperreports.engine.JRException: java.lang.reflect.InvocationTargetException
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:138)
    at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:122)
    at com.jaspersoft.studio.data.DataAdapterEditorPart$1.widgetSelected(DataAdapterEditorPart.java:170)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at com.jaspersoft.studio.rcp.intro.Application.start(Application.java:99)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
 
Caused by: java.lang.reflect.InvocationTargetException
 
    at sun.reflect.GeneratedMethodAccessor78.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:94)
    ... 29 more
 
Caused by: org.hibernate.MappingNotFoundException: resource: com/standoutdev/jasper/Employee.hbm.xml not found
 
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:610)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1510)
    ... 33 more

I'm using Jaspersoft Studio Community version 6.3.1 final

Thanks!

cadlg's picture
4
Joined: May 4 2015 - 11:48am
Last seen: 7 months 1 week ago

1 Answer:

0

Any suggestion? :)

cadlg's picture
4
Joined: May 4 2015 - 11:48am
Last seen: 7 months 1 week ago
Feedback