YAMLException: 不允许使用特殊字符

huangapple go评论83阅读模式
英文:

YAMLException: special characters are not allowed

问题

以下是您提供的内容的翻译:

我正试图读取一个 yml 文件并将其转换为对象,以便在 yml 文件中进行更改,但在使用 ISO_8859_1 在 Linux 服务器上进行转换时,出现了以下异常。

异常:

由于不可接受的码点 'Â' (0x92),不允许使用特殊字符
在“'reader'”,位置 950
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:211)
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176)
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:136)
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1185)
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:168)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:355)
        ... 43 more

com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.YAMLException: 不允许使用特殊字符
 在 [来源: (StringReader); 行: 165, 列: 40]
        at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.YAMLException.from(YAMLException.java:25)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:361)
        at com.fasterxml.jackson.core.JsonParser.nextFieldName(JsonParser.java:825)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:896)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        ... (省略部分错误栈信息)

代码片段:

StringBuilder contentBuilder = new StringBuilder();
String originalFile = "..路径";
try (Stream<String> stream = java.nio.file.Files.lines(Paths.get(originalFile), StandardCharsets.ISO_8859_1)) {
    stream.forEach(s -> contentBuilder.append(s).append("\n"));
}

Object obj = yamlReader.readValue(contentBuilder.toString(), Object.class);

Yaml 内容:
(以下为 YAML 格式的内容,为了简洁起见,在这里不进行翻译。)

您提供的内容包括异常信息、代码片段和 YAML 内容。如有需要,请随时提问。

英文:

I'm trying to read a yml file and converting it into object to make changes in the yml file, but getting the below exception while conversion when using ISO_8859_1 in linux server.

Exception:

Caused by: unacceptable code point &#39;&#194;&#39; (0x92) special characters are not allowed
in &quot;&#39;reader&#39;&quot;, position 950
        at org.yaml.snakeyaml.reader.StreamReader.update(StreamReader.java:211)
        at org.yaml.snakeyaml.reader.StreamReader.ensureEnoughData(StreamReader.java:176)
        at org.yaml.snakeyaml.reader.StreamReader.peek(StreamReader.java:136)
        at org.yaml.snakeyaml.scanner.ScannerImpl.scanToNextToken(ScannerImpl.java:1185)
        at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:287)
        at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:227)
        at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558)
        at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158)
        at org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:168)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:355)
        ... 43 more


com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.YAMLException: special characters are not allowed
 at [Source: (StringReader); line: 165, column: 40]
        at com.fasterxml.jackson.dataformat.yaml.snakeyaml.error.YAMLException.from(YAMLException.java:25)
        at com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:361)
        at com.fasterxml.jackson.core.JsonParser.nextFieldName(JsonParser.java:825)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:896)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:895)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:871)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.mapObject(UntypedObjectDeserializer.java:895)
        at com.fasterxml.jackson.databind.deser.std.UntypedObjectDeserializer$Vanilla.deserialize(UntypedObjectDeserializer.java:654)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4014)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3005)

Code extract:

StringBuilder contentBuilder = new StringBuilder();
String originalFile = &quot;..path&quot;;
try (Stream&lt;String&gt; stream = java.nio.file.Files.lines(Paths.get(originalFile), StandardCharsets.ISO_8859_1)) {
			stream.forEach(s -&gt; contentBuilder.append(s).append(&quot;\n&quot;));
		}
		
		Object obj = yamlReader.readValue(contentBuilder.toString(), Object.class); 

Yaml content:

