Foren

Problems with character encoding in LR 6.2 Portal

Klaus Bachmaier, geändert vor 7 Jahren.

Problems with character encoding in LR 6.2 Portal

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
We've set up two very similar (I hope identical) Liferay servers. One non production and one production server. Each server is connected to a MS SQL Server database, both DB-schemes reside inside the same database server. While on the non production server all UTF-8 characters show up, there are problems with these characters on the production server.

Of course first thing to check was the database collation. On both databases it's set to SQL_Latin1_General_CP1_CI_AS. Also the collations of distinct tables I've checked, like JournalArticle are the same.

Next thing I've checked are CATALINA_ OPTS in setenv.bat. Both servers have -Dfile.encoding=UTF8 in their CATALINA_OPTS string.

The Liferay pages on both servers have the correct content-type setting in the <head> portion of the page:

<meta content="text/html; charset=UTF-8" http-equiv="content-type">

Just to give some more Background:

- Both servers start as Windows services
- Both servers ar behind an IIS webserver, which acts as a reverse proxy
- I can insert special characters directly to the database tables on both databases, and they are shown correctly when I retrieve them with select commands in SQL Management Studio. So characters are stored correctly in the tables. But when read out by Liferay they are displayed wrong in the portal (as a black square with the question mark)

"encoding" properties are the same on both servers:

file.encoding UTF-8
file.encoding.pkg sun.io
sun.io.unicode.encoding UnicodeLittle
sun.jnu.encoding Cp1252

The only difference I'm aware of is that on the production server I accidently let the Java updater update the Java version. It's now 1.8.0_91 on the prod. server and 1.8.0_73 on the non prod. server.

Any hints on how I may getr UTF-8 characters working on the production server?
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: Problems with character encoding in LR 6.2 Portal

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
On of my clients has modified the web.xml under TOMCAT_HOME/webapps/ROOT/WEB-INF and added the last filter as the following --

<filter>
         <filter-name>SetCharacterEncoding</filter-name>
         <filter-class>
                   org.apache.catalina.filters.SetCharacterEncodingFilter
          </filter-class>
          <init-param>
                    <param-name>encoding</param-name>
                   <param-value>UTF-8</param-value>
         </init-param>
 </filter>


Which I believe they did to solve problems that they were having with UTF8 stuff. Can you give that a shot and let us know if it helps?
Klaus Bachmaier, geändert vor 7 Jahren.

RE: Problems with character encoding in LR 6.2 Portal

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
I tried it, but unfortunately without success. Thank you anyway. But because the non-production server also doesn't have the filter applied, and there UTF-8 characters are displayed correctly there must be another difference between the servers. But I still have no idea where this difference may be.
Klaus Bachmaier, geändert vor 7 Jahren.

RE: Problems with character encoding in LR 6.2 Portal (Antwort)

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
OK, solved!

As mention earlier, I accidently upgraded Java on the prod.-server. Therefore I had to re-register Liferay as a service under Windows, because due to the Java Upgrade JRE_Home had changed. I used exactly the same batch file as before when I registed Liferay as a service on prod. and non-prod. servers. I turns out that with my new Java version I had to explicitely add the character encoding to the JvmOptions when registering the service. This hasn't been nessecary before.
thumbnail
Andrew Jardine, geändert vor 7 Jahren.

RE: Problems with character encoding in LR 6.2 Portal

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hah! Well done Klaus -- I'll bet they said something about it in the release notes, but release notes are like the instructions that come with a new toy. It makes you feel good that they are AVAILABLE, but it's not like you're going to actually READ them emoticon.

Could you share with us the final set of JVM Options that you used so as to save the next person who has this problem, and comes across your thread, the trouble of seeking it out?
Klaus Bachmaier, geändert vor 7 Jahren.

RE: Problems with character encoding in LR 6.2 Portal

Regular Member Beiträge: 223 Beitrittsdatum: 30.09.13 Neueste Beiträge
That's the whole batch file I've used to register my service. The relevat line is line 148:

@echo off

rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                Install the service using Tomcat7 as service name.
rem                        Service is installed using default settings.
rem remove                 Remove the service from the System.
rem
rem name        (optional) If the second argument is present it is considered
rem                        to be new service name
rem ---------------------------------------------------------------------------

setlocal

set "SELF=%~dp0%service.bat"
rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%cd%"
if exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHome
rem CD to the upper dir
cd ..
set "CATALINA_HOME=%cd%"
:gotHome
if exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHome
echo The tomcat7.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
:okHome
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJdkHome
if not "%JRE_HOME%" == "" goto gotJreHome
echo Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
echo Service will try to guess them from the registry.
goto okJavaHome
:gotJreHome
if not exist "%JRE_HOME%\bin\java.exe" goto noJavaHome
if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome
goto okJavaHome
:gotJdkHome
if not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHome
if not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHome
if not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHome
if not "%JRE_HOME%" == "" goto okJavaHome
set "JRE_HOME=%JAVA_HOME%\jre"
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK not a JRE
goto end
:okJavaHome
if not "%CATALINA_BASE%" == "" goto gotBase
set "CATALINA_BASE=%CATALINA_HOME%"
:gotBase

set "EXECUTABLE=%CATALINA_HOME%\bin\tomcat7.exe"

rem Set default Service name
set SERVICE_NAME=Liferay62
set DISPLAYNAME=Liferay Portal Server 6.2 %SERVICE_NAME%

if "x%1x" == "xx" goto displayUsage
set SERVICE_CMD=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
:checkUser
if "x%1x" == "x/userx" goto runAsUser
if "x%1x" == "x--userx" goto runAsUser
set SERVICE_NAME=%1
set DISPLAYNAME=%1
shift
if "x%1x" == "xx" goto checkServiceCmd
goto checkUser
:runAsUser
shift
if "x%1x" == "xx" goto displayUsage
set SERVICE_USER=%1
shift
runas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"
goto end
:checkServiceCmd
if /i %SERVICE_CMD% == install goto doInstall
if /i %SERVICE_CMD% == remove goto doRemove
if /i %SERVICE_CMD% == uninstall goto doRemove
echo Unknown parameter "%SERVICE_CMD%"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name] [/user username]
goto end

:doRemove
rem Remove the service
echo Removing the service '%SERVICE_NAME%' ...
echo Using CATALINA_BASE:    "%CATALINA_BASE%"

"%EXECUTABLE%" //DS//%SERVICE_NAME% ^
    --LogPath "%CATALINA_BASE%\logs"
if not errorlevel 1 goto removed
echo Failed removing '%SERVICE_NAME%' service
goto end
:removed
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:    "%CATALINA_HOME%"
echo Using CATALINA_BASE:    "%CATALINA_BASE%"
echo Using JAVA_HOME:        "%JAVA_HOME%"
echo Using JRE_HOME:         "%JRE_HOME%"

rem Try to use the server jvm
set "JVM=%JRE_HOME%\bin\server\jvm.dll"
if exist "%JVM%" goto foundJvm
rem Try to use the client jvm
set "JVM=%JRE_HOME%\bin\client\jvm.dll"
if exist "%JVM%" goto foundJvm
echo Warning: Neither 'server' nor 'client' jvm.dll was found at JRE_HOME.
set JVM=auto
:foundJvm
echo Using JVM:              "%JVM%"

set "CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar"
if not "%CATALINA_HOME%" == "%CATALINA_BASE%" set "CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"

"%EXECUTABLE%" //IS//%SERVICE_NAME% ^
    --Description "Liferay Portal Server 6.2 " ^
    --DisplayName "%DISPLAYNAME%" ^
    --Install "%EXECUTABLE%" ^
    --LogPath "%CATALINA_BASE%\logs" ^
    --StdOutput auto ^
    --StdError auto ^
    --Classpath "%CLASSPATH%" ^
    --Jvm "%JVM%" ^
    --StartMode jvm ^
    --StopMode jvm ^
    --StartPath "%CATALINA_HOME%" ^
    --StopPath "%CATALINA_HOME%" ^
    --StartClass org.apache.catalina.startup.Bootstrap ^
    --StopClass org.apache.catalina.startup.Bootstrap ^
    --StartParams start ^
    --StopParams stop ^
    --JvmOptions "-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Dfile.encoding=UTF8;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" ^
    --JvmMs 2048 ^
    --JvmMx 2048
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
echo The service '%SERVICE_NAME%' has been installed.

:end
cd "%CURRENT_DIR%"