Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Resolving conflicts with Classloaders - Example with Hibernate/Antlr

$
0
0
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).


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>