Jax ws client failing because of UTF-8 BOM - woodstox-core-asl-4.1.2.jar:4.1.2

Posted on 2015-02-14
Last Modified: 2015-05-16
I have web service client written in JAX-WS.
I'm receiving a response with a UTF-8 BOM.

[0xef][0xbb][0xbf]<?xml ....

So When the same jax-ws client code is deployed to Tomcat server we did have any problem. May be because of tomcat using a different parser.

But we have to deploy our code only in JBoss server - where the application parser is being picked up - woodstox-core-asl-4.1.2.jar:4.1.2. (I will have to use a specific parser only for this jax-ws client if changing the parser is a solution).

Stack trace:

12:27:24,867 FINE  [org.apache.cxf.phase.PhaseInterceptorChain] (http--0_0_0_0_0_0_0_0-8080-2) Invoking handleFault on interceptor
12:27:24,868 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (http--0_0_0_0_0_0_0_0-8080-2) Interceptor for {urn:cache-claim:2003-09-30}WebService#{urn:cache-claim:2003-09-30}MOClaimFastEnqLimits has thrown exception, unwinding now: java.lang.RuntimeException: Couldn't parse stream.
                at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(
                at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(
                at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
                at org.apache.cxf.endpoint.ClientImpl.onMessage(

Caused by: com.ctc.wstx.exc.WstxIOException: Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead
                at [woodstox-core-asl-4.1.2.jar:4.1.2]

Please kindly help me with a solution, I'm desparete to get this working ?
Question by:Faiz03
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
LVL 62

Expert Comment

ID: 40610711
probably you have 2 conflicting versions of com.ctc.wstx arount your application/server/jdk.

Author Comment

ID: 40610730
No I Have only woodstox-core-asl-4.1.2.jar. And this stax is part of the application in class path.I don't want to use this stax as it is failing(i.e. It cannot handle UTF-8 BOM) - ReaderBootstrapper.class If you look at the source of this class you find this

if (c == 0xEF) {
 throw new WstxIOException("Unexpected first character (char code 0xEF), not valid in xml document: could be mangled UTF-8 BOM marker. Make sure that the Reader uses correct encoding or pass an InputStream instead");  }

Open in new window

So i would like to use different stax implementation for my Jax ws client or any other solution.
LVL 62

Expert Comment

ID: 40610745
Well you have some other UTF problem - you have first part of UTF only. There is some problem with UTF generator chopping strings by bytes not by characters.
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.


Author Comment

ID: 40610761
I have verified the response from the third party - Web Service provider (.net) and they are valid response, but they also send the BOM - Byte order mark. Which i have already mentioned,

i have written a Web Serivce client in JAX-WS Which use the stax implementaion in class path - woodstox. And the wood stox parser dosent handle BOM. While the response is still correctly parsed by different stax implemetation etc. I'm sure if i change the stax implemtation this will work but i would like to change this only for Jax -ws client and not for the whole application or any solution that will help solve this problem.
LVL 62

Expert Comment

ID: 40610769
why dont you fill a bug report with them?

Accepted Solution

Faiz03 earned 0 total points
ID: 40610779
I have raised this with third party asking for not sending the byte order mark - BOM but i'm if they are going to resolve this by not sending the BOM. If they do so Happy days. I don't have to change anything.

If i have to file a bug report with woodstox i don't think it is going to get me anything.

I just have time for  a week. And I'm pretty sure that there are alternate ways around this Stax implementation issue but i dont know what they are.
LVL 62

Expert Comment

ID: 40610884
You can open bug report. BOM is legal beginning of XML.
I'd say most XML toolkits will fail with BOM in network stream.

Author Comment

ID: 40610922
Yes i did fingers crossed. I'm still working/searching for a workaround for this.
LVL 62

Expert Comment

ID: 40611042
Stop microsoft from adding useless BOM character?

Author Closing Comment

ID: 40780618
Because this is what i have ended up with.

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maven example error 3 77
tomcat startup error 5 136
intellij error 2 33
batch vs regular insert in spring DAO 2 25
For some reason Google Apps has decided to reserve 'www' for your new domain which results in an error when trying to map the web address 'www' to a certain site in your Google Sites. The error is 'this address is already being used' and after some …
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to implement Singleton Design Pattern in Java.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question