我遇到错误
嵌套的异常是java.lang.NoSuchMethodError: javax / persistence / Table.indexes()[Ljavax / persistence / Index;
我的controller-servlet.xml文件是
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/jsp/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<beans:property name="url"
value="jdbc:oracle:thin:" />
<beans:property name="username" value="user" />
<beans:property name="password" value="123" />
</beans:bean>
<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.company.bmdashboard.beans.BatchJob</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="bMDashboardRepository" class="com.company.bmdashboard.repositories.BMDashboardRepositoryImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="bMDashboardService" class="com.company.bmdashboard.services.BMDashboardServiceImpl">
<beans:property name="bMDashboardRepository" ref="bMDashboardRepository"></beans:property>
</beans:bean>
<context:component-scan base-package="com.company.bmdashboard" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<beans:bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
</beans:beans>
我的jars文件是
我的RepositoryImpl是
@Repository
public class BMDashboardRepositoryImpl implements BMDashboardRepository{
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sf){
this.sessionFactory = sf;
}
@Override
public ArrayList<BatchJob> retrieveAllBatchJobs() {
// TODO Auto-generated method stub
System.out.println("Repository Impl: in retrieve all batch jobs");
Session session= sessionFactory.getCurrentSession();
@SuppressWarnings("unchecked")
List<BatchJob> allBatchJobs=session.createQuery("From BatchJob").list();
for(BatchJob bj:allBatchJobs)
{
System.out.println(bj.toString());
}
return (ArrayList<BatchJob>) allBatchJobs;
}
}
当我在webspehre中发布代码时,出现此错误。我认为jar文件有问题吗?
预先感谢
答案 0 :(得分:0)
我找到了解决方法。
我使用的是WAS 8.5,它提供了自己的支持JPA 2.0的JDK。 JPA 2.1中引入了@ Table.indexes()方法。
解决方案
1)将WAS升级到9
2)代替使用@Table注释,请尝试使用xml映射。我用的是ClassName.hbm.xml。