I have created a PHP script to start/stop GlassFish server. In the PHP, I am using the shell_exec method to execute the start-domain and stop-domain commands.
To start the server
shell_exec("sudo -u root /usr/local/glassfish3/bin/asadmin start-domain domain1");
To stop the server
shell_exec("sudo -u root /usr/local/glassfish3/bin/asadmin stop-domain domain1");
While the script does start and stop the server, there is an issue I can't figure out. The character encoding changes to something different and the special characters coming from the client requests are no longer formatted correctly.
Characters with correct charset
Characters with incorrect charset
Seems that the settings for UTF-8 are getting ignored and it falls back to a different charset what I believe to "ISO-8859-1".
<jdbc-connection-pool connection-validation-method="auto-commit" ...> <property name="characterEncoding" value="UTF-8"></property> </jdbc-connection-pool>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd"> <sun-web-app error-url=""> <context-root>/some-directory-war</context-root> <class-loader delegate="true"/> <jsp-config> <property name="keepgenerated" value="true"> <description>Keep a copy of the generated servlet class java code.</description> </property> </jsp-config> <!-- Change the default character encoding from ISO-8859-1 to UTF-8 --> <parameter-encoding default-charset="UTF-8"/> </sun-web-app>
During my investigation I found numerous articles stating to define the character set in the sun-web.xml (older version of glassfish - my case) but does not help.
After some testing, I have noticed that if I login with www-data in the console, the default shell used is /bin/sh and starting the domain from that causes the same issue. However, if I switch to /bin/bash, then it works.
Does anyone have a clue what could be the difference?
Any information on this will be much appreciated!