weblogic 整合hibernate valildation 2个问题的解决

1.java.lang.AbstractMethodError:

引用

使用hibernatevalidator,在tomcat下部署没有问题,发布到weblogic(10)下面就报错了。在使用验证时有以下错误:

java.lang.AbstractMethodError:getProviderUtil

atjavax.persistence.Persistence$PersistenceUtilImpl.isLoaded(UnknownSource)

出错原因是weblogic自身带有openjpa的包(hibernate、openjpa掐架?),解决方法是在spring中增加配置

dispatcher-servlet.xml

<mvc:annotation-drivenvalidator="validator"/>

applicationContext.xml

<beanname="validator"class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">

<propertyname="traversableResolver">

<beanclass="com.....ExtTraversableResolver"></bean>

</property>

</bean>

其中ExtTraversableResolver代码如下:

importjava.lang.annotation.ElementType;

importjavax.validation.Path;

importjavax.validation.TraversableResolver;

publicclassExtTraversableResolverimplementsTraversableResolver{

publicfinalbooleanisReachable(ObjecttraversableObject,Path.NodetraversableProperty,Class<?>rootBeanType,PathpathToTraversableObject,ElementTypeelementType){

returntrue;

}

publicfinalbooleanisCascadable(ObjecttraversableObject,Path.NodetraversableProperty,Class<?>rootBeanType,PathpathToTraversableObject,ElementTypeelementType){

returntrue;

}

}

2.ava.lang.NoSuchMethodError:javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;

引用
C:\Program Files\Java\jdk1.6.0_30\jre\lib\ext\hibernate-jpa-2.0-api-1.0.0.Final.jar

相关推荐