generator-jhipster: Failed to deploy in a different context to root

Overview of the issue

With authenticationType session:

  • When I deploy a project in Tomcat 10.1.10 it´s run OK, but when I try login with admin / admin I get 200 OK but browser show public page and don´t show private pages with admin menu.
  • With ./mvnw -Pprod the login process it´s work OK

With authenticationType jwt:

- 2023-06-13T11:31:17.436+02:00  WARN 238448 --- [nio-8080-exec-7] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' is not supported]
2023-06-13T11:31:17.437+02:00 ERROR 238448 --- [nio-8080-exec-7] o.s.b.w.servlet.support.ErrorPageFilter  : Cannot forward to error page for request [/api/authenticate] as the response has already been committed. As a result, the response may have the wrong status code. If your application is running on WebSphere Application Server you may be able to resolve this problem by setting com.ibm.ws.webcontainer.invokeFlushAfterService to false
  • With ./mvnw -Pprod the login process it´s work OK
Motivation for or Use Case

Deploy in external Tomcat 10.1.10

Reproduce the error
  1. Install Jhipster v8.0.0-beta.1
  2. Generate a monolithic app
  3. Convert to .war with this steps for angular: https://www.jhipster.tech/production/#building-an-executable-jar--war-file
  • Modify the pom.xml to change the application packaging to war like:
  -    <packaging>jar</packaging>
  +    <packaging>war</packaging>

  • Modify the pom.xml to change the scope of spring-boot-starter-undertow dependency to provided
  • Update the index.html with the proper base tag. Considering jhipster as the context path, base tag value should look like:
<base href="/foo/"/> 4. Generate with ./mvnw clean package -Pprod -DskipTests 5. Copy .war with: cp foo-0.0.1-SNAPSHOT.war.original ../../apache-tomcat-10.1.10/webapps/foo.war 6. Start Tomcat 7. Acces to http://localhost:8080/foo/ it´s OK 8. Try login with admin / admin
Related issues
Suggest a Fix

Maybe the code generated by jhipster is not compatible with the new versions of spring security https://docs.spring.io/spring-security/reference/5.8/migration/servlet/config.html

JHipster Version(s)

v8.0.0-beta.1

JHipster configuration
JDL definitions
application {
  config {
    applicationType monolith,
    baseName foo,
    packageName com.foo,
    jhiPrefix gsr,
    authenticationType session,
    databaseType sql,
    devDatabaseType h2Disk,
    prodDatabaseType oracle,
    enableHibernateCache true,
    cacheProvider ehcache,
    buildTool maven,
    testFrameworks [cypress, gatling, cucumber],
    clientFramework angular,
    enableTranslation true,
    nativeLanguage es,
    languages [es, en]
  }
  entities *
}
  
Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

Firefox 113.0.2 (64-bit) Ubuntu 22.04 openjdk version “17.0.7” 2023-04-18

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (23 by maintainers)

Most upvoted comments

I’ll add a bug bounty in hopes that someone can figure out how to fix this.

I tried modifying index.html to have <base href="/foo/" /> and I added the following to application.yml:

server:
  servlet:
    context-path: /foo

I’m able to reproduce your problem, but I don’t know how to fix it.

I thought it might be a CORS issue since no CORS registration was printed to the console. Changing the filter to a CorsConfigurationSource makes the registration print to the console, but it still doesn’t work. I tried disabling CORS, and that doesn’t work either.

I’ll re-open this issue in hopes that someone else knows how to fix it.