jhipster / jhipster-registry

JHipster Registry, based on Spring Cloud Netflix Eureka and Spring Cloud Config
Apache License 2.0
698 stars 657 forks source link

JHipster Registry can't be accessed on Tomcat 9 #510

Closed emeraldhieu closed 2 years ago

emeraldhieu commented 3 years ago
Overview of the issue

JHipster can't be accessed when deployed on Tomcat 9

Motivation for or Use Case

I'd like to deploy JHipster Registry on Tomcat along with other services to reduce the amount of embeded container if using Spring Boot

Reproduce the error

1) Checkout jhipster-registry 2) Prepare "central-config" correctly in jhipster-registry 3) mvn clean package -DskipTests -Pprod 4) Copy the war file into Tomcat's webapps 5) Add this config to server.xml with the hope that I can access JHipster Registry via "localhost:8761"

  <Service name="jhipster-registry">

    <Connector port="8761" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

     <Engine name="Catalina" defaultHost="localhost">
        <Host name="localhost"  appBase="jhipster-registry"
          unpackWARs="true" autoDeploy="true">
        </Host>
     </Engine>
  </Service>

6) Start Tomcat 7) Logs look good; no error 8) Access http://localhost:8761 shows "HTTP 404 Not Found"

Related issues

Nothing

Suggest a Fix

I don't quite know.

JHipster Registry Version(s)

6.8.0

Browsers and Operating System

MacOS, Chrome

juliensadaoui commented 2 years ago

The JHipster-Registry is not adapt by default to work within Tomcat. It is a standalone Java application that can run as a desktop application or be configured as a system service.

Servlet containers like Tomcat expect the registry to meet some contracts to be deployed. You must initialize the Servlet context required by Tomcat by implementing the SpringBootServletInitializer interface.

You can see the follow implementation in generator : https://github.com/jhipster/generator-jhipster/blob/main/generators/server/templates/src/main/java/package/ApplicationWebXml.java.ejs