Monday, December 7, 2020

Weblogic - App throwing ORA-01722: invalid number /conversion between client & server..

After migrating a custom web application from one Weblogic Server to another; we started to encounter ORA-01722 errors. (recorded in the Admin Server logs..) 

Note that, this custom app was deployed to the Admin Server.. Yeah , it should be deployed to a Managed Server but let's forget about that for now :)

ORA-01722 is an error which may be reported during the conversion of a character string to a number. Basically, it is reported when this conversion can not done correctly.

Database tier was the same, the data was the same (and correct), the code was the same, only the Weblogic tier was different...

This was probably related to some conversions between client (in this case -> Weblogic) and the database.. 

So, we implemented the following solution..
  • Checked the database character set..
  • Set the LANG environment variable (for the Weblogic) equal to the database character set..
With these moves, we actually made client (Weblogic) character set = server character set.. Thus, we ensured that there wouldn't be any conversions while data was flowing from db to the app..

Note that setting LANG also sets the NLS_NUMERIC_CHARACTERS indirectly as that parameter is derived from NLS_TERRITORY and the NLS_TERRITORY is also defined by the LANG itself.

Well, this error could also be caused by the wrong alignment between NLS_NUMERIC_CHARACTERS and the data..

For instance;

SQL> alter session set nls_numeric_characters = '.,';
Session altered.

SQL> select to_number( '10,10' ) from dual;
select to_number( '10,10' ) from dual
                  *
ERROR at line 1:
ORA-01722: invalid number
---

So setting the LANG was a good idea and it solved our issue.

How did we make Weblogic get our LANG setting ?

Well, we set it in the setDomainEnv.sh

In our case, we set "export LANG=tr_TR.ISO-8859-9" and restarted the Admin server..

startWeblogic.sh already calls setDomainEnv.sh for setting the related env variable..

That's it.. 

No comments :

Post a Comment

If you will ask a question, please don't comment here..

For your questions, please create an issue into my forum.

Forum Link: http://ermanarslan.blogspot.com.tr/p/forum.html

Register and create an issue in the related category.
I will support you from there.