2

Hibernate 接続をセットアップするために、Jaspersoft Studio 5.5.1 で Data Adapter Wizard を使用しています。

hibernate.cfg.xmlウィザードは、私が提供する Hibernate 構成 ( ) を要求します。私の休止状態の設定は他の設定で機能しています...

ウィザードで接続をテストすると、次のエラーが表示されます。

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

ウィザードが Hibernate バイナリを欠いているようです。私の質問は; これらのバイナリを Jaspersoft Studio のクラスパスに適切にアタッチする方法は?

編集

「データベース JDBC 接続」オプションを使用して、クラスパスに JAR を追加できます。

ここに画像の説明を入力

しかし、これは 'Hibernate Session' オプションでは不可能です:

ここに画像の説明を入力

4

2 に答える 2

0

Jaspersoft スタジオのクラスパスは次の場所にあるようです:

Jaspersoft Studio-5.5.1.final\features\jre.win32.win32.x86_64.feature_1.7.0.u25\jre\lib\ext

上記のクラスパスに Hibernate JAR をコピーすると、回答に投稿した例外が次のように変わりました。

net.sf.jasperreports.engine.JRException: java.lang.reflect.InvocationTargetException
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:147)
    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.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:121)
    ... 3 more
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.microsoft.sqlserver.jdbc.SQLServerDriver]
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:245)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.loadDriverIfPossible(DriverManagerConnectionProviderImpl.java:200)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.buildCreator(DriverManagerConnectionProviderImpl.java:156)
    at org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:95)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:260)
    at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:94)
    at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:89)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:206)
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
    at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1885)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1843)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.microsoft.sqlserver.jdbc.SQLServerDriver
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:230)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:242)
    ... 22 more

新しい例外は、SQL Server JDBC ドライバーが見つからないことが原因です。そのため、このドライバーを同じクラスパスにコピーしました。例外は次のように変更されました。

net.sf.jasperreports.engine.JRException: java.lang.reflect.InvocationTargetException
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:147)
    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.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:121)
    ... 3 more
Caused by: java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
    at java.lang.Class.getMethod0(Unknown Source)
    at java.lang.Class.getMethod(Unknown Source)
    at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:124)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1928)
    ... 8 more
Caused by: java.lang.ClassNotFoundException: javax.validation.ValidatorFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 16 more

今回の例外は、Bean Validation APIの欠落によるものです。そこでvalidation-api-1.1.0.Final.jar、Jaspersoft のクラスパスにコピーしました。これは、最終的に Hibernate に接続するのに十分でした。

オブス。私の休止状態は4.3.1です。

于 2014-03-09T11:03:49.500 に答える