iBatis for Java [READ ONLY]
  1. iBatis for Java [READ ONLY]
  2. IBATIS-389

Unbalanced # in SQL causes unclear/misleading error message

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0, 2.3.4
    • Fix Version/s: 2.3.5
    • Component/s: Core
    • Labels:
      None

      Description

      Below is the stack trace for in exception caused by an unbalanced # in an insert statement. The "Error parsing XPath 'blah'" message does not give nearly as much information as the parser has available at the time and does not even indicate the source of the problem. I have traced the issue back to the use of StringTokenizer in InlineParameterMapParser, if this class was changed slightly, to catch NoSuchElementException and rethrow SqlMapException with a message like "Failed to parse statement [xpath] with id [statement id], check inline parameters" or even "Failed to parse SQL in [statement id]" finding the problem would be almost effortless. All it needs is a big try-catch block around the whole method body.
      This code appears to be an failed effort to do this, StringTokenizer picks up the sntax error before this:
      if (!PARAMETER_TOKEN.equals(token))

      { throw new SqlMapException("Unterminated inline parameter in mapped statement (" + "statement.getId()" + ")."); }

      I just lost a good hour trying to find the source of one of these problems, I traced the iBatis code to figure out where a NoSuchElementEx could be thrown to figure out what would be wrong after 20 minutes of reading my XML/SQL. Calling the bug major might seem a bit melodramatic, but I think it is important that this gets out in a maint. release soon.


      Error occurred. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'. Cause: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/insert'. Cause: java.util.NoSuchElementException
      Caused by: java.util.NoSuchElementException
      org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
      org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)

        Activity

          People

          • Assignee:
            Kai Grabfelder
            Reporter:
            Jamison
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development