Announcement Announcement Module
Collapse
No announcement yet.
Roo 1.2.4 upgrade - HibernatePersistence not found Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo 1.2.4 upgrade - HibernatePersistence not found

    Hi,

    We recently staged upgrading from STS 3.2.0 to 3.3.0 and Roo 1.2.3 to 1.2.4 for a multi-module web portal project.

    Hit a problem with the HibernatePersistence class not found. For the impatient, the problem was resolved for us by changing the Hibernate dependency from 4.2.2.Final to 4.2.1.Final.

    Here's the exception:

    Code:
    2013-07-17 14:00:57,601 ERROR [localhost-startStop-1] org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:319) : Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [jar:file:/D:/Software/SpringSource/sts.3.3.0/vfabric-tc-server-developer-2.9.2.RELEASE/base-instance/wtpwebapps/portal/WEB-INF/lib/portal-core-2.0.1.jar!/META-INF/spring/applicationContext-core.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.hibernate.ejb.HibernatePersistence]
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:922)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
    	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
    	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.IllegalArgumentException: Cannot find class [org.hibernate.ejb.HibernatePersistence]
    	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:296)
    	at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:275)
    	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    	... 26 more
    Caused by: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1713)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1558)
    	at org.springframework.util.ClassUtils.forName(ClassUtils.java:260)
    	at org.springframework.util.ClassUtils.resolveClassName(ClassUtils.java:293)
    	... 30 more
    Here's the persistence.xml:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    <persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
                <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
                <!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
                <property name="hibernate.connection.charSet" value="UTF-8"/>
                <!-- Uncomment the following two properties for JBoss only -->
                <!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
                <!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
            </properties>
        </persistence-unit>
    </persistence>
    This is on a Windows 7 machine. It has not been tried on Linux or Mac. Also noticed that in the pre-upgrade project using STS 3.2.0 a Java import for the offending class can be successfully added. This doesn't work in the upgraded version:

    Code:
    #import org.hibernate.ejb.HiberatePersitence;
    Looking at the Hibernate version, Roo has upgraded from 4.1.8.Final to 4.2.2.Final. The JPA version remains unchanged at 1.0.1.Final. Switching from 4.2.2.Final to 4.2.1.Final fixed things up for us. I wonder if anyone has hit this problem or if there was a problem with the jar I ended up with. I can't see any issues when I unpacked it. HibernatePersistence.class is there and in the right spot.

    Code:
    <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.2.2.Final</version>
            </dependency>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-entitymanager</artifactId>
                <version>4.2.2.Final</version>
                <exclusions>
                    <exclusion>
                        <groupId>cglib</groupId>
                        <artifactId>cglib</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>dom4j</groupId>
                        <artifactId>dom4j</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.hibernate.javax.persistence</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
                <version>1.0.1.Final</version>
            </dependency>
    Anyway just wanted to share our experience. BTW we love Roo. We've been using it for almost 2 years now. Originally we intended to roll it out, thinking it's value was best for getting the application, build and dependencies off the ground. But it continues to prove invaluable to keep pace with upgrade complexities and give great implementation guidance.

    Great work people!
    Last edited by RnR; Jul 18th, 2013, 09:13 AM.
Working...
X