Java Metro Client Throwing WstxParsingException - xml-parsing

I have a Metro web service client that is throwing a com.ctc.wstx.exc.WstxParsingException.
If I am reading it correctly, it's saying that "3" is an invalid XML character. Is that correct? What is an "expansion character" and why would "3" be invalid?
Full stack trace:
Exception in thread "main" com.sun.xml.ws.encoding.soap.DeserializationException: Failed to read a response: javax.xml.bind.UnmarshalException
- with linked exception:
[com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x3) not a valid XML character
at [row,col {unknown-source}]: [2,4154]]
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:124)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:89)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:140)
at $Proxy34.getSubInfoByRel(Unknown Source)
at com.my.company.client.SOAPClient.getSubscriberInfoByTN(SOAPClient.java:237)
Caused by: javax.xml.bind.UnmarshalException
- with linked exception:
[com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x3) not a valid XML character
at [row,col {unknown-source}]: [2,4154]]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:426)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:362)
at com.sun.xml.bind.v2.runtime.BridgeImpl.unmarshal(BridgeImpl.java:120)
at com.sun.xml.bind.api.Bridge.unmarshal(Bridge.java:233)
at com.sun.xml.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:547)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:121)
... 5 more
Caused by: com.ctc.wstx.exc.WstxParsingException: Illegal character entity: expansion character (code 0x3) not a valid XML character
at [row,col {unknown-source}]: [2,4154]
at com.ctc.wstx.sr.StreamScanner.constructWfcException(StreamScanner.java:605)
at com.ctc.wstx.sr.StreamScanner.throwParseError(StreamScanner.java:461)
at com.ctc.wstx.sr.StreamScanner.reportIllegalChar(StreamScanner.java:2375)
at com.ctc.wstx.sr.StreamScanner.checkAndExpandChar(StreamScanner.java:2321)
at com.ctc.wstx.sr.StreamScanner.resolveCharEnt(StreamScanner.java:2277)
at com.ctc.wstx.sr.StreamScanner.fullyResolveEntity(StreamScanner.java:1468)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2755)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1019)
at com.sun.xml.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:92)
at com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector.bridge(StAXStreamConnector.java:192)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:360)
... 9 more

The issue was that (code 0x3) is a Unicode code point and as such an illegal XML character. The owners of the data have been informed. Thanks to Josh from the Woostox mailing list for the help.

Related

Error when use kafka-avro-console-consumer consume avro message sent by spring cloud stream kafka

I tried official schema-registry-confluent example (consumer/producer) with my local installed confluent 4.0.0, it can send "sensor" avro message when send post request and receive in listener, but when I use kafka-avro-console-consumer tool shipped with confluent 4.0.0 to view avro message sent, the tool raised the following error (a). I also tried to consume avro message sent by kafka-avro-console-producer tool (and the message can be shown correctly in kafka-avro-console-consumer tool) , it reported the following error (b). Doesn't the given example support confluent 4.0.0? Many thanks!
(a) kafka-avro-console-consumer error =>
ERROR Unknown error when running consumer: (kafka.tools.ConsoleConsumer$:107)
org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id -1
Caused by: org.apache.kafka.common.errors.SerializationException: Unknown magic byte!
(b) listener error =>
org.springframework.messaging.converter.MessageConversionException: Could not read JSON: Invalid UTF-32 character 0x51473863 (above 0x0010ffff) at char #1, byte #7); nested exception is java.io.CharConversionException: Invalid UTF-32 character 0x51473863 (above 0x0010ffff) at char #1, byte #7)
at org.springframework.messaging.converter.MappingJackson2MessageConverter.convertFromInternal(MappingJackson2MessageConverter.java:234) ~[spring-messaging-5.1.0.BUILD-SNAPSHOT.jar!/:5.1.0.BUILD-SNAPSHOT]
Every time there is a MessageConversionException it simply means that the provided Message Converters could not convert Message. . . and rightfully so as we can't handle every scenario, only the common ones.
So, you should implement custom Message Converter (either from scratch or extending one of the existing ones).
Here is more info on how to define custom Message Converter
https://docs.spring.io/spring-cloud-stream/docs/Fishtown.M1/reference/htmlsingle/#spring-cloud-stream-overview-user-defined-message-converters

com.fasterxml.jackson.core.JsonParseException(Invalid UTF-8 start byte) occured when using multibyte character

