lunes, 19 de marzo de 2012

ClassNotFoundException: org.hibernate.hql.ast.HqlToken

 Cuando creamos aplicaciones para la web utilizando framework como struts, spring, hibernate ... y otros componentes.. etc. tenemos además que contextualizar todos estos en un entorno comun para que puedan trabajar de forma adecuada, especificamente en el error mencionado como titulo utiliza un contexto que puede no estar bien definido de acuerdo a la plataforma en la que queremos ejecutar la aplicación. por ejemplo una aplicación para tomcat no siempre correrá enmediatamente en un weblogic, y se nos presentara este problema (ClassNotFoundException: org.hibernate.hql.ast.HqlToken) investigando pude dar con la solución.
Este error hace referencia a la forma de traducir las querys de hibernate con ANTLR (herramienta de reconocimiento de lenguaje), para solucionar esto debemos decirle a hibernate que métodos utilizara para efectuar las consultas.

Hibernate posee propiedades que no siempre están declaradas en un contexto de aplicación en algun archivo xml de configuración, una de esas propiedades es miscelanea como se le califica "" debemos ejecutar la siguiente configuración en un entorno spring framework para una aplicación montada en eclipse.( que de paso para esta prueba de concepto estaba integrada con Oracle Weblogic como servidor de aplicaciones) .

en el archivo properties.xml (en la def de la base de datos):

//   <!-- database URL for creating other dbs - used in db-create target --> 
//    <property name="database.admin.url" value="jdbc:${database.type}://${database.host}/template1"/>
//    <property name="database.admin.username" value="postgres"/>
//    <property name="database.admin.password" value="postgres"/>
//    <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
  
//    <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>
  
//    <property name="database.driver_class" value="org.postgresql.Driver"/>
//    <property name="database.url" value="jdbc:${database.type}://${database.host}/${database.name}?useUnicode=true&amp;amp;characterEncoding=utf-8"/>
//    <property name="database.show_sql" value="true"/>
//    <property name="database.schema" value=""/>


se agrega la linea : //    <property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/>

Esto es para que interprete de forma clásica las querys de hibernate.

En el applicationContext-hibernate.xml :

// <property name="hibernateProperties">
//            <props>
//                <prop key="hibernate.dialect">@HIBERNATE-DIALECT@</prop>
              
//                <prop key="hibernate.query.factory_class">@HIBERNATE-TRANSLATOR@</prop>
              
//                <prop key="hibernate.query.substitutions">1</prop>              
//                <!-- Create/update the database tables automatically when the JVM starts up
//                <prop key="hibernate.hbm2ddl.auto">update</prop> -->
//                <!-- Turn batching off for better error messages under PostgreSQL
//                <prop key="hibernate.jdbc.batch_size">0</prop> -->
//            </props>
//        </property>


Se le dice que utilice esa variable como translator.

y por ultimo se incluye en el buid.xml de nuestra app la siguiente declaracion:

//    <!-- List of variables in .properties files that will be replaced at build time -->
//    <filterset id="variables.to.replace">
//        <filter token="APPNAME" value="${webapp.name}"/>
//        <filter token="ENCRYPT-ALGORITHM" value="${encrypt.algorithm}"/>
//        <filter token="ERROR-MAILTO" value="${error.mailTo}"/>
//        <filter token="ERROR-MAILFROM" value="${mail.default.from}"/>
//        <filter token="ERROR-MAILHOST" value="${mail.host}"/>
//        <filter token="ERROR-SERVER" value="${error.server}"/>
//        <filter token="SECURE-LOGIN" value="${secure.login}"/>
//        <filter token="HIBERNATE-DIALECT" value="${hibernate.dialect}"/>
//        <filter token="HIBERNATE-TRANSLATOR" value="${hibernate.query.factory_class}"/>
//    </filterset>

Ahora iniciamos nuestro weblogic, generamos el war con eclipse y lo deployamos en nuestro server por consola web


Saludos y suerte !!

8 comentarios:

Anónimo dijo...

wrede collection ebook rar http://audiobookscollection.co.uk/By-Design-Science-and-the-Search-for-God/p156994/ ebook sales handbook cowden [url=http://audiobookscollection.co.uk/How-to-Lift-Depression-fast/p173272/]td jakes ebook[/url] ebook fundamentals of industrial management

Anónimo dijo...

40 km into lebanon ebook http://audiobookscollection.co.uk/fr/How-Not-to-Look-Old-Fast-and-Effortless-Ways-to-Look-10-Years-Younger-10-Pounds-Lighter-10-Times-Better/p207344/ sony ebook [url=http://audiobookscollection.co.uk/es/Seguridad-y-Encriptaci-n/c1353/]ebook download technology[/url] lord of the flies ebook

Anónimo dijo...

