i have the following setup for aip-persistence-context file:
where the S2ServiceLocatorBean is a spring bean that uses an annotation (managed by a cxf dynamic proxy called jaxwsclientproxy) to call a service to return a datasource. code fragment below:Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="aiplocatorbean" class="com.locator.service.S2LocatorServiceBean"> <property name="logicalDbName" value="ETS_AIPDB"></property> <property name="sourceHostName" value="DOMAIN1"></property> <property name="logicalServerName" value="USDTP6"></property> </bean> <bean id="aipDataSource" class="com.locator.C3P0DataSourceFactoryBean" depends-on="aiplocatorbean"> <property name="locatorDao" ref="aiplocatorbean"/> <property name="connectionPoolName" value="ETSAIPDB_DATASOURCE"/> </bean> <bean id="aipEntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceXmlLocation" value="META-INF/aip-persistence-unit.xml" /> <property name="persistenceUnitName" value="aipPerUnit" /> <property name="dataSource" ref="aipDataSource"/> <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.OracleDialect" /> </bean> </property> </bean> <bean id="aipTransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="aipEntityManagerFactory" /> <property name="dataSource" ref="aipDataSource" /> </bean> <jpa:repositories base-package="com.service.aip.impl.persistence.jpa" transaction-manager- ref="aipTransactionManager" /> <tx:annotation-driven transaction-manager="aipTransactionManager" />
the problem is when i use jpa:repositories along with EMF (entity manager factory) the line locatorService.submitLocatorGetDbInfo always throws NPE (Null Pointer Exception).Code:public class S2ServiceLocatorBean { // this is the jaxws client proxy created to call the service // the annotation is processed using a BeanAnnotationPostProcessor and // we use afterPropertiesSet and use Spring's ReflectionServiceFactoryBean to get the // SEI (service endpoint interface ) to make a SOAP call to get the DB Info @ServiceProxy(channel="locator") LocatorDBInfoSvc locatorService; public DBInfo getLocatorInfo() { LocatorGetDbInfoResponseT response = locatorService.submitLocatorGetDbInfo(input); return new DBInfo(response); } }
it's as if once spring-data-jpa is done with making proxy objects it won't allow the ServiceProxy beanannotationpost processor to do it's job.
any clues to why this happens as i find it quite interesting.
note : i also implemented the SmartLifeCycle on S2ServiceLocatorBean so it would be the first bean that's instatiated or destroyed....this also doesn't help.
regards,
-cogitate


Reply With Quote
