Solved

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

Posted on 2015-02-14
11
347 Views
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 org.apache.cxf.ws.policy.PolicyInInterceptor@389dd05c
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(StaxUtils.java:1178)
                at org.apache.cxf.interceptor.StaxInInterceptor.handleMessage(StaxInInterceptor.java:104)
                at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
                at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:795)


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 com.ctc.wstx.io.ReaderBootstrapper.bootstrapInput(ReaderBootstrapper.java:174) [woodstox-core-asl-4.1.2.jar:4.1.2]

Please kindly help me with a solution, I'm desparete to get this working ?
0
Comment
Question by:Faiz03
  • 5
  • 5
11 Comments
 
LVL 61

Expert Comment

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

Author Comment

by:Faiz03
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.
0
 
LVL 61

Expert Comment

by:gheist
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.
0
 

Author Comment

by:Faiz03
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.
0
 
LVL 61

Expert Comment

by:gheist
ID: 40610769
why dont you fill a bug report with them?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Accepted Solution

by:
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.
0
 
LVL 61

Expert Comment

by:gheist
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.
0
 

Author Comment

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

Expert Comment

by:gheist
ID: 40611042
Stop microsoft from adding useless BOM character?
0
 

Author Closing Comment

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
To properly understand GitHub, let’s divide it into two words ‘Git’ and ‘Hub’. Git is basically a ‘Distribution Version Control’ (DVC) and ‘Source Code Management’ (SCM) system widely used by software programmers while Hub means the efficient centre…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now