Vaadin 14 Embedded Jetty 9.4 + Spring boot do not persist session - spring

I have a project with Vaadin 14 + Spring Boot 2.4.5 which runs on the embedded Jetty / jetty-maven-plugin 9.4
In my current Setup, sessions get persisted. I did not configure this (knowingly) and I don't want it.
I found how to enable session persistence:
https://docs.huihoo.com/jetty/the-definitive-reference/using-persistent-sessions.html#enabling-persistence-for-jetty-maven-plugin
The default value should be no persistence but I find no hint how to get back to this.

The embedded Jetty is managed by Spring Boot. You can set server.servlet.session.persistent=false in application.properties to disable session persistence.

Related

Hibernate Search breaks with Spring Boot 2.3.0

When i migrated one of my Hibernate Search project from Spring Boot 2.2.7.RELEASE to 2.3.0.RELEASE, application started facing deadlock during the very startup.
I can not see any error in the logs either.
My sample project is here:
https://github.com/cancerian0684/listing-service
If i rollback Spring Boot 2.3.0 to 2.2.7, everything started working fine again. Is there a known issue in using Hibernate Search (tried both 5.x and 6.0.0.Beta8) with Spring Boot 2.3.0?
Spring Boot 2.3 switched to deferred JPA initialization and that leads to some issue, Hibernate Search being one of them. You should be able to get it back working using the following property
spring.data.jpa.repositories.bootstrap-mode=default
See this issue for some more context.

Liquibase Not Updating Spring Boot Web Application

I recently deployed a spring boot 1.4.0 web application and I noticed that liquibase did not perform an update. I have no problem with my spring boot 1.3.2 web application.
Was something introduced to Spring Boot 1.4.0 that would cause liquibase to not execute?
Tracked down the issue to liquibase-core package was not included in order to the Spring Boot autoconfigurations to execute.
It's not entirely clear why the liquibase-gradle-plugin did not include the required package.

Spring Session JDBC 1.2.0 in Spring Boot 1.3.5

when I use the spring session starter for spring boot 1.3.5 and set the version for spring session to 1.2 it comes to conflicts. Seems that it is not compatible and I have to wait for boot 1.4. OK...
To get it running I just added a dependency to spring session 1.2, without the starter and added a class which extends AbstractHttpSessionApplicationInitializer.
This works when I run it in an external tomcat but not when I run it in the embedded tomcat of boot 1.3.5.
Can I use SS 1.20 in SB 1.3.5?
Thank you
One step forward
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if(auth == null || !(auth.getPrincipal() instanceof UserDetailsImpl))
return null;
...
Here is always null returned although auth.getPrincipal() is an instance of UserDetailsImpl.
Seems to be a classloader issue.
But why does it work in an external tomcat? Any other classloading strategies here?
In short: yes, you can use Spring Session 1.2.x with Spring Boot 1.3.x without any problems.
Spring Session project contains many samples to help users get started with Spring Session (documentation on these samples is available here). Among these samples is also one that resembles your use case - Boot JDBC sample.
As shown in the samples and the docs you should use #EnableJdbcHttpSession annotation to bootstrap Spring Session JDBC support. If your app by any chance also uses Redis, you should exclude the SessionAutoConfiguration provided by Spring Boot 1.3 since your combination of dependencies will trigger the auto-configuration of Redis-backed Spring Session, which is something you don't want if you'd like to use JDBC-backed session store.

Tomcats RemoteIPValve not invoked in Spring Boot Application deployed as a WAR file

My Spring Boot 1.3.2 Application is deployed as a WAR file into a standalone tomcat7. I am trying to activate the RemoteIPValve using server.use-forward-headers=true as described in the spring boot docs.
But the RemoteIPValve is not properly configured nor invoked when handling the request. Log says:
NonEmbeddedServletContainerFactory detected.
When I start the application using the maven plugin I get a:
Initializing Spring embedded WebApplicationContext
... and RemoteIPValve is working as expected. How can I accomplish the same using WAR File deployment?
When you deploy a Spring Boot application to standalone Tomcat, none of the embedded server configuration takes effect. Instead, you need to update your Tomcat installation's configuration to enable the valve. To use the valve in its default configuration, add the following to server.xml:
<Valve className="org.apache.catalina.valves.RemoteIpValve"/>

How to set the logging level of embedded tomcat in Spring Boot?

How to set the logging level of embedded tomcat in Spring Boot?
Especially I need to see the tomcat clustering-related logs.
I added the following line to the application.properties, but tomcat seems to log only INFO level logs.
logging.level.org.apache.catalina=TRACE
Is there a simple method to accomplish this?
It would be best to know the Spring Boot and embedded tomcat-specific, simple solution, preferably only editing application.properties.
In short, use Spring Boot version 1.3.0 with Logback. (I was using Spring Boot 1.2.4)
Spring Boot 1.3.0 adds LevelChangePropagator to LogbackLoggingSystem.java (see this commit), thus the logging level that is set in application.properties is propagated to the jul(java.util.logging) which tomcat uses.
Otherwise, one must set the logging level for the logger in the logging.properties for the jul if the level is below the INFO level which is the default, AND also set the logging level for the logger in the application.properties. This is for the limitation of jul-to-slf4j module which cannot completely override jul implementation since jul is in the java.* package.
Also see the following Spring Boot issues: Optimize JUL logging #2585, Slf4JLoggingSystem should also configure JUL levels #2923.
And this is the related StackOverflow question: Spring Boot - set logging level of external jar which is using Java Util Logging (jul). Actually this is the problem I was facing.
(I will accept this answer if no better answer is posted for a few days from now.)

Resources