0

我正在从 WAS 8 迁移到 WAS 9。我的应用程序使用 Hibernate 4.3.0.Beta3 版本和 spring 4.0.3。在应用程序启动时,我收到此错误:

An error occurred in the org.hibernate.jpa.HibernatePersistenceProvider persistence
    provider when it attempted to create the container entity manager factory for 
    the AccidentCompensation persistence unit. The following error occurred: 
java.lang.IllegalStateException: java.lang.UnsupportedOperationException: 
    No current bean manager found in CDI service
    at com.ibm.ws.jpa.cdi.impl.BeanManagerInvocationHandler.invoke(BeanManagerInvocationHandler.java:80)

如果需要更多信息,请告诉我。

4

1 回答 1

1

我解决了我的问题,编写了一个自定义会话构建器并从工厂实例中禁用了 beanreference。

    package br.com.temasistemas.utils.hibernate;

import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderFactory;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;

public class CustomSessionFactoryBuilderFactory implements SessionFactoryBuilderFactory {

    @Override
    public SessionFactoryBuilder getSessionFactoryBuilder(final MetadataImplementor metadata,
            final SessionFactoryBuilderImplementor defaultBuilder) {
        return defaultBuilder.applyBeanManager(null);
    }

}

create a service file in 

META-INF/services/org.hibernate.boot.spi.SessionFactoryBuilderFactory

content

br.com.temasistemas.utils.hibernate.CustomSessionFactoryBuilderFactory
于 2018-12-04T02:58:00.190 回答