Announcement Announcement Module
Collapse
No announcement yet.
Get a java.lang.NoSuchMethodError when tried to use HibernateTemplate.find() method Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get a java.lang.NoSuchMethodError when tried to use HibernateTemplate.find() method

    hi, all, I am new here, i am writing a method in which I use HibernateTemplate.find(sqlString) to access data from database, but I got an exception :
    import org.springframework.orm.hibernate3.HibernateTempla te;
    import org.springframework.orm.hibernate3.support.Hiberna teDaoSupport;
    ................

    List List = new java.util.ArrayList();
    String sql = "FROM Price p "
    try{
    list = this.getTemplate().find(sql);
    }
    catch ...................

    and the exception I got is shown below, could any friends tell me what causes this exception ? thanks !:
    ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "executeCommand" on bean "BeanId(ots_ear#ots_command_ejb.jar#CommandServerR eadCommittedRequiresNew, null)". Exception data: java.lang.NoSuchMethodError: org.hibernate.hql.antlr.SqlGeneratorBase: method access$001(Lorg/hibernate/hql/ast/SqlGeneratorLjava/lang/StringBuffer; not found at org.hibernate.hql.ast.SqlGenerator$DefaultWriter.c lause(SqlGenerator.java:180)
    at org.hibernate.hql.ast.SqlGenerator.out(SqlGenerato r.java:45)
    at org.hibernate.hql.antlr.SqlGeneratorBase.selectSta tement(SqlGeneratorBase.java:166)
    at org.hibernate.hql.antlr.SqlGeneratorBase.statement (SqlGeneratorBase.java:117)
    at org.hibernate.hql.ast.QueryTranslatorImpl.generate (QueryTranslatorImpl.java:213)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompil e(QueryTranslatorImpl.java:180)
    at org.hibernate.hql.ast.QueryTranslatorImpl.compile( QueryTranslatorImpl.java:111)
    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:112)
    at org.hibernate.impl.SessionImpl.createQuery(Session Impl.java:1623)
    at org.springframework.orm.hibernate3.HibernateTempla te$29.doInHibernate(HibernateTemplate.java:819)
    at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:365)
    at org.springframework.orm.hibernate3.HibernateTempla te.find(HibernateTemplate.java:817)
    at org.springframework.orm.hibernate3.HibernateTempla te.find(HibernateTemplate.java:813)

  • #2
    Looks more like you have some conflicting jars on your classpath or multiple versions of the same library.

    Comment


    • #3
      but HibernateTemplate.load function works fine, only the "find" method gives me trouble

      Comment


      • #4
        Can you post your mapping file, if it's possible ?

        Comment


        • #5
          sure:

          <hibernate-mapping auto-import="true" default-lazy="false">
          <class
          name="com.tuc.ssi.ots.order.dto.PricingEstimateDTO "
          table="BIL_ITM_EST"
          >
          <id
          name="pricingEstimateId"
          type="java.lang.Long"
          column="BIL_ITM_EST_ID"
          >
          <generator class="com.tuc.cwf.hibernate.id.CachedBlockSequenc eGenerator">
          <param name="sequence">BIL_ITM_EST_SEQ</param>
          <param name="cache_size">200</param>
          </generator>
          </id>
          <property
          name="sequenceNumber"
          type="java.lang.Long"
          column="SEQ_NUM"
          not-null="true"
          length="2"
          />
          <property
          name="typeCode"
          type="java.lang.String"
          column="BIL_ITM_TYP_CDE"
          not-null="true"
          length="5"
          />
          <property
          name="subtype"
          type="java.lang.String"
          column="BIL_ITM_SBTYP_NME"
          not-null="true"
          length="50"
          />
          <property
          name="amount"
          type="java.math.BigDecimal"
          column="BIL_ITM_AMT"
          length="12"
          />
          <property
          name="comments"
          type="java.lang.String"
          column="CMNT_TXT"
          not-null="true"
          length="500"
          />
          <property
          name="orderId"
          type="java.lang.Long"
          column="ORDR_ID"
          length="10"
          />
          <property
          name="createTimestamp"
          type="java.util.Date"
          column="CRAT_TSP"
          generated="insert"
          not-null="true"
          />
          <property
          name="updateTimestamp"
          type="java.util.Date"
          column="UPD_TSP"
          generated="always"
          not-null="true"
          />

          </class>
          </hibernate-mapping>

          the hibernate properties are setting as
          <property name="hibernateProperties">
          <props>
          <prop key="hibernate.dialect">org.hibernate.dialect.Orac le9Dialect</prop>

          <!--
          <prop key="hibernate.transaction.factory_class">org.hibe rnate.transaction.JTATransactionFactory</prop>
          <prop key="hibernate.transaction.manager_lookup">org.hib ernate.transaction.WebSphereExtendedJTATransaction Lookup</prop>
          -->

          <prop key="hibernate.transaction.factory_class">org.hibe rnate.transaction.CMTTransactionFactory</prop>

          <!-- recommend to not be set since we are using Spring JTA Transaction Manager
          <prop key="hibernate.transaction.manager_lookup_class">o rg.hibernate.transaction.WebSphereTransactionManag erLookup</prop>
          -->

          <prop key="hibernate.connection.release_mode">after_stat ement</prop>
          <prop key="hibernate.current_session_context_class">jta</prop>

          <!-- Built in automatic session contexct management is preferred - see Section 2.5
          <prop key="hibernate.transaction.flush_before_completion ">true</prop>
          <prop key="hibernate.transaction.auto_close_session">tru e</prop>
          -->

          <prop key="hibernate.cache.use_query_cache">false</prop>
          <prop key="hibernate.cache.use_second_level_cache">false </prop>

          <prop key="hibernate.show_sql">false</prop>
          <prop key="hibernate.format_sql">false</prop>

          </props>
          </property>

          the code in which "find" method is uses :

          // Test code
          List pricingEstimates = new java.util.ArrayList();
          String sql = "FROM PricingEstimateDTO p " +
          " WHERE p.orderId = ? order by p.sequenceNumber " ;
          Session session = null;
          try{

          pricingEstimates = this.getTemplate().find(sql,orderId);
          }
          catch ..................................

          Comment


          • #6
            I would guess that's because the HQL statement uses antlr.jar, load probably doesn't require this.
            Last edited by karldmoore; Aug 29th, 2007, 10:45 AM.

            Comment

            Working...
            X