• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

java.io.CharConversionException when reading a string of characters from database

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm running Tomcat 5 and using OpenJDK Runtime Environment (IcedTea6 1.7.10) (rhel-1.21.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode) on CentOS and recently came across one weird problem that I suspect is a JDK bug.

When I read from a mysql database, a field called randomid that is made up of a series of random characters (lower case letters, uppercase letters and numbers) such as SRM1iq1 or FRG6rx2 or XGC6gs7

I get

SEVERE: Servlet.service() for servlet jsp threw exception
java.io.CharConversionException
at gnu.gcj.convert.Input_iconv.read(libgcj.so.7rh)
at java.lang.String.init(libgcj.so.7rh)
at java.lang.String.<init>(libgcj.so.7rh)
at com.mysql.jdbc.SingleByteCharsetConverter.<init>(SingleByteCharsetConverter.java:153)
at com.mysql.jdbc.SingleByteCharsetConverter.initCharset(SingleByteCharsetConverter.java:108)
at com.mysql.jdbc.SingleByteCharsetConverter.getInstance(SingleByteCharsetConverter.java:86)
at com.mysql.jdbc.ConnectionImpl.getCharsetConverter(ConnectionImpl.java:2767)
at com.mysql.jdbc.ResultSetRow.getString(ResultSetRow.java:754)
at com.mysql.jdbc.ByteArrayRow.getString(ByteArrayRow.java:67)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5557)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5434)
at org.apache.jsp.main_jsp._jspService(main_jsp.java:1160)
at org.apache.jasper.runtime.HttpJspBase.service(jasper5-runtime-5.5.23.jar.so)
at javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.23.jar.so)
at org.apache.jasper.servlet.JspServletWrapper.service(jasper5-compiler-5.5.23.jar.so)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(jasper5-compiler-5.5.23.jar.so)
at org.apache.jasper.servlet.JspServlet.service(jasper5-compiler-5.5.23.jar.so)
at javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.23.jar.so)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(catalina-5.5.23.jar.so)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(catalina-5.5.23.jar.so)
at org.apache.catalina.core.StandardWrapperValve.invoke(catalina-5.5.23.jar.so)
at org.apache.catalina.core.StandardContextValve.invoke(catalina-5.5.23.jar.so)
at org.apache.catalina.core.StandardHostValve.invoke(catalina-5.5.23.jar.so)
at org.apache.catalina.valves.ErrorReportValve.invoke(catalina-5.5.23.jar.so)
at org.apache.catalina.core.StandardEngineValve.invoke(catalina-5.5.23.jar.so)
at org.apache.catalina.connector.CoyoteAdapter.service(catalina-5.5.23.jar.so)
at org.apache.coyote.http11.Http11Processor.process(tomcat-http-5.5.23.jar.so)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(tomcat-http-5.5.23.jar.so)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(tomcat-util-5.5.23.jar.so)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(tomcat-util-5.5.23.jar.so)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(tomcat-util-5.5.23.jar.so)
at java.lang.Thread.run(libgcj.so.7rh)

Works perfectly on the development machine that is running Tomcat5 and a different version of JDK 6. The easy way out would be changing the JDK, but being a live running server, I'd rather think of something else.

Any ideas of how to maybe go around this problem (besides changing the random id?)

Thanks a bunch

Will
 
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at the stack trace, the error is nothing to do with the JDK or with the version of Tomcat. The error is that the database column in question can't be converted to chars using whatever charset is configured in MySQL and/or the Tomcat configuration and/or your Java code which sets up the database connection.

That doesn't match with your description of the field, which suggests you're just using innocuous ASCII characters, but perhaps that isn't actually the case?

Although there is this worrying line in the stack trace:

at gnu.gcj.convert.Input_iconv.read(libgcj.so.7rh)


which suggests that the problem might exist there...
 
William Farrugia
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply Paul.

You are right, but how do you explain the applic works on the development machine? Besides I double checked and the characters are A-Za-z0-9... so there shouldn't be any problems. The database is set to UTF in my.cnf....

not sure if this is my case http://bugs.mysql.com/bug.php?id=29636
 
Paul Clapham
Marshal
Posts: 28296
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may be right... I haven't heard good things about GNU Java so perhaps it is a JDK problem.
 
Destroy anything that stands in your way. Except this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic