I have services developed using Spring Boot 2.2.4 which takes POST parameters as input. The problem is that if I input a string having any special symbols i.e. Copyright symbol or Trademark symbol it works fine with Windows system but when deployed on k8s, it changes to '?' symbol. I tried setting the #Consumes with charset UTF-8, setting the spring properties:
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled= true
spring.http.encoding.force= true
Still the problem persists. I am not sure if this is an encoding problem or some other configuration problem with Linux/ SpringBoot.
Related
I have this property into Spring Boot application:
server:
connection-timeout: 12000
I get warning:
Deprecated Each server behaves differently. Use server specific properties instead.
Gradle: org.springframework.boot:spring-boot-autoconfigure:2.6.8 (spring-boot-autoconfigure-2.6.8.jar)
is there some better configuration property that I can use?
I don't even know why you receive a deprecated warning.
According to the documentation from Spring Boot version 2.3 and onwards this property is removed not deprecated any more.
As you can read here, there are some other properties which you can use instead depending on the server that runs your spring boot application.
server.tomcat.connection-timeout should be used if you have tomcat as running server.
server.netty.connection-timeout should be used if netty is used.
server.jetty.connection-idle-timeout should be used if jetty is used
Basically each server has it's own implementation, so you must read your server's documentation to see what it allows and how this behaves. There might be slight differences from how one server behaves and how it interprets connection-timeout and how another server behave and interprets a similar configuration.
This is I think the reason that Spring decides to move to server specific configuration on property connection-timeout instead of a general property and also a very important reason was that some servers may not even have this configuration available to them. So then you have a general property configured in your spring boot application which the server that runs the application can't even respect.
Therefore you now have specific properties for specific servers and now you can be sure upfront whether this configuration is available in your server and you can also read the server documentation to understand exactly what the behavior will be.
Although this setting is being deprecated, we still can use the timeout function.
According to official document, we can use #Transactional(timeout = 1) to do the track in the controller
https://www.baeldung.com/spring-rest-timeout
I am upgrading my application from SpringBoot 1.5 to 2.3, the old application had the following yml file
config:
pic_code:
"Test/Try": "ABC"
"Trial": "DRF"
After upgrading, YAML key with '/' is not being read properly and gives null.
I have tried to change the key as below
"[Test/Try]"
'[Test/Try]'
"Test'/Try"
but nothing worked.
Any suggestions will be very much helpful
It works with '[Test/Try]' as per the link shared above Spring Boot YAML configuration with URL in key no longer loads correctly with version 2
I have ejb message driven bean on was 8 java 6. every think work well.
The message driver bean listened on mq queue .
the queue on MainFrame
I migrated from WAS 8 to WAS 9 (java 8) .
Some messages include characters that cannot converted and cause exception :
JMSCMQ1049: The character set '424(IBM424) Unmappable Action: REPORT
I found an article that talks about the problem
https://www.ibm.com/docs/en/ibm-mq/8.0?topic=java-character-string-conversions-in-mq-classes
Character string conversions in IBM MQ classes for Java
The IBM® MQ classes for Java use CharsetEncoders and CharsetDecoders
directly for character string conversion. The default behavior for
character string conversion can be configured with two system
properties. The handling of messages that contain unmappable
characters can be configured through com.ibm.mq.MQMD.
Before IBM MQ 8.0, string conversions in IBM MQ classes for Java was done by calling the java.nio.charset.Charset.decode(ByteBuffer)
and Charset.encode(CharBuffer) methods.
Using either of these methods results in a default replacement ( REPLACE) of malformed or untranslatable data. This behavior can
obscure errors in applications, and lead to unexpected characters, for
example ?, in translated data.
From IBM MQ 8.0, to detect such issues earlier and more effectively, the IBM MQ classes for Java use CharsetEncoders and
CharsetDecoders directly and configure the handling of malformed and
untranslatable data explicitly. The default behavior is to REPORT such
issues by throwing a suitable MQException.
What I do not know, is how to implement the solution that the article
offers within the JMS settings of the queue in webSphere admin console or in java implementation
Anyone know how to solve the problem?
The link provided has the information below:
com.ibm.mq.cfg.jmqi.UnmappableCharacterAction Specifies the action to
be taken for untranslatable data on encoding and decoding. The value
can be REPORT, REPLACE, or IGNORE.
com.ibm.mq.cfg.jmqi.UnmappableCharacterReplacement Sets or gets the
replacement bytes to apply when a character cannot be mapped in an
encoding operation The default Java replacement string is used in
decoding operations.
If you wanted to mimic the prior behavior you would set the following system properties as generic JVM arguments the following link discusses how to set the arguments: Setting generic JVM arguments in WebSphere Application Server
-Dcom.ibm.mq.cfg.jmqi.UnmappableCharacterAction=REPLACE
-Dcom.ibm.mq.cfg.jmqi.UnmappableCharacterReplacement=63
For a more detailed answer that is not specific to WAS see this:
Special Character Issue : MQ message PUT error : java.nio.charset.UnmappableCharacterException
I'm new to WAS server. I'm doing POC with Java 1.8, Spring(4.3.9.RELEASE), Hibernate(4.2.0), DB2 and WAS 8.5.5(installed java 1.8). Server started successfully but getting below exception while executing createQuery() statement.
java.io.UnsupportedEncodingException: Cp037
at sun.io.Converters.getConverterClass(Converters.java:319)
at sun.io.Converters.newConverter(Converters.java:373)
at sun.io.ByteToCharConverter.getConverter(ByteToCharConverter.java:98)
at com.ibm.db2.jcc.b.p.a(p.java:435)
... 132 more
2020-01-09 17:20:13 WARN SqlExceptionHelper:143 - SQL Error: -99999, SQLState: 22021
2020-01-09 17:20:13 ERROR SqlExceptionHelper:144 - [ibm][db2][jcc][10275][10041] Unsupported ccsid, encoding, or locale: "Cp037".
It is working fine when i deploy the same into Tomcat. Please help me on this to resolve,
let me know if any info needed. Thank you.
It seems an known behavior of JDK 8. Here is one of references:
UTF-8 encoding/decoding problem in JDK 8
https://www.ibm.com/support/pages/utf-8-encodingdecoding-problem-jdk-8
Cause:
Starting from JDK 8 ,the input data to NIO UTF-8 decoder(Java API) should be of pure UTF-8. Till JDK 8 this rule was not strictly implemented and decoder was able to decode ill-formed UTF-8 byte sequence also. Decoder in JDK 1.8 will throw an exception if it encounters non UTF-8 data and the program cannot proceed with the execution.
Solution: (Does not work for Oracle JDK 8)
A new global property db2.jcc.alternateUTF8Encoding is introduced in JCC. This property can have value 1 and 0 ,the default value is 0 . If this property is set to 1 under IBM JDK 1.8 (db2.jcc.alternateUTF8Encoding=1) for UTF8 encoded data ,JCC uses UTF8J to decode .
This will help to avoid MalformedInputException during decoding. This is a global property and need to be configured in the property file. This property cannot be set using DataSource or Connection and works only with IBM JDK.
It is recommended review the article.
Hope this helps.
I hit this problem, I resolved issue with below actions.
open websphere app server (WAS) admin console.
go to JDBC, JDBC providers, DB2 Using IBM JCC Driver, Class Path;
ensure you have this entry: ${DB2_JCC_DRIVER_PATH}/db2jcc4.jar
go to Environment, Websphere variables, DB2_JCC_DRIVER_PATH should point to folder/path of latest db2jcc4.jar, mine is dated 6/13/2019
I recently upgraded Tomcat from v7.0.26 to v7.0.76 for one of my webapp. The URLs that were working earlier are not getting encoded. : gets encoded as %3A. I tried mentioning UTF-8 in the web.xml and server.xml, but the encoding is still seen. Has anyone come across a similar issue?
After investigating the tomcat changelog and trying several versions of tomcat, found that tomcat v7.0.70 has a change for this issue. The changeset is here. This change causes the URL to be encoded when you do a getRequestURI() call.
To avoid this issue of encoding, we are using Tomcat version prior to 7.0.70.
Alternatively there is a flag dispatchersUseEncodedPaths which can be used to enable/disable this encoding that was introduced in tomcat v7.0.70.