关于Spring hibernate Application中自由的数据源问题

时间:2014-03-21 14:55:33

标签: spring hibernate websphere websphere-liberty

我有一个spring和hibernate应用程序,我们正试图从Jboss移植到WAS Liberty配置文件。当弹簧工厂初始化时,我得到低于错误

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myDatasource': Post-processing of the FactoryBean's object failed; nested exception is org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource [Xlint:cantFindType]
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:165)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1441)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 87 more Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine superclass of missing type com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource [Xlint:cantFindType]
at org.aspectj.weaver.reflect.ReflectionWorld$ExceptionBasedMessageHandler.handleMessage(ReflectionWorld.java:129)
at org.aspectj.weaver.Lint$Kind.signal(Lint.java:325)
at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)
at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getSuperclass(MissingResolvedTypeWithKnownSignature.java:98)
at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:144)
at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:82)
at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:236)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:198)
at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:252)
at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:284)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findAdvisorsThatCanApply(AbstractAdvisorAutoProxyCreator.java:117)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:87)
at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:68)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:359)
at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.postProcessObjectFromFactoryBean(AbstractAutowireCapableBeanFactory.java:1598)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162) ... 92 more

我的服务器具有以下数据源配置

 <dataSource id="MyDS" jdbcDriverRef="Oracle" jndiName="jdbc/myDS">

应用程序上下文中的数据源bean定义如下

<bean id="myDatasource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jdbc/myDS" />
    </bean>

我很感激帮助。这似乎与类加载有关,但我无法弄明白。

2 个答案:

答案 0 :(得分:1)

尝试为数据源bean定义指定以下属性:

<bean id="myDatasource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="jdbc/myDS"/>
        <property name="lookupOnStartup" value="false"/>
        <property name="cache" value="true" />
        <property name="proxyInterface"  value="javax.sql.DataSource" />
    </bean>

答案 1 :(得分:0)

proxyInterface解决方案适用于WAS 8.5.5 Liberty Profile。 在WAS 7中,这也可作为替代解决方案:

<jee:jndi-lookup id="WASdataSource" jndi-name="java:comp/env/jdbc/admt" />

<bean id="dataSource" class="org.springframework.jdbc.datasource.WebSphereDataSourceAdapter">
        <property name="targetDataSource" ref="WASdataSource"/>
</bean>