I tried to save a node entity(#NodeEntity) whose property(string type)
has multi-byte string like Japanese, but JsonParseException occurred.
java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0x8d at [Source: [B#569cfc36; line: 1, column: 67]
at org.neo4j.ogm.drivers.bolt.request.BoltRequest.executeRequest(BoltRequest.java:175) ~[neo4j-ogm-bolt-driver-2.1.2.jar!/:na]
at org.neo4j.ogm.drivers.bolt.request.BoltRequest.execute(BoltRequest.java:89) ~[neo4j-ogm-bolt-driver-2.1.2.jar!/:na]
at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:287) ~[neo4j-ogm-core-2.1.1.jar!/:na]
at org.neo4j.ogm.session.request.RequestExecutor.executeSave(RequestExecutor.java:66) ~[neo4j-ogm-core-2.1.1.jar!/:na]
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:85) ~[neo4j-ogm-core-2.1.1.jar!/:na]
at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:44) ~[neo4j-ogm-core-2.1.1.jar!/:na]
at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:447) ~[neo4j-ogm-core-2.1.1.jar!/:na]
But if I invoked java with -Dfile.encoding=UTF-8 option, a entity is saved correctly...
Please advice me how to save multi-byte string without -D=file.encoding option?
I think that it is preferred that encoding is specified in config file or by coding.
Thanks.
My Environment is here.
OS=Windows 7 64bit(Japanese Edition)
Java=JDK1.8u121
Spring Boot=1.5.2
Spring Boot Neo4j=4.2.1
Noe4j Driver= Bolt Driver 2.1.2
This is a known issue in ogm - https://github.com/neo4j/neo4j-ogm/issues/244.
Current suggested workaround is exactly what you did - provide property at startup
-Dfile.encoding=UTF-8

TFS2013 Fails to Deserialize Parameters containing "$/"

I'm using the TFS 2013 XAML Build Process Template and have some parameters that contain TFS paths (i.e. start with $/) and the build immediately fails when deserializing the parameters.
The only workaround I have is to use $\/ but this gets pushed through as it is literally, breaking things that expect $/. Is there any way I can escape the strings properly?
e.g.
Post-build script arguments: -Path1 "$/MyProject/MySolution.sln" -Path2 $/MyProject/NuGet"
MSBuild arguments: /p:PackageOutputDir="$/MyProject/NuGet"
This is causing the following type of exception when I try to run a build:
Exception Message: TF401070: Could not deserialize the JSON string provided. Details:
After parsing a value an unexpected character was encountered: \. Path 'PostActionScriptArguments', line 1, position 449. (type BuildParameterSerializationException)
Exception Stack Trace: at Microsoft.TeamFoundation.Build.Common.BuildParameter.set_Json(String value)
Inner Exception Details:
Exception Message: After parsing a value an unexpected character was encountered: \. Path 'PostActionScriptArguments', line 1, position 449. (type JsonReaderException)
Exception Stack Trace: at Newtonsoft.Json.JsonTextReader.ParsePostValue()

Json string more than 524288 exception

I try to parse a huge json file, it's more that 524288 characters and I can't parse it with groovy and haven't text of exception. Is it a known issue, is there any workaround?
Can it be limitation of tomcat?
Update:
I've got an exception:
ERROR (org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver) - JSONException occurred when processing request: [POST] /person/parsePersonJson
Expected a ',' or ']' at character 524288 of ...
Update2:
in grails I used:
JSON.parse(params.myJson)
Changed tomcat settings of maxPostSize to "0"
It may concern to value of configured POST parameter size in Tomcat (maxPostSize). You should refer to this documentation: http://tomcat.apache.org/tomcat-5.5-doc/config/http.html (keyword: "maxPostSize") for more explanation. Then you can try to increase that value. Hope this helps!
It was a problem with input size. Max input size by specification is 512k

PGError: ERROR: invalid byte sequence for encoding "UTF8

I'm getting the following PGError while ingesting Rails emails from Cloudmailin:
PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xbb HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". : INSERT INTO "comments" ("content") VALUES ('Reply with blah blah ����������������������������������������������������� .....
So it seems pretty clear I have some invalid UTF8 characters getting into the email right? So I tried to clean that up but something is still Sneaking through. Here's what I have so far:
message_all_clean = params[:message]
Iconv.conv('UTF-8//IGNORE', 'UTF-8', message_all_clean)
message_plain_clean = params[:plain]
Iconv.conv('UTF-8//IGNORE', 'UTF-8', message_plain_clean)
#incoming_mail = IncomingMail.create(:message_all => Base64.encode64(message_all_clean), :message_plain => Base64.encode64(message_plain_clean))
Any ideas, thoughts or suggestions? Thanks
When encountering this issue on Heroku, we converted to US-ASCII to sanitize incoming data appropriately (i.e. pasted from Word):
Iconv.conv("UTF-8//IGNORE", "US-ASCII", content)
With this, we had no more issues with character encoding.
Also, double check that there's no other fields that need the same conversion, as it could affect anything that's passing a block of text to the database.

Resources