|
#1
|
|||
|
|||
|
i am having a problem with getting a result of getHibernateTemplate.find().
i don't get any problems with loadAll method but when i use find method i do get problems. Code:
2006-05-08 08:54:33,765 DEBUG [org.springframework.web.servlet.DispatcherServlet] - Could not complete request org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from regulation.regulation.Regulation]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from regulation.regulation.Regulation] Caused by: org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from regulation.regulation.Regulation] at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57) at antlr.CharScanner.setTokenObjectClass(CharScanner.java:340) at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31) at antlr.CharScanner.<init>(CharScanner.java:51) at antlr.CharScanner.<init>(CharScanner.java:60) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:56) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:53) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:50) at org.hibernate.hql.ast.HqlLexer.<init>(HqlLexer.java:26) at org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44) at org.hibernate.hql.ast.QueryTranslatorImpl.parse Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<value>/WEB-INF/Regulation.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.proxool.xml">/WEB-INF/proxool.xml</prop>
<prop key="hibernate.proxool.pool_alias">spring</prop>
</props>
</property>
</bean>
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="mySessionFactory"/>
</property>
</bean>
<bean id="regulationTarget" class="regulation.regulation.RegulationDaoImpl">
<property name="sessionFactory">
<ref bean="mySessionFactory"/>
</property>
</bean>
<bean id="regulationService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="myTransactionManager"/>
</property>
<property name="target">
<ref local="regulationTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly,-org.springframework.dao.DataAccessException</prop>
<prop key="save*">PROPAGATION_REQUIRED,-org.springframework.dao.DataAccessException</prop>
<prop key="delete*">PROPAGATION_REQUIRED,-org.springframework.dao.DataAccessException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-org.springframework.dao.DataAccessException</prop>
</props>
</property>
</bean>
</beans>
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!--bean id="messageSource"
class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean-->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/viewRegulation1.html">regulationController</prop>
<prop key="/viewRegulation2.html">regulationController</prop>
</props>
</property>
</bean>
<bean id="regulationController"
class="regulation.controller.RegulationController">
<property name="methodNameResolver" ref="regulationControllerResolver"/>
<property name="regulation" ref="regulationService"/>
</bean>
<bean id="regulationControllerResolver"
class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
<property name="mappings">
<props>
<prop key="/viewRegulation1.html">viewRegulation1Handler</prop>
<prop key="/viewRegulation2.html">viewRegulation2Handler</prop>
</props>
</property>
</bean>
</beans>
Last edited by kprulz; May 7th, 2006 at 09:39 PM. |
|
#2
|
||||
|
||||
|
What are your mapping file? loadAll uses the classname to execute the query - if given a class that is not mapped properly it will thrown the exception. With find you are using hand made queries which usually yield slightlty different sql.
__________________
Costin Leau SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source" http://twitter.com/costinl Please use [ c o d e ] [ / c o d e ] tags |
|
#3
|
|||
|
|||
|
Quote:
getHibernateTemplate().find("from Regulation); causes an error |
|
#4
|
||||
|
||||
|
Quote:
Quote:
__________________
Costin Leau SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source" http://twitter.com/costinl Please use [ c o d e ] [ / c o d e ] tags |
|
#5
|
|||
|
|||
|
Quote:
Code:
<hibernate-mapping>
<class name="regulation.regulation.Regulation" table="regulations_tbl">
<id name="id" type="integer">
<column name="id" not-null="true"/>
<generator class="increment"/>
</id>
<property name="no" type="integer"/>
<property name="rdate" type="date"/>
<property name="title" type="string"/>
<property name="dptname" type="string"/>
<property name="volumes" type="string"/>
<property name="edate" type="date"/>
<property name="reorganize" type="string"/>
<property name="supplement" type="string"/>
<property name="note" type="string"/>
<property name="filename" type="string"/>
<property name="type" column="class" type="string"/>
</class>
</hibernate-mapping>
Last edited by kprulz; May 8th, 2006 at 05:23 PM. |
|
#6
|
|||
|
|||
|
The ClassNotFoundException is a little bit bizarre here!!! What Hibernate version are you using? did you build Hibernate yourself or download it? Can you check if this class is accessible to antlr?
|
|
#7
|
|||
|
|||
|
Quote:
how do i check if it's accessible to antlr? Last edited by kprulz; May 8th, 2006 at 11:52 PM. |
|
#8
|
||||
|
||||
|
put the antlr jar in the same folder with hibernate 3.1 - this way it will be in the same classloader with HB.
__________________
Costin Leau SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source" http://twitter.com/costinl Please use [ c o d e ] [ / c o d e ] tags |
|
#9
|
|||
|
|||
|
You need to be sure your webapp server uses the classes in WEB-INF over what is in it's classpath. It could be using a different version of antlr
|
|
#10
|
|||
|
|||
|
I am getting same error as below...I am not sure what I am supposed to do
I am using Jdeveloper,Hibernate 3.0,Spring. I have antlr.jar along with hibernate3.jar ...Any suggestions would be a great help....Thanks Error is while using find() method on getHibernateTemplate().find("from Application a where a.name = ? ", name).get(0); rg.springframework.orm.hibernate3.HibernateQueryEx ception: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from gov.nci.nih.ctep.caepr.businessobjects.Application a where a.name = ? ]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from gov.nci.nih.ctep.caepr.businessobjects.Application a where a.name = ? ] org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from gov.nci.nih.ctep.caepr.businessobjects.Application a where a.name = ? ] at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java :57) at antlr.CharScanner.setTokenObjectClass(CharScanner. java:239) at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass (HqlLexer.java:31) at antlr.CharScanner.<init>(CharScanner.java:40) at antlr.CharScanner.<init>(CharScanner.java:49) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBas eLexer.java:56) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBas eLexer.java:53) at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBas eLexer.java:50) at org.hibernate.hql.ast.HqlLexer.<init>(HqlLexer.jav a:26) at org.hibernate.hql.ast.HqlParser.getInstance(HqlPar ser.java:44) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(Qu eryTranslatorImpl.java:242) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompil e(QueryTranslatorImpl.java:157) at org.hibernate.hql.ast.QueryTranslatorImpl.compile( QueryTranslatorImpl.java:112) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQL QueryPlan.java:77) at org.hibernate.engine.query.HQLQueryPlan.<init>(HQL QueryPlan.java:56) at org.hibernate.engine.query.QueryPlanCache.getHQLQu eryPlan(QueryPlanCache.java:72) at org.hibernate.impl.AbstractSessionImpl.getHQLQuery Plan(AbstractSessionImpl.java:133) at org.hibernate.impl.AbstractSessionImpl.createQuery (AbstractSessionImpl.java:111) at org.hibernate.impl.SessionImpl.createQuery(Session Impl.java:1621) at org.springframework.orm.hibernate3.HibernateTempla te$29.doInHibernate(HibernateTemplate.java:742) at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:311) at org.springframework.orm.hibernate3.HibernateTempla te.find(HibernateTemplate.java:740) at org.springframework.orm.hibernate3.HibernateTempla te.find(HibernateTemplate.java:736) at gov.nci.nih.ctep.caepr.serviceImpl.CaeprServiceImp l.getApplication(CaeprServiceImpl.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java) at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:287) at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:155) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :122) at org.springframework.aop.framework.adapter.MethodBe foreAdviceInterceptor.invoke(MethodBeforeAdviceInt erceptor.java:52) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144) at org.springframework.aop.framework.adapter.AfterRet urningAdviceInterceptor.invoke(AfterReturningAdvic eInterceptor.java:51) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144) at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174) at $Proxy3.getApplication(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java) at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java) at org.springframework.aop.support.AopUtils.invokeJoi npointUsingReflection(AopUtils.java:287) at org.springframework.aop.framework.ReflectiveMethod Invocation.invokeJoinpoint(ReflectiveMethodInvocat ion.java:155) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :122) at org.springframework.transaction.interceptor.Transa ctionInterceptor.invoke(TransactionInterceptor.jav a:57) at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :144) at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:174) at $Proxy4.getApplication(Unknown Source) at gov.nci.nih.ctep.caepr.plugin.ConstantsPlugin.init (ConstantsPlugin.java:48) at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:1158) at org.apache.struts.action.ActionServlet.init(Action Servlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.j ava:259) at com.evermind.server.http.HttpApplication.loadServl et(HttpApplication.java:2365) at com.evermind.server.http.HttpApplication.findServl et(HttpApplication.java:4807) at com.evermind.server.http.HttpApplication.initPrelo adServlets(HttpApplication.java:4901) at com.evermind.server.http.HttpApplication.initDynam ic(HttpApplication.java:1026) at com.evermind.server.http.HttpApplication.<init>(Ht tpApplication.java:560) at com.evermind.server.Application.getHttpApplication (Application.java:915) at com.evermind.server.http.HttpServer.getHttpApplica tion(HttpServer.java:707) at com.evermind.server.http.HttpSite.getApplication(H ttpSite.java:438) at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:455) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:285) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:126) at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:186) at java.lang.Thread.run(Thread.java:534) 08/06/10 20:35:20 CAEPRS_1-Caeprs-webapp: Error preloading servlet javax.servlet.UnavailableException at org.apache.struts.action.ActionServlet.initModuleP lugIns(ActionServlet.java:1169) at org.apache.struts.action.ActionServlet.init(Action Servlet.java:473) at javax.servlet.GenericServlet.init(GenericServlet.j ava:259) at com.evermind.server.http.HttpApplication.loadServl et(HttpApplication.java:2365) at com.evermind.server.http.HttpApplication.findServl et(HttpApplication.java:4807) at com.evermind.server.http.HttpApplication.initPrelo adServlets(HttpApplication.java:4901) at com.evermind.server.http.HttpApplication.initDynam ic(HttpApplication.java:1026) at com.evermind.server.http.HttpApplication.<init>(Ht tpApplication.java:560) at com.evermind.server.Application.getHttpApplication (Application.java:915) at com.evermind.server.http.HttpServer.getHttpApplica tion(HttpServer.java:707) at com.evermind.server.http.HttpSite.getApplication(H ttpSite.java:438) at com.evermind.server.http.HttpRequestHandler.proces sRequest(HttpRequestHandler.java:455) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:285) at com.evermind.server.http.HttpRequestHandler.run(Ht tpRequestHandler.java:126) at com.evermind.util.ReleasableResourcePooledExecutor $MyWorker.run(ReleasableResourcePooledExecutor.jav a:186) at java.lang.Thread.run(Thread.java:534) -Thanks, Kelly |
![]() |
| Thread Tools | |
| Display Modes | |
|
|