org.hibernate.exception.SQLGrammarException: could not execute query

Spring JIRA | Sébastien Launay | 7 years ago
  1. 0

    When an {{org.hibernate.exception.SQLGrammarException}} occurs because a table is missing i have the following stace trace: {noformat} Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.jasig.cas.services.DefaultServicesManagerImpl]: Constructor threw exception; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248) ... 76 more Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:95) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212) at org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152) at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:189) at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:151) at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:311) at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:307) at org.jasig.cas.services.JpaServiceRegistryDaoImpl.load(JpaServiceRegistryDaoImpl.java:30) at org.jasig.cas.services.DefaultServicesManagerImpl.load(DefaultServicesManagerImpl.java:134) at org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:61) at org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:43) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) ... 78 more Caused by: org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.doList(Loader.java:2235) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67) at org.springframework.orm.jpa.JpaTemplate$9.doInJpa(JpaTemplate.java:319) at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:184) ... 90 more Caused by: java.sql.SQLException: ORA-00942: table or view does not exist at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:133) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:115) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:221) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:467) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:417) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1084) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1032) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:1139) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1471) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3874) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3944) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:3613) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) ... 100 more {noformat} Because the {{SQLGrammarException}} is wrapped like any other exception we lose the SQL statement that caused the exception which can be handy in my case because I do not know which table does not exist :(. This maybe more of a Hibernate issue than a Spring issue (SQL in not append in the message but kept in a private field) but this is not the case for the parent class ({{org.hibernate.JDBCException}}) where the SQL statement is integrated by Spring in the stack trace. By looking at the 3.x source code, I think this issue also occurs in the future 3.0 version but I have not tested it.

    Spring JIRA | 7 years ago | Sébastien Launay
    org.hibernate.exception.SQLGrammarException: could not execute query
  2. 0

    When an {{org.hibernate.exception.SQLGrammarException}} occurs because a table is missing i have the following stace trace: {noformat} Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.jasig.cas.services.DefaultServicesManagerImpl]: Constructor threw exception; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:248) ... 76 more Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:95) at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212) at org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152) at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:189) at org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:151) at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:311) at org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:307) at org.jasig.cas.services.JpaServiceRegistryDaoImpl.load(JpaServiceRegistryDaoImpl.java:30) at org.jasig.cas.services.DefaultServicesManagerImpl.load(DefaultServicesManagerImpl.java:134) at org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:61) at org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:43) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100) ... 78 more Caused by: org.hibernate.exception.SQLGrammarException: could not execute query at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.loader.Loader.doList(Loader.java:2235) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129) at org.hibernate.loader.Loader.list(Loader.java:2124) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401) at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363) at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196) at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149) at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102) at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67) at org.springframework.orm.jpa.JpaTemplate$9.doInJpa(JpaTemplate.java:319) at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:184) ... 90 more Caused by: java.sql.SQLException: ORA-00942: table or view does not exist at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:133) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:115) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:221) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:467) at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:417) at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1084) at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215) at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1032) at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:1139) at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1471) at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3874) at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3944) at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:3613) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208) at org.hibernate.loader.Loader.getResultSet(Loader.java:1812) at org.hibernate.loader.Loader.doQuery(Loader.java:697) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) at org.hibernate.loader.Loader.doList(Loader.java:2232) ... 100 more {noformat} Because the {{SQLGrammarException}} is wrapped like any other exception we lose the SQL statement that caused the exception which can be handy in my case because I do not know which table does not exist :(. This maybe more of a Hibernate issue than a Spring issue (SQL in not append in the message but kept in a private field) but this is not the case for the parent class ({{org.hibernate.JDBCException}}) where the SQL statement is integrated by Spring in the stack trace. By looking at the 3.x source code, I think this issue also occurs in the future 3.0 version but I have not tested it.

    Spring JIRA | 7 years ago | Sébastien Launay
    org.hibernate.exception.SQLGrammarException: could not execute query
  3. 0

    JDBC timeout is not throwing SQLTimeoutException

    Stack Overflow | 2 years ago | praveenj
    java.sql.SQLException: ORA-01013: user requested cancel of current operation
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Geovise BVBA

    hibernatespatial.org | 12 months ago
    org.hibernate.QueryTimeoutException: could not execute query
  6. 0

    Sonar - an open source entreprise quality control tool user list

    gmane.org | 1 year ago
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.0:sonar (default-cli) on project big-parent: Can not execute Sonar

  1. qavid 1 times, last 4 months ago
18 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.sql.SQLException

    ORA-00942: table or view does not exist

    at oracle.jdbc.driver.SQLStateMapping.newSQLException()
  2. Oracle jdbc
    OraclePreparedStatementWrapper.executeQuery
    1. oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:133)
    2. oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:115)
    3. oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:221)
    4. oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:467)
    5. oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:417)
    6. oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1084)
    7. oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
    8. oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1032)
    9. oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:1139)
    10. oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1471)
    11. oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3874)
    12. oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3944)
    13. oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:3613)
    13 frames
  3. Commons DBCP
    DelegatingPreparedStatement.executeQuery
    1. org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
    1 frame
  4. Hibernate
    QueryLoader.list
    1. org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    2. org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
    3. org.hibernate.loader.Loader.doQuery(Loader.java:697)
    4. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
    5. org.hibernate.loader.Loader.doList(Loader.java:2232)
    6. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
    7. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    8. org.hibernate.loader.Loader.doList(Loader.java:2235)
    9. org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
    10. org.hibernate.loader.Loader.list(Loader.java:2124)
    11. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
    11 frames
  5. Hibernate HQL/JP-QL Parser
    QueryTranslatorImpl.list
    1. org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
    1 frame
  6. Hibernate
    QueryImpl.list
    1. org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
    2. org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
    3. org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
    3 frames
  7. Hibernate EJB
    QueryImpl.getResultList
    1. org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67)
    1 frame
  8. Spring ORM
    JpaTemplate.execute
    1. org.springframework.orm.jpa.JpaTemplate$9.doInJpa(JpaTemplate.java:319)
    2. org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:184)
    2 frames
  9. Hibernate
    SessionFactoryUtils.convertHibernateAccessException
    1. org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:630)
    1 frame
  10. Spring ORM
    HibernateJpaDialect.translateExceptionIfPossible
    1. org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:95)
    1 frame
  11. Spring Tx
    DataAccessUtils.translateIfNecessary
    1. org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:212)
    1 frame
  12. Spring ORM
    JpaTemplate.find
    1. org.springframework.orm.jpa.JpaAccessor.translateIfNecessary(JpaAccessor.java:152)
    2. org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:189)
    3. org.springframework.orm.jpa.JpaTemplate.executeFind(JpaTemplate.java:151)
    4. org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:311)
    5. org.springframework.orm.jpa.JpaTemplate.find(JpaTemplate.java:307)
    5 frames
  13. Jasig CAS Core
    DefaultServicesManagerImpl.<init>
    1. org.jasig.cas.services.JpaServiceRegistryDaoImpl.load(JpaServiceRegistryDaoImpl.java:30)
    2. org.jasig.cas.services.DefaultServicesManagerImpl.load(DefaultServicesManagerImpl.java:134)
    3. org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:61)
    4. org.jasig.cas.services.DefaultServicesManagerImpl.<init>(DefaultServicesManagerImpl.java:43)
    4 frames
  14. Java RT
    Constructor.newInstance
    1. sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    2. sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    3. sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    4. java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    4 frames
  15. Spring Beans
    BeanUtils.instantiateClass
    1. org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
    1 frame