Generator-jhipster: Migrating to Undertow (again)

Created on 1 Sep 2016  Â·  20Comments  Â·  Source: jhipster/generator-jhipster

Undertow looks more efficient than Tomcat, we already performed various tests and it seems to have better performance and consume less resources.

We tried migrating a few months ago - see #2948 - but failed because we had issues on Windows.

I would like to test this again, as:

  • Spring Boot 1.4 comes with Tomcat 8, which has an annoying issue - see #3995 - so we might as well migrate to Undertow
  • We have new versions of Spring Boot, Undertow, etc, so maybe the bug isn't here anymore.

I commited my tests on branch test-undertow and:

  • Normal project works: running with Maven and or Gradle, running as an executable WAR file, dev and prod profile both work...
  • Websockets work

I can't test the Windows issue as I've got a Mac, can anybody test this, and validate that the issue we had at #2948 is over?

area

Most helpful comment

@gmarziou yes I tried Websockets both with Maven and Gradle, everything works!
@pascalgrimaud thanks for your tests!
@atomfrede thanks for correcting the Gradle build

I'm merging this, we have no issues left!

All 20 comments

Ok ill try to test it tonight on windows

Thanks & regards,
Deepu

On 2 Sep 2016 03:30, "Julien Dubois" [email protected] wrote:

Undertow looks more efficient than Tomcat, we already performed various
tests and it seems to have better performance and consume less resources.

We tried migrating a few months ago - see #2948
https://github.com/jhipster/generator-jhipster/issues/2948 - but failed
because we had issues on Windows.

I would like to test this again, as:

I commited my tests on branch test-undertow
https://github.com/jhipster/generator-jhipster/tree/test-undertow and:

  • Normal project works: running with Maven and or Gradle, running as
    an executable WAR file, dev and prod profile both work...
  • Websockets work

I can't test the Windows issue as I've got a Mac, can anybody test this,
and validate that the issue we had at #2948
https://github.com/jhipster/generator-jhipster/issues/2948 is over?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/4054, or mute the
thread
https://github.com/notifications/unsubscribe-auth/ABDlF5y75enmWTn7yx22__-OuNkAsQ0Aks5qlzeNgaJpZM4JzGuy
.

Thanks Deepu! That would be a pretty big update!
I'm waiting for this for the next release.

@jdubois good news :) undertow seems to be working well on windows for both bootrun and java -jar with maven. I havent tried gradle yet but i'm 100% confident that it will work since it worked for you and maven works for me. The only thing to be checked is if things are fine when run as main class from IDE

I will test on Linux and with Docker configuration too

OK this looks like we're going to do it this time!

I'm notifying @stuartwdouglas as he's the main Undertow contributor -> Stuart, we're going to bring you quite a lot users, you can ask @gunnarmorling about it :-)

Nice

I got 1 issue with this configuration (gradle + websocket), by starting with ./gradlew :

{
  "generator-jhipster": {
    "jhipsterVersion": "3.6.1",
    "baseName": "jhgradle",
    "packageName": "io.github.pascalgrimaud",
    "packageFolder": "io/github/pascalgrimaud",
    "serverPort": "8080",
    "authenticationType": "session",
    "hibernateCache": "ehcache",
    "clusteredHttpSession": "no",
    "websocket": "spring-websocket",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": "no",
    "buildTool": "gradle",
    "enableSocialSignIn": false,
    "rememberMeKey": "47366938fffd2affb9e206d461505a0ec0a0d981",
    "useSass": false,
    "applicationType": "monolith",
    "testFrameworks": [
      "gatling"
    ],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }
}

Here the error in log, after I log with "admin":

2016-09-03 19:25:00.382 ERROR 18832 --- [ XNIO-2 task-20] io.undertow.request                      : UT005023: Exception handling request to /websocket/tracker/745/fyk4le4s/websocket

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/websocket/tracker/745/fyk4le4s/websocket; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.ClassCastException: io.undertow.websockets.jsr.ServerWebSocketContainer cannot be cast to org.apache.tomcat.websocket.server.WsServerContainer
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
        at com.codahale.metrics.servlet.AbstractInstrumentedFilter.doFilter(AbstractInstrumentedFilter.java:104)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.boot.actuate.trace.WebRequestTraceFilter.doFilterInternal(WebRequestTraceFilter.java:105)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:317)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127)
        at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:115)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:158)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:169)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:63)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:200)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:121)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at io.github.pascalgrimaud.web.filter.CsrfCookieGeneratorFilter.doFilterInternal(CsrfCookieGeneratorFilter.java:34)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:100)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331)
        at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:214)
        at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:177)
        at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
        at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
        at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
        at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
        at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
        at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
        at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
        at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
        at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
        at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
        at io.undertow.servlet.handlers.SessionRestoringHandler.handleRequest(SessionRestoringHandler.java:119)
        at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:285)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:264)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:175)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:802)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.web.socket.sockjs.SockJsException: Uncaught failure in SockJS request, uri=http://localhost:8080/websocket/tracker/745/fyk4le4s/websocket; nested exception is org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.ClassCastException: io.undertow.websockets.jsr.ServerWebSocketContainer cannot be cast to org.apache.tomcat.websocket.server.WsServerContainer
        at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:135)
        at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:51)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        ... 96 common frames omitted
