0

I faced that issue before, using Liferay POrtal, after I import lar file, any Arabic character and any special character like "♦" ruined to be question mark "?", and when I check Database, i see its stored like that too, I mean "?" .

Its explained here : Import .lar file issue on Encoding with Glassfish as Application Server

adding -DFile.encoding=UTF8 does not helped me.

AND Using Liferay itself with Arabic has no issues (like adding web content), retrieving data from DB is working well.

These days, I'm doing upgrade from liferay 5.2.8 to 6.1.20, i faced that issue again, all Arabic characters touched with upgrade (extracted to temp directory as a temp file then re-inserted to DB) got corrupted..

So its seemed to me this is issue with file system with Glassfish.

I tried Tomcat 7.0 and this issue not happened, and my data survived, but i need to solve it in Glassfish Application Server.

FYI: same issue with Glassfish v2.1.1 , v3.1.2.2 , and ML versions.

Any idea?

Community
  • 1
  • 1
Al-Mothafar
  • 7,266
  • 6
  • 68
  • 96

2 Answers2

1

Check what kind of encoding your database uses. The typical advice is to use UTF-8 for the database storage as well. Careful: When you check for correct characters in the database, your DB-tools might use a different encoding than the database itself. Sorry for the situation you're in, encoding issues are always a mess.

If you detect that your database uses a non-UTF-8 encoding, you might be lucky with specifying that encoding in the database connection string (depends on whatever database you're using), but you'd be lucky with this. You probably have a bit to repair - scripted or manually.

Olaf Kock
  • 45,059
  • 7
  • 56
  • 86
  • Thanks, But I don't think its DB issue, as I said same application (here its liferay) doing same batch in tomcat and glassfish, in tomcat no issue, in glassfish has issue, with same DB driver ! and DB ! and arabic chars stored correctly. – Al-Mothafar Jan 30 '13 at 11:33
  • also the same connection string? I.e. with regards to the encoding? For some reason I remember that glassfish had two DB-properties, "URL" and "Url" or similar - I don't know which of those takes precedence. – Olaf Kock Jan 31 '13 at 19:49
0

The -Dfile.encoding is a Oracle JVM specific setting how to read Java source files. This doesn't have any influence on the charset as specified in the Content-Type header of the HTTP response.

You can add the following to the file glassfish-web.xml (located in the WEB-INF folder):

<parameter-encoding default-charset="UTF-8"/>

If you have .jsp files try that in web.xml:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
</jsp-config>
unwichtich
  • 13,511
  • 3
  • 50
  • 65