Spring + Hibernate JPA 1.0 + Oracle IAS (OC4J): deploy error

Hi all!

I’m dealing with this problem for few days and I couldn’t solve it, so I’m going to ask the experts. Probably, it’s not a matter of Vaadin itself, but the integration with Spring and Hibernate (through JPA contract) and, most of all, the fact that the application server used is Oracle IAS 10.1.3.5.

So, I’m developing a Java 1.6 web application using Vaadin 6.8.2, Spring 2.5.6 and Hibernate 3.3.0. I’m using maven to build the WAR. We would like to use JAPContainer.

As examples, we used the following projects:

jpacontainer-addressbook-demo


jpacontainerjee6jndi


SpringIntegration

and, most of all:

SpringApplication

I’m trying to use JPA 1.0 Hibernate implementation for persistence but I’ve got this error during deployment phase (I’m stuck with 1.0 version due to OC4J limitations; this is the reason why I took Hibernate 3.3.0: latest version that assures compatibility with JPA 1.0):

12/09/11 17:25:49 oracle.oc4j.admin.internal.DeployerException: [intraRAM:intraRAM]
 - Eccezione durante la creazione di EntityManagerFactory tramite la classe PersistenceProvider org.hibernate.ejb.HibernatePersistence nell'unità di persistenza hibernatePU.
12/09/11 17:25:49   at com.evermind.server.ejb.exception.DeploymentException.exceptionCreatingEntityManagerFactory(DeploymentException.java:130)
12/09/11 17:25:49   at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.createContainerEntityManagerFactory(PersistenceUnitManagerImpl.java:197)
12/09/11 17:25:49   at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initializePersistenceUnit(PersistenceUnitManagerImpl.java:159)
12/09/11 17:25:49   at com.evermind.server.ejb.persistence.PersistenceUnitManagerImpl.initialize(PersistenceUnitManagerImpl.java:87)
12/09/11 17:25:49   at com.evermind.server.http.HttpApplication.createDefaultPersistenceUnitManager(HttpApplication.java:875)
12/09/11 17:25:49   at com.evermind.server.http.HttpApplication.<init>(HttpApplication.java:844)
12/09/11 17:25:49   at com.evermind.server.ApplicationStateRunning.getHttpApplication(ApplicationStateRunning.java:435)
12/09/11 17:25:49   at com.evermind.server.Application.getHttpApplication(Application.java:592)
12/09/11 17:25:49   at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.createHttpApplicationFromReference(HttpSite.java:2280)
12/09/11 17:25:49   at com.evermind.server.http.HttpSite$HttpApplicationRunTimeReference.<init>(HttpSite.java:2199)
12/09/11 17:25:49   at com.evermind.server.http.HttpSite.addHttpApplication(HttpSite.java:1833)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:304)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:120)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.WebApplicationBinder.bindWebApp(WebApplicationBinder.java:92)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.ApplicationDeployer.bindWebApp(ApplicationDeployer.java:825)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.ApplicationDeployer.doDeploy(ApplicationDeployer.java:276)
12/09/11 17:25:49   at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:100)
12/09/11 17:25:49   at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
12/09/11 17:25:49   at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
12/09/11 17:25:49   at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
12/09/11 17:25:49   at java.lang.Thread.run(Thread.java:662)
12/09/11 17:25:50 AVVERTENZA: DeployerRunnable.run [intraRAM:intraRAM]
 - Eccezione durante la creazione di EntityManagerFactory tramite la classe PersistenceProvider org.hibernate.ejb.HibernatePersistence nell'unità di persistenza hibernatePU.oracle.oc4j.admin.internal.DeployerException: [intraRAM:intraRAM]
 - Eccezione durante la creazione di EntityManagerFactory tramite la classe PersistenceProvider org.hibernate.ejb.HibernatePersistence nell'unità di persistenza hibernatePU.
    at oracle.oc4j.admin.internal.DeployerBase.execute(DeployerBase.java:133)
    at oracle.oc4j.admin.jmx.server.mbeans.deploy.OC4JDeployerRunnable.doRun(OC4JDeployerRunnable.java:52)
    at oracle.oc4j.admin.jmx.server.mbeans.deploy.DeployerRunnable.run(DeployerRunnable.java:81)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    at java.lang.Thread.run(Thread.java:662)

