1
votes

after many search on the web I have not yet found a solution. I use JPA 2 on WebLogic 10.3.6. Everything works well on tomcat:

@RequestMapping(value="/createUser", method = RequestMethod.POST)
public String create(@Valid Utente utente, BindingResult result)


but when I deploy to WebLogic I get this Exception:

java.lang.AbstractMethodError: org.apache.openjpa.persistence.PersistenceProviderImpl.getProviderUtil()Ljavax/persistence/spi/ProviderUtil;
at javax.persistence.Persistence$PersistenceUtilImpl.isLoaded(Unknown Source) ~[javax.persistence_1.1.0.0_2-0.jar:2.0.3]
at org.hibernate.validator.internal.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:56) ~[hibernate-validator-5.0.2.Final.jar:5.0.2.Final]


This is pom.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.0.0.RELEASE</version>
</dependency>
...
<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.0.2.Final</version>
</dependency>

Thanks in advance

2
I think you messed up the imports in. check what @Valid isZeus
@Valid helps me to validate forms by putting annotation on modelsMarco Di Scala

2 Answers

2
votes

Resolved by putting in validation.xml:

<?xml version="1.0" encoding="UTF-8"?>
<validation-config
    xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.1.xsd"
    version="1.1">

    <traversable-resolver>CustomTraversableResolver</traversable-resolver>

</validation-config>

and implementing:

public class CustomTraversableResolver implements TraversableResolver {

    @Override
    public boolean isReachable(Object traversableObject, Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
        return true;
    }

    @Override
    public boolean isCascadable(Object traversableObject, Node traversableProperty, Class<?> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
        return true;
    }
}
0
votes

Like said here, @MDS response is a workaround because you should be aware that this potentially causes lots of entities to be loaded from the database upon validation of a bean which has non-loaded lazy references to other entities.

I suggest to edit weblogic-application.xml to overload the correct jar:

<wls:prefer-application-packages>
    <wls:package-name>javax.persistence.*</wls:package-name>
    <wls:package-name>org.eclipse.persistence.*</wls:package-name>
</wls:prefer-application-packages>