无法使 CDI 在 Weblogic 12c、休眠 5.2.4、hibernate-validator/cdi 5.3.1 中工作

Unable to get CDI working in Weblogic 12c, hibernate 5.2.4, hibernate-validator/cdi 5.3.1

我的环境: 网络逻辑 12c

和设置的jpa2.1补丁:SET PRE_CLASSPATH=%MW_HOME%\oracle_common\modules\javax.persistence_2.1.jar;%MW_HOME%\wlserver\modules\com.oracle.weblogic.jpa21support_1.0.0.0_2-1.jar

my-ear/APP-INF/lib 包含:

hibernate-release-5.2.4.Final/lib/required/*.jar 
hibernate-validator-5.3.1/dist/*.jar and hibernate-validator-5.3.1/dist/lib/required/*

我的persistence.xml:

<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
  http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  version="2.1">
<persistence-unit name="myPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>myDataSource</jta-data-source>

我可以使用 persistence.xml 并且 entityManager 可以毫无问题地注入到我的会话 bean 中。 但是当我添加 beans.xml(使用 CDI ) 在其中一个 ejb-jar/META-INF 我得到:

org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435 Normal scoped bean class org.hibernate.validator.internal.engine.ValidatorImpl is not proxyable because it has no no-args constructor - ValidatorBean [id=org.hibernate.validator.internal.cdi.ValidatorBean_default]. 

我的 weblogic-application.xml 包含:

<prefer-application-packages>       
 <package-name>antlr.*</package-name>
 <package-name>org.hibernate.*</package-name>
 <package-name>org.hibernate.validator.*</package-name>
 <package-name>org.hibernate.validator.internal.cdi.*</package-name>        
 <package-name>javax.validation.*</package-name>
 <package-name>javax.validation.spi.*</package-name>
<package-name>javax.validation.bootstrap.*</package-name>

完整的堆栈跟踪:

Exception 0 :
org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001435 Normal scoped bean class org.hibernate.validator.internal.engine.ValidatorImpl is not proxyable because it has no no-args constructor - ValidatorBean [id=org.hibernate.validator.internal.cdi.ValidatorBean_default].
    at org.jboss.weld.util.Proxies.getUnproxyableClassException(Proxies.java:214)
    at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:180)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesExceptionInt(Proxies.java:195)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesException(Proxies.java:169)
    at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:151)
    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:388)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:110)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:76)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:49)
    at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)
    at weblogic.application.internal.BaseDeployment.next(BaseDeployment.java:729)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access0(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.run(DeploymentReceiverCallbackDeliverer.java:68)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

    at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:398)
    at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:371)
    at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
    at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:110)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:76)
    at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:49)
    at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)
    at weblogic.application.internal.BaseDeployment.next(BaseDeployment.java:729)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
    at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access0(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.run(DeploymentReceiverCallbackDeliverer.java:68)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)

我错过了什么?我如何让 beans.xml/CDI 在此环境中工作?

我安装了Weblogic patches 17754607 and 23744018 (Weblogic Server 12.1.3.0.161018)

并删除: hibernate-validator-5.3.1/dist/*.jar 来自 my-ear/APP-INF/lib

Oracle 提供的验证 jar 工作正常 - 我现在可以使用 CDI。