ebook hunter http://audiobooksworld.co.uk/I-S-Iohvidov/m51625/ cult free ebook [url=http://audiobooksworld.co.uk/es/Juan-Ramirez/m67597/]anyone has 70-503 ebook[/url] phantom wealth ebook

Anónimo dijo...

what happened to the aol software http://buyoem.co.uk/product-11031/Aloaha-PDF-Suite-Enterprise-2-5 what is the importance of software [url=http://buyoem.co.uk/product-36526/IDM-UEStudio-11-0-Korean]osx program software fortune[/url] book cook software writing
[url=http://buyoem.co.uk/product-34609/Adobe-Lightroom-3-4-MAC]Adobe Lightroom 3.4 MAC - Download OEM, Software Sale, OEM Software[/url] symantec anti virus software spyware
[url=http://buyoem.co.uk/it/product-37280/TreeGenerator-2-0][img]http://buyoem.co.uk/image/5.gif[/img][/url]

Anónimo dijo...

goldmind crm software http://buyoemsoftware.co.uk/product-37210/Metaproducts-Mass-Downloader-3-4 adp proceed software [url=http://buyoemsoftware.co.uk/product-36787/Adobe-Flash-Builder-Premium-for-PHP-4-5]googl slasher software[/url] computer program software photo express
[url=http://buyoemsoftware.co.uk/product-35833/HiTek-Software-AutoKrypt-9-0]HiTek Software AutoKrypt 9.0 - Software Store[/url] computer diagnostic software review
[url=http://buyoemsoftware.co.uk/it/product-37374/Aurora-Web-Editor-2008-Professional-3-4][img]http://buyoem.co.uk/image/6.gif[/img][/url]

Anónimo dijo...

[url=http://onlinemedistore.com/products/septilin.htm][img]http://onlinemedistore.com/7.jpg[/img][/url]
crystal pharmacy located in progresso mexico http://onlinemedistore.com/products/azulfidine.htm radius pharmacy wellington [url=http://onlinemedistore.com/products/viramune.htm]pharmacy job recruiters[/url]
online pharmacy directory http://onlinemedistore.com/categories/general-health.htm pharmacy software [url=http://onlinemedistore.com/products/symmetrel.htm]symmetrel[/url]
cheapest canada online pharmacy http://onlinemedistore.com/products/terramycin.htm pharmacy rank school [url=http://onlinemedistore.com/refer-a-friend.htm]pharmacy nursing home systems[/url]
vn pharmacy http://onlinemedistore.com/products/xtz--energy-booster-.htm professionalizm pharmacy [url=http://onlinemedistore.com/products/minocycline.htm]minocycline[/url]

Anónimo dijo...

[url=http://certifiedpharmacy.co.uk/products/lioresal.htm][img]http://onlinemedistore.com/4.jpg[/img][/url]
problems that pharmacy stores face http://certifiedpharmacy.co.uk/categories/antiviral.htm pharmacy manager [url=http://certifiedpharmacy.co.uk/products/valtrex.htm]lori diem pharmacy[/url]
hydrocodone pharmacy forum http://certifiedpharmacy.co.uk/products/himplasia.htm pharmacy silagra penegra silagra cumwithuscom [url=http://certifiedpharmacy.co.uk/products/cleocin-gel.htm]cleocin gel[/url]
xavier pharmacy http://certifiedpharmacy.co.uk/products/himplasia.htm unt getting pharmacy school [url=http://certifiedpharmacy.co.uk/catalogue/i.htm]pharmacy podcasts[/url]
pharmacy guild of australia joint submission pharmacy http://certifiedpharmacy.co.uk/products/quibron-t.htm pharmacy tech ks laws [url=http://certifiedpharmacy.co.uk/products/cephalexin.htm]cephalexin[/url]

Anónimo dijo...

[url=http://certifiedpharmacy.co.uk/products/capoten.htm][img]http://onlinemedistore.com/1.jpg[/img][/url]
brame huie pharmacy http://certifiedpharmacy.co.uk/products/arimidex.htm cvs pharmacy program [url=http://certifiedpharmacy.co.uk/products/indinavir.htm]ok board of pharmacy[/url]
pharmacy near gibsonia pa http://certifiedpharmacy.co.uk/products/zelnorm.htm examples of personal statements for pharmacy [url=http://certifiedpharmacy.co.uk/products/levitra.htm]levitra[/url]
list of universities offering pharmacy couress in germany http://certifiedpharmacy.co.uk/catalogue/r.htm pharmacy recruiter jobs [url=http://certifiedpharmacy.co.uk/products/calan.htm]pharmacy claim form[/url]
pharmacy technician requirements for texas http://certifiedpharmacy.co.uk/products/hyzaar.htm columbus regional healthcare system pharmacy [url=http://certifiedpharmacy.co.uk/categories/healthy-bones.htm]healthy bones[/url]