4

I am trying to configure my project to run JPA2.1 with Hibernate Validator 5.1.2 on Weblogic 12.1.3, but I'm running into issues when I try to deploy my project.

I configured weblogic to use JPA2.1 using the manual method as described on the tthis Documentation Page for Weblogic 12.1.3: http://docs.oracle.com/middleware/1213/wls/EJBAD/using_toplink.htm#EJBAD1508

I want to use hibernate-validator 5.1.2 in my project, which I configured this as such:

Maven dependency:

<dependency>
 <groupId>org.hibernate</groupId>
 <artifactId>hibernate-validator</artifactId>
 <version>5.1.2.Final</version>
</dependency>

weblogic.xml

<container-descriptor>
    <prefer-application-packages>
        <!-- hibernate validator 5.1.2 over HV 4.1 -->
        <package-name>javax.validation.*</package-name>
        <package-name>org.hibernate.validator.*</package-name>
        <!-- guava 13 -->
        <package-name>com.google.common.collect.*</package-name>
    </prefer-application-packages>
    <prefer-application-resources>
        <!-- hibernate validator 5.1.2 over HV 4.1 -->
        <resource-name>META-INF/validation-mapping-1.1.xsd</resource-name>
        <resource-name>META-INF/validation-configuration-1.1.xsd</resource-name>
    </prefer-application-resources>
</container-descriptor>

On deployment i get the following exception:

<Aug 1, 2014 10:46:16 AM CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "8725280002070" for task "0". Error is: "weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.hibernate.validator.HibernateValidator"
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.hibernate.validator.HibernateValidator
    at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
    at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
    at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
    at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
    Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: org.hibernate.validator.HibernateValidator
    at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:357)
    at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:318)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:186)
    Truncated. see log file for complete stacktrace
> 

I did not get this exception when I had my project configured on Weblogic 12.1.2 with JPA2.0 and Hibernate Validator 4.3.1.

Does anyone have suggestions on how to fix this?

Waterstraal
  • 399
  • 4
  • 16
  • Are you sure in WEB-INF/lib you have all necessary JARs like `hibernate-validator-5.1.2.Final.jar` etc.. Can you show what lib folder contains at least JARs with hibernate-*.jar – Amogh Aug 01 '14 at 09:07
  • I just checked: WEB-INF/lib contains the hibernate-validator-5.1.2.Final.jar and also validation-api-1.1.0.Final.jar – Waterstraal Aug 01 '14 at 09:19
  • Okay looks like weblogic unable to find `org.hibernate.validator.HibernateValidator` class in class path. Can you try adding `true` in weblogic.xml. – Amogh Aug 01 '14 at 09:23
  • I now get a very different error... which I can't really explain: `SEVERE: Could not load or parse web.xml java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory cannot be cast to javax.xml.parsers.DocumentBuilderFactory at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source) at org.primefaces.config.ConfigContainer.initConfigFromWebXml(ConfigContainer.java:253)` – Waterstraal Aug 01 '14 at 09:25
  • Can you show updated weblogic.xml. – Amogh Aug 01 '14 at 09:27
  • Sure, it's just this: ` true ` I could not leave prefer-application-packages, because that conflicts with prefec-web-inf-classes – Waterstraal Aug 01 '14 at 09:28
  • Are you setting value for `prefer-web-inf-classes` in console also because value specified in the console will take precedence over a value set manually – Amogh Aug 01 '14 at 09:35
  • No i have not set this value in the console. – Waterstraal Aug 04 '14 at 06:57

2 Answers2

2

Oracle released "Interim Patch for Bug: 20087183" last week that fixes this issue.

Waterstraal
  • 399
  • 4
  • 16
1

Since you activated JPA 2.1, it means that classes of JPA are loaded at the highest classloader. Hibernate Validator is "used" by JPA classes, thus requiring Hibernate classes to be available at the same, or higher classloader than JPA classes.

Try to load the Hibernate JARs along with the JPA 2.1 JARs on your startup script. I am not sure if this will work but this is definitely a classloader ordering problem.

If you are not sure in which classloader to load the Hibernate classes, use WebLogic CAT (Classloader Analysis Tool) to see where it should go.

Hope it helps.

Bruno Borges
  • 853
  • 7
  • 24