org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here]

Hibernate JIRA | Jonathan Calvert | 6 years ago
  1. 0

    org.hibernate.hql.ast.HqlLexer can cause a ClassNotFound exception in an OSGi environment with a stacktrace like {code} org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here] at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:80) at antlr.CharScanner.setTokenObjectClass(CharScanner.java:338) at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:54) ... {code} The HqlLexer class has antlr.CharScanner as a superclass, as evidenced by the stacktrace. The contents of the method are: {code} public void setTokenObjectClass(String cl) { // Ignore the token class name parameter, and use a specific token class. super.setTokenObjectClass( HqlToken.class.getName() ); } {code} It passes the name of the HqlToken class as a string to CharScanner, which then ultimately attempts to find HqlToken via antlr.Utils. The tokenObjectClass is a protected field. The code can be simplified by simply setting the field directly to HqlToken.class which is obviously already available to the HqlLexer class. The reason this causes the exception in an OSGi environment is that the context class loader available to ANTLR is limited to what is explicitly declared in the ANTLR bundle. Since ANTLR cannot (and should not) have to know about all the classes that it may be passed, it does not declare an import on the org.hibernate.hql.ast package. By passing the class directly, the lookup is avoided from within the ANTLR package. {code} public void setTokenObjectClass(String cl) { // Ignore the token class name parameter, and use a specific token class. tokenObjectClass = HqlToken.class; } {code}

    Hibernate JIRA | 6 years ago | Jonathan Calvert
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here]
  2. 0

    org.hibernate.hql.ast.HqlLexer can cause a ClassNotFound exception in an OSGi environment with a stacktrace like {code} org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here] at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:80) at antlr.CharScanner.setTokenObjectClass(CharScanner.java:338) at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:54) ... {code} The HqlLexer class has antlr.CharScanner as a superclass, as evidenced by the stacktrace. The contents of the method are: {code} public void setTokenObjectClass(String cl) { // Ignore the token class name parameter, and use a specific token class. super.setTokenObjectClass( HqlToken.class.getName() ); } {code} It passes the name of the HqlToken class as a string to CharScanner, which then ultimately attempts to find HqlToken via antlr.Utils. The tokenObjectClass is a protected field. The code can be simplified by simply setting the field directly to HqlToken.class which is obviously already available to the HqlLexer class. The reason this causes the exception in an OSGi environment is that the context class loader available to ANTLR is limited to what is explicitly declared in the ANTLR bundle. Since ANTLR cannot (and should not) have to know about all the classes that it may be passed, it does not declare an import on the org.hibernate.hql.ast package. By passing the class directly, the lookup is avoided from within the ANTLR package. {code} public void setTokenObjectClass(String cl) { // Ignore the token class name parameter, and use a specific token class. tokenObjectClass = HqlToken.class; } {code}

    Hibernate JIRA | 6 years ago | Jonathan Calvert
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here]
  3. 0

    Issue 746 - openmeetings - org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken - Open-Source Web-Conferencing - Google Project Hosting

    google.com | 1 year ago
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [select c from org.openmeetings.app.hibernate.beans.basic.Configuration as c where c.conf_key = :conf_key and c.deleted = :deleted]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    ClassNotFoundException (HqlToken) when running in WebLogic

    Stack Overflow | 7 years ago | dave
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from Bar]
  6. 0

    Commerce Services: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

    Google Groups | 9 years ago | Lukas Zapletal
    org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.elasticpath.domain.attribute.Attribute as a where a.key = ?]

    1 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. org.hibernate.QueryException

      ClassNotFoundException: org.hibernate.hql.ast.HqlToken [hql query here]

      at org.hibernate.hql.ast.HqlLexer.panic()
    2. Hibernate HQL/JP-QL Parser
      HqlLexer.panic
      1. org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:80)
      1 frame
    3. Antlr
      CharScanner.setTokenObjectClass
      1. antlr.CharScanner.setTokenObjectClass(CharScanner.java:338)
      1 frame
    4. Hibernate HQL/JP-QL Parser
      HqlLexer.setTokenObjectClass
      1. org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:54)
      1 frame