IBM WAS Liberty Error +缺少类型com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource

时间:2015-11-19 20:51:22

标签: spring jndi websphere-liberty

我正在将一个glassfish项目转换为IBM WAS Liberty,我很难在访问使用jndi(jdbc / dataphile)在Liberty(server.xml)中配置的连接池时遇到问题。

我连续获得缺少类型com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource 错误。

以下是一些更多细节:

<library id="DB2JCC4Lib">
    <fileset dir="C:/MyApps/db2/jdbc" id="db-fileset" includes="db2jcc4-9.5.jar"/>
</library>

<dataSource id="dataSource" jndiName="jdbc/dataphile" type="javax.sql.DataSource">
    <jdbcDriver libraryRef="DB2JCC4Lib"/>
    <connectionManager minPoolSize="2" numConnectionsPerThreadLocal="10"/>
    <properties.db2.jcc databaseName="DUNDEEPD" id="DataphileProperties" password="username" portNumber="30001" serverName="xxx.xx.xxx.xxx" user="username"/>
</dataSource>

我的堆栈跟踪在下面;

[ERROR   ] Context initialization failed 
Caused by: org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException: warning can't determine modifiers 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:340)
    at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.raiseCantFindType(MissingResolvedTypeWithKnownSignature.java:232)
    at org.aspectj.weaver.MissingResolvedTypeWithKnownSignature.getModifiers(MissingResolvedTypeWithKnownSignature.java:104)
    at org.aspectj.weaver.ResolvedType.isInterface(ResolvedType.java:876)
    at org.aspectj.weaver.ResolvedType.getHierarchy(ResolvedType.java:355)
    at org.aspectj.weaver.patterns.KindedPointcut.fastMatch(KindedPointcut.java:126)
    at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.couldMatchJoinPointsInType(PointcutExpressionImpl.java:84)
    at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:238)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:200)
    at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:254)
    at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:286)
    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:1561)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:162)
    ... 58 more

2 个答案:

答案 0 :(得分:0)

我不是这方面的专家,但此处报道了类似的问题:

https://developer.ibm.com/answers/questions/9498/datasource-issue-on-liberty-in-spring-hibernate-application.html

解决方案需要将其添加到数据源:

<property name="resourceRef" value="true" />
<property name="expectedType" value="javax.sql.DataSource"/>

答案 1 :(得分:0)

我确实有足够的理论知道为什么,但这就是我从根本上解决问题的方法:

最初,在我的Spring XML架构配置中,我有以下内容:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/mydatasource" />

但我必须将其转换为以下内容:

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

基本上建议我必须强制执行此配置更改,这会添加以下属性:

<property name="proxyInterface"  value="javax.sql.DataSource"

希望能帮助其他人 感谢