Return-Path: X-Original-To: apmail-cxf-issues-archive@www.apache.org Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 58DDC10BE4 for ; Mon, 2 Jun 2014 23:39:02 +0000 (UTC) Received: (qmail 86679 invoked by uid 500); 2 Jun 2014 23:39:01 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 86608 invoked by uid 500); 2 Jun 2014 23:39:01 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 86597 invoked by uid 99); 2 Jun 2014 23:39:01 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2014 23:39:01 +0000 Date: Mon, 2 Jun 2014 23:39:01 +0000 (UTC) From: "Brian Semrad (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CXF-5231) NoSuchElementException in ClientFaultConverter when stack trace message contains line breaks MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CXF-5231?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14016046#comment-14016046 ] Brian Semrad edited comment on CXF-5231 at 6/2/14 11:37 PM: ------------------------------------------------------------ [~sbenbouzid] Yes, it does appear to be that same issue. I didn't see the other open issue. Thanks. was (Author: cerebralvortex): @Saad Be > NoSuchElementException in ClientFaultConverter when stack trace message contains line breaks > -------------------------------------------------------------------------------------------- > > Key: CXF-5231 > URL: https://issues.apache.org/jira/browse/CXF-5231 > Project: CXF > Issue Type: Bug > Affects Versions: 2.7.3, 2.7.6 > Reporter: JBE > Assignee: Freeman Fang > Fix For: 2.6.10, 2.7.7, 3.0.0-milestone1 > > > On server side, I have enabled those two flags in order to be able to retrieve the full exception in client : > {code} > Message.FAULT_STACKTRACE_ENABLED -> true > Message.EXCEPTION_MESSAGE_CAUSE_ENABLED -> true > {code} > The problem is that one of the exception message contains a line break "\n" character. Thus when the exception is thrown, here is what I have on client side with version 2.7.6 : > {code} > java.util.NoSuchElementException > at java.util.StringTokenizer.nextToken(StringTokenizer.java:349) > at org.apache.cxf.interceptor.ClientFaultConverter.parseStackTrackLine(ClientFaultConverter.java:288) > at org.apache.cxf.interceptor.ClientFaultConverter.getCause(ClientFaultConverter.java:279) > at org.apache.cxf.interceptor.ClientFaultConverter.setStackTrace(ClientFaultConverter.java:247) > at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:80) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) > 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:271) > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:811) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1486) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1305) > at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) > at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:623) > at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:541) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) > at com.sun.proxy.$Proxy71.execute(Unknown Source) > at com.mycompany.client.WebServiceClient.main(WebServiceClient.java:111) > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Fault string, and possibly fault code, not set > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:156) > at com.sun.proxy.$Proxy71.execute(Unknown Source) > at com.mycompany.client.WebServiceClient.main(WebServiceClient.java:111) > Caused by: java.util.NoSuchElementException > at java.util.StringTokenizer.nextToken(StringTokenizer.java:349) > at org.apache.cxf.interceptor.ClientFaultConverter.parseStackTrackLine(ClientFaultConverter.java:288) > at org.apache.cxf.interceptor.ClientFaultConverter.getCause(ClientFaultConverter.java:279) > at org.apache.cxf.interceptor.ClientFaultConverter.setStackTrace(ClientFaultConverter.java:247) > at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:80) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) > 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:271) > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:811) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1590) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1486) > at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1305) > at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) > at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:623) > at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) > at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:541) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330) > at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96) > at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:134) > ... 2 more > {code} > After debugging, I can see that in the getCause method of ClientFaultConverter, you are using a StringTokenizer to iterate through different lines. > {quote} > StringTokenizer st = new StringTokenizer(ss, "\n"); > {quote} > When it comes to the exception message, we have this kind of string : > {quote} > Caused by: beginning of the message > end of the message > first line of stack trace > {quote} > Thus this piece of code: > {code} > private Throwable getCause(StringTokenizer st, String firstLine) { > // The actual exception class of the cause might be unavailable at the > // client -> use a standard throwable to represent the cause. > Throwable res = new Throwable(firstLine.substring(firstLine.indexOf(":") + 2)); > List stackTraceList = new ArrayList(); > while (st.hasMoreTokens()) { > String oneLine = st.nextToken(); > if (oneLine.startsWith("Caused by:")) { > Throwable nestedCause = getCause(st, oneLine); > res.initCause(nestedCause); > break; > } > stackTraceList.add(parseStackTrackLine(oneLine)); > } > StackTraceElement[] stackTraceElement = new StackTraceElement[stackTraceList.size()]; > res.setStackTrace(stackTraceList.toArray(stackTraceElement)); > return res; > } > {code} > will result in calling "parseStackTrackLine" on element "end of the message" which causes the exception. -- This message was sent by Atlassian JIRA (v6.2#6252)