Caused by: org.springframework.web.socket.sockjs.SockJsTransportFailureException: WebSocket handshake failure; nested exception is java.lang.ClassCastException: io.undertow.websockets.jsr.ServerWebSocketContainer cannot be cast to org.apache.tomcat.websocket.server.WsServerContainer
        at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:122)
        at org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService.handleTransportRequest(TransportHandlingSockJsService.java:306)
        at org.springframework.web.socket.sockjs.support.AbstractSockJsService.handleRequest(AbstractSockJsService.java:433)
        at org.springframework.web.socket.sockjs.support.SockJsHttpRequestHandler.handleRequest(SockJsHttpRequestHandler.java:132)
        ... 100 common frames omitted
Caused by: java.lang.ClassCastException: io.undertow.websockets.jsr.ServerWebSocketContainer cannot be cast to org.apache.tomcat.websocket.server.WsServerContainer
        at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:85)
        at org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy.getContainer(TomcatRequestUpgradeStrategy.java:48)
        at org.springframework.web.socket.server.standard.AbstractStandardUpgradeStrategy.getSupportedExtensions(AbstractStandardUpgradeStrategy.java:88)
        at org.springframework.web.socket.server.support.AbstractHandshakeHandler.doHandshake(AbstractHandshakeHandler.java:272)
        at org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler.handleRequest(WebSocketTransportHandler.java:118)
        ... 103 common frames omitted

Strange, I don't have this with Maven -> might be a dependency issue.

Another note: we also need to test if gzip compression is working in prod mode.

I didnt see this with maven as well. I'll check gradle tomorrow

Thanks & Regards,
Deepu

On Sat, Sep 3, 2016 at 11:03 PM, Julien Dubois [email protected]
wrote:

Strange, I don't have this with Maven -> might be a dependency issue.

Another note: we also need to test if gzip compression is working in prod
mode.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/4054#issuecomment-244559377,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlF2MFR-ytIxzu4pcYR8wJ8O-kZhJDks5qma-FgaJpZM4JzGuy
.

@deepu105 : It's the same error you had before. See https://github.com/jhipster/generator-jhipster/issues/2948#issuecomment-191097768

When using gradle tomcat is still in dependency tree. Adding

configurations {
    compile.exclude module: "spring-boot-starter-tomcat"
}

to build.gradle removes tomcat from dependencies.
EDIT: I have some issues with node/npm right now, so I can't test it, but I guess it wil resolve the error.

@atomfrede : should it be added here _build.gradle ?
[edit] forget my question :)

I think we have to modify these lines too:

About these 2 lines, should it be replaced by "undertow" or simply removed ?

@pascalgrimaud Yes should lines should be replaced with undertow or removed, not sure why tomcat is added there again to the dependencies. I guess thats the reason why tomcat was added to dependencies, also it was excluded from spring boot starter web. When printing the dependency tree tomcat was on root level and I was wondering why.

@atomfrede : thanks! it seems to resolve the stacktrace issue! I will PR all theses modifications to test-undertow branch

  • Sorry for the Tomcat exclusion in Gradle -> our conf is a bit different from Maven, so it looks I mixed up stuff here. Anyway, I see you solved it!
  • I just tested GZip encoding in production, and it's working fine

-> I think we are good to go here!!!!!!! At least :-)

Here, all my tests (only on Linux), for maven/gradle and for dev/prod

  • IDE: start with main -> OK
  • launch mvnw or gradlew -> OK
  • launch with java -jar -> OK
  • docker build and launch the app inside Docker container -> OK
  • deploy the original war inside a Tomcat Server -> OK

Everythings look good to me

Ya lets do it

Thanks & regards,
Deepu

On 4 Sep 2016 13:48, "Pascal Grimaud" [email protected] wrote:

Here, all my tests (only on Linux), for maven/gradle and for dev/prod

  • IDE: start with main -> OK
  • launch mvnw or gradlew -> OK
  • launch with java -jar -> OK
  • docker build and launch the app inside Docker container
  • deploy the original war inside a Tomcat Server

Everythings look good to me

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/jhipster/generator-jhipster/issues/4054#issuecomment-244590039,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABDlF8094mIYMmGhP6FLHBvUYIE1c8oQks5qmn7sgaJpZM4JzGuy
.

Has anyone run a test with websockets? Because in this example, they exclude tomcat from dependency and so far we don't.

At least for gradle the global exclusion should remove tomcat completely.

@gmarziou yes I tried Websockets both with Maven and Gradle, everything works!
@pascalgrimaud thanks for your tests!
@atomfrede thanks for correcting the Gradle build

I'm merging this, we have no issues left!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RizziCR picture RizziCR  Â·  3Comments

marcelinobadin picture marcelinobadin  Â·  3Comments

pascalgrimaud picture pascalgrimaud  Â·  3Comments

chegola picture chegola  Â·  4Comments

DanielFran picture DanielFran  Â·  3Comments