Search code examples
javaopenidjboss7.xopenshift

Change URIEncoding in OpenShift JBoss AS 7


I am building an testing app with Spring Security using the OpenId module. I also use the jQuery OpenId plugin to support some providers.

I am testing the app with Tomcat (version 7) and after a little bit of troubleshooting I found that I need to specify the URI encoding for the server in order to support users whose credentials have tilded letters and vowels e.g. Peñasco, Ángel, etc.

In Tomcat I just have to set this to the tomcat-server.xml file:

<Connector URIEncoding="UTF-8" SSLEnabled="true" .../>

But the app is being deployed in a JBoss AS 7 cartridge on the OpenShift PaaS.

How can I put the analog configuration in this case?

EDIT:

I added the file .openshift / action_hooks / pre_start_jbossas-7 with this contents:

#!/bin/bash

# Need to set URI encoding to UTF-8 because of Spring Security OpenID module needs it for tilded letters e.g. ñ, Á

export JAVA_OPTS=" -Dorg.apache.catalina.connector.URI_ENCODING=\"UTF-8\" -Dorg.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING=true"

But it does not work remotely, I used the same options with the local server and it doesn't work.


Solution

  • In JBoss AS7, you can configure this functionality using system properties:

    -Dorg.apache.catalina.connector.URI_ENCODING="UTF-8"
    -Dorg.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING="true"
    

    For reference, see: https://community.jboss.org/message/643825#643825

    You can also set these in the <system-properties> section of standalone.xml, but on OpenShift this file is not controlled by your application. For an OpenShift app you will need to start JBoss with these options by setting JAVA_OPTS in your application's pre-start hook. To do this, add the following to the .openshift/action-hooks/pre_start_jbossas-7 file:

    export JAVA_OPTS="$JAVA_OPTS -Dorg.apache.catalina.connector.URI_ENCODING=\"UTF-8\" \
                      -Dorg.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING=\"true\""
    

    Hope this helps. Please leave a comment if you run into issues.