i'm trying add ehcache
(v2.6.0) hibernate 4.1.5.sp1
project, having configuration issues. specifically, i'm getting java.lang.noclassdeffounderror
: org/hibernate/cache/entityregion
error when try , build hibernate
configuration
<property name="hibernate.cache.use_second_level_cache">true</property> <property name="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.ehcacheregionfactory</property>
here's maven dependencies ...
<hibernate.version>4.1.5.sp1</hibernate.version> <hibernate.validator.version>4.3.0.final</hibernate.validator.version> <ehcacheversion>2.6.0</ehcacheversion> ... <!-- hibernate dependencies --> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-validator</artifactid> <version>${hibernate.validator.version}</version> </dependency> <dependency> <groupid>org.hibernate</groupid> <artifactid>hibernate-entitymanager</artifactid> <version>${hibernate.version}</version> </dependency> <dependency> <groupid>net.sf.ehcache</groupid> <artifactid>ehcache-core</artifactid> <version>${ehcacheversion}</version> </dependency>
here's java code use configure ...
configuration config = new configuration() .setproperty("hibernate.dialect", "org.hibernate.dialect.hsqldialect") .setproperty("hibernate.connection.driver_class", "org.hsqldb.jdbcdriver") .setproperty("hibernate.connection.url", "jdbc:hsqldb:mem:myprojecttestdb") .setproperty("hibernate.connection.username", "sa") .setproperty("hibernate.connection.password", "") .setproperty("hibernate.connection.pool_size", "1") .setproperty("hibernate.connection.autocommit", "true") .setproperty("hibernate.cache.provider_class", "org.hibernate.cache.hashtablecacheprovider") .setproperty("hibernate.hbm2ddl.auto", "create-drop") .setproperty("hibernate.show_sql", "true") .setproperty("hibernate.current_session_context_class", "thread") .setproperty("hibernate.cache.use_second_level_cache", "true") .setproperty("hibernate.cache.region.factory_class", "net.sf.ehcache.hibernate.ehcacheregionfactory") .addannotatedclass(organization.class) .addannotatedclass(state.class) .addannotatedclass(country.class) .addannotatedclass(domain.class) .addannotatedclass(community.class); final serviceregistry serviceregistry = new serviceregistrybuilder().applysettings(config.getproperties()).buildserviceregistry(); sessionfactory = config.buildsessionfactory(serviceregistry);
and here's hideous error. configuration missing?
java.lang.noclassdeffounderror: org/hibernate/cache/entityregion @ java.lang.class.getdeclaredconstructors0(native method) @ java.lang.class.privategetdeclaredconstructors(unknown source) @ java.lang.class.getconstructor0(unknown source) @ java.lang.class.getconstructor(unknown source) @ org.hibernate.cfg.settingsfactory.createregionfactory(settingsfactory.java:386) @ org.hibernate.cfg.settingsfactory.buildsettings(settingsfactory.java:251) @ org.hibernate.cfg.configuration.buildsettingsinternal(configuration.java:2270) @ org.hibernate.cfg.configuration.buildsettings(configuration.java:2266) @ org.hibernate.cfg.configuration.buildsessionfactory(configuration.java:1735) @ org.mainco.subco.orgsclient.service.organizationservicetest.setuporgservicetest(organizationservicetest.java:56) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:44) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:15) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:41) @ org.junit.internal.runners.statements.runbefores.evaluate(runbefores.java:27) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:76) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:50) @ org.junit.runners.parentrunner$3.run(parentrunner.java:193) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:52) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:191) @ org.junit.runners.parentrunner.access$000(parentrunner.java:42) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:184) @ org.junit.runners.parentrunner.run(parentrunner.java:236) @ org.eclipse.jdt.internal.junit4.runner.junit4testreference.run(junit4testreference.java:50) @ org.eclipse.jdt.internal.junit.runner.testexecution.run(testexecution.java:38) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:467) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.runtests(remotetestrunner.java:683) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.run(remotetestrunner.java:390) @ org.eclipse.jdt.internal.junit.runner.remotetestrunner.main(remotetestrunner.java:197) caused by: java.lang.classnotfoundexception: org.hibernate.cache.entityregion @ java.net.urlclassloader$1.run(unknown source) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(unknown source) @ java.lang.classloader.loadclass(unknown source) @ sun.misc.launcher$appclassloader.loadclass(unknown source) @ java.lang.classloader.loadclass(unknown source) ... 32 more
ehcache-core files hibernate 3.x. hibernate 4.x comes own implementation ehcache. don't need use ehcache explicitly in hibernate 4.x. here best answer problem.
Comments
Post a Comment