org.springframework.jndi.TypeMismatchNamingException

  Recently, I am going on with a banking program, using Struts + Spring + Hibernate + WebSphere + Maven technology. I often meet with the org.springframework.jndi.TypeMismatchNamingException when I run my problem on the real system. After a long time struggling, I found a approch to this problem.

  Description:
Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'java:comp/env/jdbc/DataSourceName'; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource] available at JNDI location [java:comp/env/jdbc/DataSourceName] is not assignable to [javax.sql.DataSource]
at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:47)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parsePersistenceUnitInfo(PersistenceUnitReader.java:282)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.parseDocument(PersistenceUnitReader.java:216)
at org.springframework.orm.jpa.persistenceunit.PersistenceUnitReader.readPersistenceUnitInfos(PersistenceUnitReader.java:139)
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.readPersistenceUnitInfos(DefaultPersistenceUnitManager.java:294)
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:266)
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:251)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:192)
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)
... 92 more
Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource] available at JNDI location [java:comp/env/jdbc/DataSourceName] is not assignable to [javax.sql.DataSource]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:180)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:44)
... 102 more
 
  Approach:

  You should find the lib folder your web project is using, find the calsses12-10.1.0.4.jar, and delete it from your lib folder.

你可能感兴趣的:(java,maven,jdbc,orm,jpa)