hibernate 在websphere 9中的CDI服务中未找到当前Bean管理器

bvjxkvbb  于 2023-10-23  发布在  其他
关注(0)|答案(1)|浏览(132)

我从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)

请让我知道如果需要更多的信息。

crcmnpdw

crcmnpdw1#

我解决了我的问题,写了一个自定义的会话构建器,并从工厂示例中禁用了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);
    }

}

创建服务文件:

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

将文件编辑为文本文件并添加内容:

br.com.temasistemas.utils.hibernate.CustomSessionFactoryBuilderFactory

相关问题