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:
<weblogic-web-app>
<container-descriptor>
<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.
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

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

  • Hibernate configuration parameters hibernate.hbm2ddl.auto

    Hibernate in the configuration file: <properties> <property name="hibernate.hbm2ddl.auto" value="create" /> </ properties> Parameter Description: validate load hibernate, the authentication to create a database t ...

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.132:15

  • hibernate generic generic DAO

    package org.lzpeng.dao; import java.io.Serializable; import java.util.List; import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.criterion.Criterion; import org.springside.modules.orm.hibernate.Page; /** * * @version 2009-1-10 *

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries