Resolving conflicts with Classloaders - Example with Hibernate/Antlr

After migrating Hibernate applications to a more recent version of WebLogic Server from WLS 9.2.x, you might encounter query exceptions such as:

EXCEPTION STACK TRACE: org.hibernate.QueryException: aggregate function expected before ( in SELECT [select distinct c, (select count(*) from ...

The same query working properly under the old environment.  At first it might look like an invalid syntax in the query but the issue is really coming from a conflict between parsers clients.  The solution is to use prefer-application-packages in weblogic-application.xml (WebLogic Server-specific deployment descriptor extension for the application.xml) to define which package(s) should be loaded from the application and not from the system classloader, example:

<prefer-application-packages>

  <package-name>antlr.*</package-name>

</prefer-application-packages>

The suitable Antlr (Java-based compiler generator client) version should be made available in the application itself, inside WEB-INF/lib - this parser being used by Hibernate.  prefer-web-inf-classes must be set to true in weblogic.xml, the default value being false, for classes located in WEB-INF to be loaded in preference to the system classloader.  

WLS 10.3.x is shipped with antlr version 2.7.7 (built on Mon Jun 11 12:19:48 EDT 2007  ImplVersion: 2.7.7)

WLS 12c is shipped with antlr version 2.7.7.0 (built on Fri Nov 4 19:42:39 EDT 2011  ImplVersion: 2.7.7.0)

You can find all packages versions in %Home%/modules or simply by running java weblogic.utils.Versions

For aid in configuring filtering classloaders, see Using the Classloader Analysis Tool (CAT).

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The official blog for Oracle WebLogic Server fans and followers!

Stay Connected

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
5
6
7
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today