Here’s my persistence.xml (put as /src/main/resources/META-INF/persistence.xml):

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">

    <persistence-unit name="hibernatePU" transaction-type="JTA">    
        <provider>org.hibernate.ejb.HibernatePersistence</provider>        
        <jta-data-source>jdbc/WEBRAM-DS</jta-data-source>        
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
            <property name="hibernate.hbm2ddl.auto" value="update" />
        </properties>
    </persistence-unit>
</persistence>

And here’s my springApplicationContext.xml:

<context:property-placeholder location="classpath*:*.properties" />

<context:spring-configured />
<context:annotation-config />

<context:component-scan base-package="it.foo.goo" />

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager" />

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceUnitName" value="hibernatePU" />
    <property name="jpaVendorAdapter">
        <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
            <property name="generateDdl" value="true" />
            <property name="showSql" value="true" />
            <property name="databasePlatform" value="org.hibernate.dialect.OracleDialect" />
        </bean>
    </property>
</bean>

<!-- Turn on @Autowired, @PostConstruct etc support -->
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" />

And, of course, my pom.xml dependencies (sorry, it’s a huge pom, and I know that it could be smaller…):

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <vaadin.version>6.8.2</vaadin.version>
    <gwt.version>2.3.0</gwt.version>
    <gwt.plugin.version>2.2.0</gwt.plugin.version>
    <hibernate-core-version>3.3.0.sp1</hibernate-core-version>
    <slf4j.version>1.5.6</slf4j.version>
    <spring.version>2.5.6</spring.version> <!-- L.P. using 2.5.6 in the place of 3.1.2 due to OC4J xsd parser error!! -->
    <aspectj.version>1.6.3.RELEASE</aspectj.version>
</properties>

<dependencies
    <!-- VAADIN -->
    <dependency>
        <groupId>com.vaadin</groupId>
        <artifactId>vaadin</artifactId>
        <version>${vaadin.version}</version>
    </dependency>
    <!-- LOGGGIN: Slf4j with Log4J backend -->
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.log4j</groupId>
        <artifactId>com.springsource.org.apache.log4j</artifactId>
        <version>1.2.15</version>
        <scope>runtime</scope>
    </dependency>        
    <!-- ASPECTj -->
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>com.springsource.org.aspectj.runtime</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>1.6.3</version>
    </dependency>        
    <!-- SPRING -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.core</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.context</artifactId>
        <version>${spring.version}</version>
        <exclusions>
            <!-- Exclude Commons Logging in favor of SLF4j -->
            <exclusion>
                <groupId>org.apache.commons</groupId>
                <artifactId>com.springsource.org.apache.commons.logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.aop</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.aspects</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.jdbc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.orm</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.transaction</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.web</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>org.springframework.web.servlet</artifactId>
        <version>${spring.version}</version>
    </dependency>        
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.4.0.GA</version>
        <exclusions>
            <!-- Exclude SLF4j - Explicit dependency already added -->
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>com.springsource.javax.persistence</artifactId>
        <version>1.0.0</version>
    </dependency>
    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>com.springsource.javax.validation</artifactId>
        <version>1.0.0.GA</version>
    </dependency>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>com.springsource.javax.transaction</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>com.springsource.org.apache.commons.fileupload</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>org.tuckey</groupId>
        <artifactId>com.springsource.org.tuckey.web.filters.urlrewrite</artifactId>
        <version>3.1.0</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>com.springsource.javax.servlet.jsp.jstl</artifactId>
        <version>1.2.0</version>
    </dependency>
</dependencies>

I’ve had problems retrieving the datasource identified on persistence.xml, but now I solved them and logs don’t say “unable to find datasource with name” anymore. The problem now is that Spring cannot instantiate the EntityManagerFactory through the org.hibernate.ejb.HibernatePersistence class, that according to what I understand should become my PersistenceProvider.

I’ve seen so many configuration around and all of them seem to be coherent with mine. I’m missing something, I’m sure of it, but I can’t figure out what it is :frowning:

Does someone with more experience on the field have ideas about? Am I the only one who tried to use Vaadin on OC4J in a such way?

Thank you in advance,
Luca

In some examples I found this line in the properties of the hibernate persistence unit:

<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.TransactionManagerLookup"/>

It seems to specify the lookup class that provide the transaction manager, it is really needed? I found some different implementation for different application server, but not one specific for Oracle OC4J/IAS, so I tried with this general one.

Of course, the error persists… and it’s frustrating 'cause it’s not so verbose and clear :frowning: