Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Hibernate搜索:NoSuchMethod org.Hibernate.engine.transaction.spi.TransactionEnvironment.getJtaPlatform()?_Spring_Hibernate_Jpa_Hibernate Search - Fatal编程技术网

Spring Hibernate搜索:NoSuchMethod org.Hibernate.engine.transaction.spi.TransactionEnvironment.getJtaPlatform()?

Spring Hibernate搜索:NoSuchMethod org.Hibernate.engine.transaction.spi.TransactionEnvironment.getJtaPlatform()?,spring,hibernate,jpa,hibernate-search,Spring,Hibernate,Jpa,Hibernate Search,我有一个使用spring和hibernate的java项目。我正在集成hibernate搜索来进行全文搜索。因为我集成了hibernate搜索,所以我无法保存我的实体。我得到以下错误: org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.transac

我有一个使用spring和hibernate的java项目。我正在集成hibernate搜索来进行全文搜索。因为我集成了hibernate搜索,所以我无法保存我的实体。我得到以下错误:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.hibernate.engine.transaction.spi.TransactionEnvironment.getJtaPlatform()Lorg/hibernate/engine/transaction/jta/platform/spi/JtaPlatform;
完整的堆栈跟踪在这里

这里是我要为用户保存项目时的spring控制器:

   @RequestMapping(value="/saveproject", method = RequestMethod.POST)
    public ModelAndView saveProject(@ModelAttribute Project  project,HttpSession session){
         User user = (User) session.getAttribute(USER);
         user.getProjects().add(project);
         ModelAndView modelAndView = new ModelAndView();
         modelAndView.setViewName("projectSuccess");
         modelAndView.addObject("project", project);
         userServices.updateUser(user);
         return modelAndView;
    } 
这里是服务部分中的updateUser方法实现:

@Transactional(propagation= Propagation.REQUIRED, readOnly=false)
@Service
public class UserServicesImpl implements UserServices {

@Autowired
    private UserDao userDao;

    public void updateUser(User user) {
            userDao.updateUser(user);

        }
..other methods
}
以下是@Repository的更新用户方法:

@Repository
public class UserDaoImpl extends AbstractDaoImpl<User, Long> implements UserDao {

