Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5719

NoSuchElementException in ClientFaultConverter when stack trace message contains * or #

    XMLWordPrintableJSON

    Details

    • Estimated Complexity:
      Moderate

      Description

      Following stack trace shows up whenever there is a # or a * character in one of the 'Caused By:' clause.

      Caused by: java.util.NoSuchElementException
      	at java.util.StringTokenizer.nextToken(StringTokenizer.java:349)
      	at org.apache.cxf.interceptor.ClientFaultConverter.parseStackTrackLine(ClientFaultConverter.java:287)
      	at org.apache.cxf.interceptor.ClientFaultConverter.getCause(ClientFaultConverter.java:278)
      	at org.apache.cxf.interceptor.ClientFaultConverter.setStackTrace(ClientFaultConverter.java:246)
      	at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:79)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
      	at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
      	at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
      	at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
      	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
      	at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:845)
      

      For example :

      org.springframework.jdbc.UncategorizedSQLException: Error setting null for parameter #1 with JdbcType OTHER . Try setting a different JdbcType for this parameter or a different jdbcTypeForNull configuration property. Cause: java.sql.SQLException: Type de colonne non valide: 1111
      ; uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; Type de colonne non valide: 1111; nested exception is java.sql.SQLException: Type de colonne non valide: 1111
      	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
      	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
      	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
      	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
      	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
      	at com.sun.proxy.$Proxy74.selectOne(Unknown Source)
      

      Because it considers the # (sharp) character as a delimiter.
      That means actual CXF stack trace deserialization does not work for any 'Caused By' clause with a sharp (#) or a star character (#)... which is really unpleasant for customization (see stack trace Apache MyBatis stack trace example above).

      Please avoid StringTokenizer splitting in favor of a String.split(...) or a plain old iterator. Because StringTokenizer considers not only Message.EXCEPTION_CAUSE_SUFFIX as a delimiter, but also each character in it, which are sharp # and star *.

      StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.


      org.apache.cxf.interceptor.ClientFaultConverter.setStackTrace

      also see CXF-5231

        Attachments

          Activity

            People

            • Assignee:
              dkulp Daniel Kulp
              Reporter:
              sbenbouzid Saad Benbouzid
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified