Hibernate's Antlr generated in Weblogic reason Jar history of the conflict, as well as the solution

Hibernate is used in grammar parser antlr, WebLogic equally.
Many users encounter ClassNotFoundException: org.hibernate.hql.ast.HqlToken of the typical problems, this classic problem has been configured to weblogic.xml, give priority to load the requested Web application WEB-INF of the Jar (ie application Classloader) instead of WebLogic's System Classloader to be barely resolved:
<prefer-web-inf-classes> true </ prefer-web-inf-classes>
</ container-descriptor>
</ weblogic-web-app>

Hibernate 3.0 user found out that the method is still not solve the problem because Hibernate uses Class.forName to Load a class, while the JVM loads the class approach is the first System Classloader (WebLogic), after the Application Classloader (Web applications), result, Applications Even with the prefer-web-inf-classes strategy, but Class.forName or Load the WebLogic's Antlr! !

Hibernate 3.1 solves this problem quickly, Hibernate will use the context classloader, Class.forName this evil code has been eliminated.

Coincidentally, in 2005 Australia's Suncorp-Metway companies use Hibernate3.0.3 + WebLogic8.1SP4 develop their application, then WebLogic 8.1SP4 built-antlr 2.7.1, with Hibernate 3.0.3 bundled antlr-2.7.5H3. jar of conflict, Suncorp-Metway's wish to change the WebLogic's SystemClassPath (adding antlr-2.7.5H3.jar), effect is equivalent to replacing WebLogic's Antlr, of course, Hibernate can solve the problem, but God knows what would be problem because the WebLogic's own Antlr will be used to analyze EJBQL (if not applicable CMP, the user can regardless of 3721, replacement of WebLogic's Antlr version of the), Suncorp-Metway's worried that the replacement of other effects on the system brings the hope that BEA continues to provide technical support.
At that time, as the BEA in Queensland, Australia's largest BEA customers, they would certainly be enough respect. To this end, BEA 8.1 SP4/SP5 have provided a patch, equivalent to upgrade the WebLogic 8.1 comes with Antlr version, WebLogic 8.1SP6 and WebLogic 9.1 start has been following this change.

Obviously, this approach can not be re-used until after the SP, because Antlr as well as an updated version of Hibernate much faster than the speed of WebLogic Service pack update, BEA can not be reconstructed Antlr constantly to adapt to the ever-changing open-source API change.

WebLogic 8.1 SP6 later, when using Hibernate 3 (strategy <prefer-web-inf-classes> true </ prefer-web-inf-classes>) of the Antlr 2.7.6 when it is the turn WebLogic own Servlet container problems ( Hibernate Well, WebLogic something has happened) throws Exception Antlr following:
java.lang.ClassCastException: antlr.CommonToken
at antlr.CharScanner.makeToken (CharScanner.java: 175)
at weblogic.servlet.jsp.JspLexer.mWORD (JspLexer.java: 4723)
at weblogic.servlet.jsp.JspLexer.mXML_ATTRIBUTES (JspLexer.java: 4309)
at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE_BODY (JspLexer.java: 5034)
at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE (JspLexer.java: 4905)
at weblogic.servlet.jsp.JspLexer.mDIRECTIVE (JspLexer.java: 4751)
at weblogic.servlet.jsp.JspLexer.mSTANDARD_THING (JspLexer.java: 2161)
at weblogic.servlet.jsp.JspLexer.mTOKEN (JspLexer.java: 1947)
at weblogic.servlet.jsp.JspLexer.nextToken (JspLexer.java: 1820)
at weblogic.servlet.jsp.JspLexer.nextToken (JspLexer.java: 1820)
at weblogic.servlet.jsp.JspLexer.parse (JspLexer.java: 963)
at weblogic.servlet.jsp.JspParser.doit (JspParser.java: 106)
at weblogic.servlet.jsp.JspParser.parse (JspParser.java: 234)
at weblogic.servlet.jsp.Jsp2Java.outputs (Jsp2Java.java: 125)

The problem is that WebLogic Servlet container do not realize that the version of Hibernate users of ANTLR needs:
1) In the old Antlr 2.7.1 in, WebLogic's Servlet container to use antlr.CharScanner through the following methods Class.forName (String className) Load token, because the jsp compiled classes in itself is based on the WebLogic System Classloader, therefore, Classloader, of course the use of WebLogic's Antlr version (2.7.1), WebLogic is not Hibernate's Antlr (2.7.6) be affected by, Class.forName transition into the System CL by the statute antlr.CommonToken not be a problem.
2) When WebLogic Antlr 2.7.1 + Hibernate Antlr2.7.6 when used together, Servlet containers CharScanner using Class.forName (String, boolean, ClassLoader) to load the token, while the third parameter is the injection of the current application of The Classloader, that WebLogic forced to use the Hibernate's Antlr 2.7.6, which will eventually lead to the container that will Antlr 2.7.6 of the CommonToken transformation into a Antlr 2.7.1 of CommonToken appear java.lang.ClassCastException.

This situation can only do two things:
1) to obtain a copy of this Case patch BEA
2) pre-System ClassPath, so that the new version of Antlr always placed in front of.

About so many things, in fact, wish to reveal the ultimate question is, whether it is Hibernate, and WebLogic, at the beginning when they are not aware of the importance of open-source code refactoring. WebLogic has indeed been the early version of the XML Parser to pay the costs of conflict, so late a lot of XML packets are WebLogic re Rename Package (refactoring code in a way). If you start, WebLogic on the use of com.bea.opensource.antlr to let their own containers to use Antlr, ANTLR conflict, these issues certainly does not appear.

WebLogic 10 really have begun a large-scale reconstruction of Jar package, unfortunately, in this world, there is a hidden rule known as backward compatibility, therefore, <prefer-web-inf-classes> true </ prefer-web-inf-classes> yes J2EE initial stage we still need to accept the reality, of course, you can look forward to another technology to solve this problem - OSGI, in fact, this version may be faster than we thought, or on WebLogic 12g.

分类:Java 时间:2008-06-04 人气:603
blog comments powered by Disqus


iOS 开发

Android 开发

Python 开发



PHP 开发

Ruby 开发






Javascript 开发

.NET 开发



Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.035 (s). 13 q(s)