    protected UserDaoImpl() {
        super(User.class);
    }
    @Override
        public void updateUser(User user) {
            saveOrUpdate(user);

        }
...other methods
}
@存储库
公共类UserDaoImpl扩展了AbstractDaoImpl实现了UserDao{
受保护的UserDaoImpl(){
super(User.class);
}
@凌驾
public void updateUser(用户){
保存或更新(用户);
}
…其他方法
}
摘要:

    public abstract class AbstractDaoImpl<E, I extends Serializable> implements AbstractDao<E,I> {

        private Class<E> entityClass;

        protected AbstractDaoImpl(Class<E> entityClass) {
            this.entityClass = entityClass;
        }

        @Autowired
        private SessionFactory sessionFactory;

        public Session getCurrentSession() {
            return sessionFactory.getCurrentSession();
        }


        @Override
        public void saveOrUpdate(E e) {
            getCurrentSession().saveOrUpdate(e);
        }

    ... others methods


        public void indexDatabase(){
            Session session  = getCurrentSession();
            FullTextSession fullTextSession = Search.getFullTextSession(session);  
            try {
                fullTextSession.createIndexer().startAndWait();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
        }

}
公共抽象类AbstractDaoImpl实现AbstractDao{
私有类实体类;
受保护的AbstractDaoImpl(类entityClass){
this.entityClass=entityClass;
}
@自动连线
私人会话工厂会话工厂;
公共会话getCurrentSession(){
返回sessionFactory.getCurrentSession();
}
@凌驾
公共作废保存或更新(E){
getCurrentSession().saveOrUpdate(e);
}
…其他方法
public void indexDatabase(){
会话会话=getCurrentSession();
FullTextSession FullTextSession=Search.getFullTextSession(会话);
试一试{
fullTextSession.createIndexer().startAndWait();
}捕捉(中断异常e){
//TODO自动生成的捕捉块
e、 printStackTrace();
} 
}
}
在我的hibernate.cfg.xml中,我配置了索引:

文件系统 E:\workspace\index


我使用Hibernate4.2和HibernateSearch4.5。我不明白问题出在哪里。

Hibernate搜索4.5使用了错误版本的Hibernate ORM。方法
getJtaPlatform
存在,但返回类型不同

在Hibernate 4.2方法TransactionEnvironment.getJtaPlatform()中返回

在Hibernate 4.3中,它返回:

HibernateSearch4.5需要Hibernate4.3。这是记录在案的,例如:

您将需要hibernate-core-4.3.1.Final.jar及其可传递依赖项


Hibernate搜索4.5使用了错误版本的Hibernate ORM。方法
getJtaPlatform
存在,但返回类型不同

在Hibernate 4.2方法TransactionEnvironment.getJtaPlatform()中返回

在Hibernate 4.3中,它返回:

HibernateSearch4.5需要Hibernate4.3。这是记录在案的,例如:

您将需要hibernate-core-4.3.1.Final.jar及其可传递依赖项


我也有这个问题。我在maven项目中使用了HibernateSearch4.5Final。 Maven导入了正确的依赖项,如hibernate代码4.3等,但这个问题仍然存在。 经过我们的调试,甚至进入hibernate core JAR之后,我放弃了,尝试了hibernate search orm 4.0 Final和hibernate core 4.0 Final。异常消失了,他找到了丢失的方法。 这是一种非常奇怪的行为。。。
我知道这不是一个明确的解决方案,但如果您能够使用4.0版,它就会起作用。我也有这个问题。我在maven项目中使用了HibernateSearch4.5Final。 Maven导入了正确的依赖项,如hibernate代码4.3等,但这个问题仍然存在。 经过我们的调试,甚至进入hibernate core JAR之后,我放弃了,尝试了hibernate search orm 4.0 Final和hibernate core 4.0 Final。异常消失了,他找到了丢失的方法。 这是一种非常奇怪的行为。。。
我知道这不是一个明确的解决方案,但如果您能够使用4.0版,它会起作用

谢谢Mikko的回复。我已将hibernate版本更改为4.3.1.Final,但我遇到了另一个错误。原因是:java.lang.NoClassDefFoundError:org/hibernate/service/jta/platform/spi/JtaPlatform,位于org.springframework.orm.hibernate4.SpringSessionContext.(SpringSessionContext.java:56)。。。139更多原因:java.lang.ClassNotFoundException:org.hibernate.service.jta.platform.spi.JtaPlatform at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa。完整的错误在这里。我认为这是spring和hibernate的兼容性问题。感谢Mikko的回复。我已将hibernate版本更改为4.3.1.Final,但我遇到了另一个错误。原因是:java.lang.NoClassDefFoundError:org/hibernate/service/jta/platform/spi/JtaPlatform位于org.springframework.orm.hibernate4.SprInSessionContext.(SpringSessionContext.java:56)…139更多原因:java.lang.ClassNotFoundException:org.hibernate.service.jta.platform.spi.JtaPlatform位于org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa。完全的错误在这里。我认为这是spring和hibernate的兼容性问题。这是关于工件的版本。类文件不包含所需的方法,因此很可能您使用的是jar文件的不兼容版本。这是关于工件的版本。类文件不包含所需的方法,因此很可能您使用的是不兼容版本的jar文件。这是我所做的,但我使用的是hibernate core 4.2.8.Final。此版本也可以。我希望它很快得到纠正。感谢a lotI使用的是不同版本的hibernate core和hibernate search jar。我将b的版本更改为4.3.5.Finaloth和问题解决了。这就是我所做的,但我使用的是hibernate core 4.2.8.Final。这个版本也可以。我希望它能很快得到纠正。感谢lotI使用了不同版本的hibernate core和hibernate搜索罐。我将和的版本都更改为4.3.5.Final