---
spring:
application:
name: &quot;DGL-SVC-V-AccountRenewalCD&quot;
cdr:
enable4IPB: true
mislogging:
enabled: true
paymentFrequency:
cdUpdate:
monthly: 1
endOfTerm: 2
cdDetails:
monthly: 0
endOfTerm: 5
enable4CPB: false
enableRetirementCDRenewal: true
interestPaymentApplicationId: &quot;CA&quot;
interestDistributionMethod:
payToAffiliate: 1
redeposit: 0
addExternalAccounts: false
invalidIPBTerms: &quot;1,2&quot;
ccp:
logger:
ids:
templateProperties:
CDRENEWAL: &quot;com.ccp.logging.ids.formatter.JFPIDSMapper||event-type-ccpids-template-self.ftl&quot;
emsconnector:
communication: &quot;jms&quot;
loggerImplementation: &quot;emsConnector&quot;
hystrix:
threadpool:
getCDRatesThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
getCustomerInfoThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
validateInternalFundTransferThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
getCDAccountDetailsThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
submitCDRenewalThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
submitInternalFundTransferThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
getRetirementAccountDetailsThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
getAccountsThreadPoolKey:
maxQueueSize: 5
coreSize: 40
maximumSize: 60
allowMaximumSizeToDivergeFromCoreSize: true
command:
getRetirementAccountDetails:
execution.isolation.thread.timeoutInMilliseconds: 10000
submitCDRenewal:
execution.isolation.thread.timeoutInMilliseconds: 10000
submitInternalFundTransfer:
execution.isolation.thread.timeoutInMilliseconds: 10000
getCustomerInfo:
execution.isolation.thread.timeoutInMilliseconds: 10000
validateInternalFundTransfer:
execution.isolation.thread.timeoutInMilliseconds: 10000
getAccounts:
execution.isolation.thread.timeoutInMilliseconds: 10000
getCDRates:
execution.isolation.thread.timeoutInMilliseconds: 10000
getCDAccountDetails:
execution.isolation.thread.timeoutInMilliseconds: 1
url-info-config:
urlInfoMap:
EXTERNAL_ACCOUNT_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/api/v1/aggregators/customers/{customerId}/accounts&quot;
serviceName: &quot;B2B-AM-D-YodleeConnector&quot;
uri: &quot;/api/v1/aggregators/customers/{customerId}/accounts&quot;
eurekaEnabled: true
RATES_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/bank/rates/retrieve&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/bank/rates/retrieve&quot;
eurekaEnabled: true
CD_ACCOUNT_DETAILS_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/v1/domain/accounts/cdAccountDetails/retrieve&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/v1/domain/accounts/cdAccountDetails/retrieve&quot;
eurekaEnabled: true
ACCOUNT_PROFILE_REFRESH_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/private/v2/profiles/accounts/details&quot;
serviceName: &quot;DGL-AM-V-ACCOUNTPROFILEWS-V2&quot;
uri: &quot;/private/v1/accounts/profiles/refreshCache&quot;
eurekaEnabled: true
ACCOUNT_PROFILE_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/private/v2/profiles/accounts/details&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/private/v1/accounts/profiles&quot;
eurekaEnabled: true
PROJECTED_CD_INFO_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/v1/domain/accounts/cdAccountProjectedInfo/retrieve&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/v1/domain/accounts/cdAccountProjectedInfo/retrieve&quot;
eurekaEnabled: true
INTERNAL_FUND_TRANSFER_VALIDATE_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/moneymovement/fundstransfer/validate&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/moneymovement/fundstransfer/validate&quot;
eurekaEnabled: true
SUBMIT_CD_RENEWAL:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/v1/domain/accounts/updateCDAccount&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/v1/domain/accounts/updateCDAccount&quot;
eurekaEnabled: true
CUSTOMER_DEMOGRAPHICS_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/private/v2/profiles/customers/retrieve&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/private/v2/profiles/customers/retrieve&quot;
eurekaEnabled: true
INTERNAL_FUND_TRANSFER_SUBMIT_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/cdr/moneymovement/fundstransfer/submit&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/moneymovement/fundstransfer/submit&quot;
eurekaEnabled: true
RETIREMENT_ACCOUNT_DETAILS_SERVICE:
fullUrl: &quot;http://sd-9ea5-6df7.nam.nsroot.net:8142/v1/retirement/accounts/details/retrieve&quot;
serviceName: &quot;NAM-CARDS-SIM-WRAP-APP-COMMON2&quot;
uri: &quot;/6916/lisa/api/private/v1/retirement/accounts/details/retrieve&quot;
eurekaEnabled: true
subApp:
id: &quot;DGL-SVC-V-AccountRenewalCD&quot;
error-info-config:
errorInfoMap:
INTERNAL_SERVER_ERROR:
httpStatus: 500
errorCode: &quot;INVALID_REQUEST&quot;
message: &quot;internal server error&quot;
type: &quot;ERROR&quot;
NOT_VALID_CD_ACCOUNT:
httpStatus: 400
errorCode: &quot;INVALID_CD_ACCOUNT&quot;
message: &quot;This is not a valid CD Account for Renewal&quot;
type: &quot;ERROR&quot;
ST0064:
httpStatus: 500
errorCode: &quot;REC_NOT_FOUND&quot;
message: &quot;RATE REC NOT FOUND FOR&quot;
type: &quot;ERROR&quot;
CD_MINIMUM_BALANCE_ERROR:
httpStatus: 400
errorCode: &quot;CD_MINIMUM_BALANCE_ERROR&quot;
message: &quot;Remaining CD balance cannot subceed the CD Minimum Balance.&quot;
type: &quot;ERROR&quot;
INSUFFICIENT_BALANCE:
httpStatus: 500
errorCode: &quot;INSUFFICIENT_BALANCE&quot;
message: &quot;Insufficient Balance in the Source Account.&quot;
type: &quot;ERROR&quot;
SP6032:
httpStatus: 500
errorCode: &quot;HOLD_ON_ACCOUNT&quot;
message: &quot;STOP/HOLD ON ACCOUNT&quot;
type: &quot;ERROR&quot;
SP6033:
httpStatus: 500
errorCode: &quot;NEW_ACCOUNT&quot;
message: &quot;THIS IS A NEW ACCOUNT&quot;
type: &quot;ERROR&quot;
CLOSE_CD_FLOW:
httpStatus: 500
errorCode: &quot;CLOSE_CD_FLOW&quot;
message: &quot;Partial withdrawal amounts must be less than CD account total.&quot;
type: &quot;ERROR&quot;
SP6014:
httpStatus: 400
contentId: &quot;Landing.renewedCdError&quot;
errorCode: &quot;CUSTOM_ALERT_ERROR&quot;
message: &quot;Sorry, we can’t process this request.|Your CD renewal request has\
\ previously been received and is being processed.&quot;
type: &quot;ERROR&quot;
VALIDATION_ERROR:
httpStatus: 400
errorCode: &quot;INVALID_REQUEST&quot;
message: null
type: &quot;ERROR&quot;
TS9400:
httpStatus: 400
errorCode: &quot;ACCOUNT_NOT_FOUND&quot;
message: &quot;RECORD NOT FOUND&quot;
type: &quot;ERROR&quot;
NOT_VALID_APP:
httpStatus: 400
errorCode: &quot;CUSTOM_ALERT_ERROR&quot;
message: &quot;Sorry, we can’t process this request on Mobile app at this time.|Please\
\ retry on online.com.&quot;
type: &quot;ERROR&quot;
ST7600:
httpStatus: 500
errorCode: &quot;CD_ACCT_NOT_FOR_RECIPIENT&quot;
message: &quot;CD ACCOUNT NOT VALID FOR RECIPIENT&quot;
type: &quot;ERROR&quot;
SP6018:
httpStatus: 400
contentId: &quot;Landing.renewedCdError&quot;
errorCode: &quot;CUSTOM_ALERT_ERROR&quot;
message: &quot;Sorry, we can’t process this request.|Your CD renewal request has\
\ previously been received and is being processed.&quot;
type: &quot;ERROR&quot;
ACCOUNT_ALREADY_UPDATED:
httpStatus: 400
contentId: &quot;Landing.renewedCdError&quot;
errorCode: &quot;CUSTOM_ALERT_ERROR&quot;
message: &quot;Sorry, we can’t process this request.|Your CD renewal request has\
\ previously been received and is being processed.&quot;
type: &quot;ERROR&quot;
ST0204:
httpStatus: 500
errorCode: &quot;RENEWAL_BEEN_PROCESSED&quot;
message: &quot;RENEWAL HAS ALREADY BEEN PROCESSED&quot;
type: &quot;ERROR&quot;
cdr-product-config:
cdRenewalRetirementProducts:
- 262
- 268
- 269
cdRenewalProducts:
- 184
- 590
- 591
tmx:
applicationName:
android: 154811
browser: 144564
ios: 168524

Added the yaml content as requested along with exception details and code extract.

Any help is appreciated.

答案1

得分: 2

请看这里这里,这个代码点对应于Windows-1252中的右引号字符,可能是因为文件在Windows系统中被编辑过。

正如异常所指示的那样,这个代码点在iso-8859-1或utf-8中不受支持:请参考这个页面来比较每种编码如何支持这个和其他字符。

要解决问题,只需编辑文件并以iso-8859-1或utf-8编码保存,替换掉这个字符,然后应该就可以了。从您的YAML文件的审查来看,问题很可能与错误“message”中的不同can’t单词有关。

英文:

As you can see here and here, this code point corresponds to the right quote character in windows-1252, probably because the file was edited in a Windows system.

As the exception indicates, this code point it is not supported by iso-8859-1 or utf-8: please, see for example this page for a comparison of how every encoding supports this and other characters.

To solve your problem, just edit the file and save it in a iso-8859-1 or utf-8 encoding replacing this character(s), it should work. Reviewing your YAML file it is very likely that the problem is related with the different can’t words in your error messages.

huangapple
  • 本文由 发表于 2020年10月26日 17:11:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/64534225.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定