Reputation: 5141
I have developed a web application using Intellij IDEA and I have used the IDE's Build functions to generate a WAR file. My application's web.xml contains the following code segment:
<security-constraint>
<web-resource-collection>
<web-resource-name>sslTestApp</web-resource-name>
<url-pattern>*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
so that every page in my application is secured with SSL.
I have also used keytool
and I have enabled HTTPS on port 8443 in conf/server.xml
as described on the official Tomcat documentation.
When I launch the project from the IDE it runs just fine with SSL enabled on port 8443 but if I place the .war file in tomcat's webapps directory, restart the server and navigate to https://localhost:8443/testApplication
, I get an ERR_TIMED_OUT
error.
If I edit the deployed application's web.xml and remove the above segment, thus allowing the application to run on the default port 8080, the application runs smoothly.
So, with Intellij both ports work, but if I manually deploy the application only 8080 works properly. Have I missed something?
Upvotes: 1
Views: 3360
Reputation: 2582
It seems that the difference between IntellijIdea deployment and manual is the context path of your application. Intellij idea run the application by default as root application so yo can access without context path.
Try to modify url-pattern to this /testApplication/*
on your web.xml, build your war artifact and deploy it manually to Tomcat
<web-resource-collection>
<web-resource-name>sslTestApp</web-resource-name>
<url-pattern>/testApplication/*</url-pattern>
</web-resource-collection>
Upvotes: 1
Reputation: 5141
Just in case someone else might be facing the same issue, the solution was to explicitly set the key's location and the key alias in server.xml
like this:
<Connector port="8443" protocol="HTTP/1.1"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" keystoreFile="C:\mykeystore"
keyAlias="mykey"
clientAuth="false" keystorePass="yourPassword" sslProtocol="TLS" />
Upvotes: 1