3

I'm using tomcat7-maven-plugin to run my application (tomcat7:run). I was using <uriEncoding>utf-8</uriEncoding> in configurations without https and everything was working fine. But once I added https the encoding stopped working.

When I make a request like this on client: https://localhost:8443/ROOT/checkName?mediaName=%C3%A7%C3%A7

I receive this on server: çç

Here is some of my pom.xml:

            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    <path>/${project.warname}</path>
                    <warFile>target/${project.warname}##${maven.build.timestamp}-${project.name}-v${project.version}</warFile>
                    <uriEncoding>utf-8</uriEncoding>

                    <!-- HTTPS -->
                    <httpsPort>8443</httpsPort>
                    <keystoreFile>${user.home}/.mvnkeystore</keystoreFile>
                    <keystorePass>changeit</keystorePass>
                    <!-- HTTPS -->

                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.25</version>
                    </dependency>
                    <dependency>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-core</artifactId>
                        <version>${tomcat.version}</version>
                    </dependency>
                </dependencies>
            </plugin>

And web.xml:

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>securedapp</web-resource-name>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

If I remove https tags, the uriEncondig starts working again.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
Filipe Roberto
  • 339
  • 4
  • 16

2 Answers2

3

It is a reported bug of the Apache Tomcat Maven Plugin - MTOMCAT-264. There is an open PR in github to fix it.

You can probably workaround it by using serverXml parameter with the caveat mentioned in the documentation.

serverXml: server.xml to use Note if you use this you must configure in this file your webapp paths.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
  • @Abdelhak Do you think it was a [good answer](http://stackoverflow.com/a/34672502/1700321)? I will remove downvote if you improve it. No point in downvoting my answers for retaliation. – Aleksandr M Jan 08 '16 at 10:39
  • Any update on this? Seems to be open for a long time now – Cybermonk Dec 30 '18 at 04:26
1

I think you need to configure the HTTPS connector - in the server .See here related question. The fact that you assign a value on the httpsPort property, means that you just enable the connector (with some defaults I guess) - as the plugin documentation suggests.

You need to configure the connector with the following:

<Connector port="443" protocol="HTTP/1.1"
           maxThreads="150" connectionTimeout="20000"
           SSLEnabled="true" scheme="https" secure="true"
           keystoreFile="conf/.keystore"
           keystorePass="changeit"
           clientAuth="false" sslProtocol="TLS"
           URIEncoding="UTF-8" compression="on"/>

Hope it helps

Community
  • 1
  • 1
javapapo
  • 1,342
  • 14
  • 26