SQLException: Charset cp850/Cp850 is not supported by the JVM.
I recently had to reinstall Tomcat on my development server at work, because my previous installation was having major issues for unknown reasons. When I finished installing it, and deploying my webapps to it, I ran into this annoying character set issue (which I was not getting with the previous installation).
I could swear I’d seen this message before, and several of my co-workers thought they recognized it, too, but nobody knew what to do about it. Every time I started the tomcat service, it was spitting out these three stack traces, for every webapp, in my exception log:
Class: net.sourceforge.jtds.jdbc.ConnectionJDBC2
Method: loadCharset
SQL STATE: 2C000
SQL ERROR CODE: 0
STACKTRACE:
java.sql.SQLException: Charset cp850/Cp850 is not supported by the JVM.
[...]
Class: org.apache.catalina.valves.JDBCAccessLogValve
Method: start
EXCEPTION WRAPPER MESSAGE:
[ERROR] ContainerBase.addChild: start:
STACKTRACE:
LifecycleException:
java.sql.SQLException: Charset cp850/Cp850 is not supported by the JVM.
[...]
Class: org.apache.catalina.core.ContainerBase
Method: addChildInternal
EXCEPTION WRAPPER MESSAGE:
[ERROR] Error deploying web application archive [foo].war
STACKTRACE:
java.lang.IllegalStateException: ContainerBase.addChild: start:
LifecycleException: java.sql.SQLException:
Charset cp850/Cp850 is not supported by the JVM.
[...]
NOTE: These stack traces only show the top line and context info, to avoid cluttering up the blog post too much. [View full stack traces here]
To troubleshoot this, I first tried cleaning out all the already-compiled classes/jars from my source code tree, and rebuilding/redeploying all the webapps, but the same behavior continued. Next, I wiped out my whole source code tree, checked it all out from CVS again, and rebuilt/redeployed all the webapps. Still got the stupid cp850 exceptions.
Before, during, and after all of that rebuilding stuff, I spent hours doing web searches on various search engines, tweaking my queries, and not turning up much of anything.
At one point, it seemed like it had to be a problem with my Sybase ASE 12.5 database configuration. I didn’t like the sound of that, though, because it’s much easier to reinstall an app server and redeploy my webapps, than it is to rebuild my database and recreate the necessary test data.
I thought maybe our build script wasn’t deploying the right versions of all the jars that needed to be deployed, so I slowly started copying the jars from my backup of my previous tomcat installation, and copying all the configuration files, and so forth. Eventually, my entire tomcat directory tree had been replaced with the backed-up tomcat installation, but the evil cp850 exceptions still lingered!
Now it was *really* looking like a database issue! I searched all the files on the machine for ‘cp850′ (case-insensitive search), and turned up nothing useful. When I searched the windows registry, I found one thing that was intriguing:
KEY: HKEY_LOCAL_MACHINE\
SOFTWARE\SYBASE\Server\
[MyServerName]_BS\Parameters\
VALUE NAME: Arg5
VALUE TYPE: REG_SZ
VALUE DATA: -Jcp850
I asked my co-workers to check their registries, but they had the same thing, and their servers were behaving just fine. Besides, this was just the backup server (BCKServer), not the actual SQLServer. So that was a dead end.
I poked around for a while longer, and *finally* figured out that it was the JVM that the Tomcat service was configured to use. When installing it, I had chosen the default JVM that it had selected, because it looked right.
The installer defaulted to the JVM that was installed with the Java plugin for web browsers and such:
C:\Program Files\Java\jre1.5.0_06\bin\server\jvm.dll
But I needed to use the one that was installed with the JDK I compiled with:
C:\Program Files\Java\jdk1.5.0_06\jre\bin\server\jvm.dll
I believe the reason for this is because when I downloaded the JDK, it either only came in one package, which included international support, or I happened to choose the package that included international support. For the Java plugin download, though, I must have selected the US/English-only package, because it was smaller or something.
That was a nightmare to track down, and I hope that by posting this, I can save someone else the time and trouble!


July 3rd, 2007 at 2:08 pm
Oh God. This reminds me of why I find Java so unenjoyable to program in compared to some other languages. The promise of “Write once, run anywhere” just never fully delivered. (my slime volleyball mysteriously stopped working when I upgraded to a new java … sorta defeats the purpose!)
I also think unicode is creating all kinds of problems.
Like “Evil apostrophes”. Oh, they may show up the same in EditPlus / Notepad. But they aren’t the same. There are like 3 or 4 different apostrophes. quotes too. hyphens too.
I had to globally fix all this CDATA in a bazillion files in 10 folders. I kept replacing all ” and ‘ with quot; and apos; … and also ‘ with - … and saying it was globally done.
and yet, we kept finding more
turns out, when copying from word, dreamweaver, and other programs, the “-” you get is not ASCII. it’s some freakin’ unicode character. There are like at least 2 hyphens, 3 apostrophes, and 3 quotes.
real freakin’ annoying because many displayed on the screen exactly identically to the other.
so now, global search and replace isn’t good enough. thanks to unicode. grrrrrrr.
I hate when so-called progress actually makes things harder.
October 17th, 2007 at 1:30 pm
Soooo helpful — after 3 days of searching and searching.
October 26th, 2007 at 1:46 am
Hi,
Thanks for your Story,
This saved my time other wise this SQL Exception(evil) might have caught me.
Regards,
Vijay.
March 17th, 2008 at 10:15 am
Hey Dave,
I´d like to thanks you for writing down this help.
Take care,
Johniee
November 15th, 2008 at 3:32 am
Thanks 4 ur help….
November 26th, 2008 at 7:12 pm
That was SO helpful. Many, many thanks.