views:

272

answers:

1

I have a very weird problem. Have an application using Hibernate and spring.I have an entitymanger defined which uses a JNDI lookup .It looks something like this

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

        </bean>
    </property>

</bean>

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
    <property name="targetDataSource">
        <bean
            class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="jdbc/pmp" />
        </bean>
    </property>
</bean>

This application runs fine in DEV. But when we move to higher envs the team that deploys this application does it successfully initially but after a few restarts of the application the entitymanager starts giving this problem

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: ConfigAPPPersist] Unable to build EntityManagerFactory 
     at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677) 
     at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132) 
     at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224) 
     at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368) 
     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334) 
     ... 32 more 
     Caused by: org.hibernate.MappingException: **property mapping has wrong number of columns**: com.***.***.jpa.marketing.entity.MarketBrands.$performasure_j2eeInfo type: object

Now you would say this is pretty obvious the entity MarketBrands is incorrect. But its not it maps to the table just fine. And the same code works on DEV.

Also the jndi cannot be incorrect since it deploys and works fine initially but throws uo this error after a restart.

This is weird and not very logical. But if someone has faced this or has any idea on what might be causing this Please!! help

The persistence.xml for the persitence unit has very little

<?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_1_0.xsd" version="1.0">

    <persistence-unit name="ConfigAPPPersist">
    <!--    commented code
        --> 
    </persistence-unit>

</persistence>
A: 

Does the MarketingBrands have an Object property? If yes, try to change it to Serializable (and if this is not possible because the field if there because the code has been instrumented by PeformaSure, then I don't have any other solution than "open a ticket" with Quest).

Pascal Thivent
MarketingBrands is an entity and implements serializable and this maps to a table in the DB .I know this makes no sense .I guess i have to ask them to turn off performasure and try.
neverland
@neverland I'm not saying that `MarketingBrands` doesn't implements `Serializable`, I was just suggesting to change its `$performasure_j2eeInfo` property of type `Object` to `Serializable`. But this is very likely a property added by PerformaSure now that you have confirmed they are using it so I don't think it will be possible. But PerformaSure is a suspect here, this property should be `@Transcient`.
Pascal Thivent
@Pascal-Performasure was the culprit ..Turning it off solved the problem ..thanks!
neverland
@neverland Glad it's solved. And feel free to upvote and accept my answer ;)
Pascal Thivent