Spring Session JDBC 1.2.0 in Spring Boot 1.3.5 - spring-boot

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.

Related

Can I just Upgrade springframwork to 5.3.18 to avoid CVE-2022-22965?

The spring published that:
I used spring 5.3.16, spring boot 2.2.10.RELEASE, spring cloud 2.2.10.RELEASE to use spring-cloud-netflix-zuul, so, can I just upgrade the spring version to 5.3.18, but don't upgrade other framwork?
Spring Boot 2.2.x is EOL and may contain other security fixes that affect you. Spring Boot 2.2.10.RELEASE use Spring Framework 5.2.9.RELEASE.
If you are using Spring Framework 5.3.x, this is not really a supported scenario irrespective of this CVE. You should be using Spring Framework 5.2.x. For that, we have released Spring Framework 5.2.20.
Of course, to be really safe you should upgrade to a supported version.

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

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.

Spring-Boot 1.5.10.release compatibility with apache-kafka-2.3.0 client

My project is built with Spring boot 1.5.10.release. We want to migrate to Apache Kafka® 2.3.0 from Apache Kafka 1.0.x.
We are currently using Spring-kafka 1.3.9.release and want to migrate to spring-kafka-2.3.0. Can we do this without changing the Spring boot version of 1.5.10.release?
I went through the Compatibility matrix but I don't see any relevant answer to my question
https://spring.io/projects/spring-kafka
No, you can't do that. Spring Kafka 2.x, as well Spring Boot 2.x, is based on Spring Framework 5.x and Java 8. You can't mix so critical versions in Spring Boot 1.5.x.
It is really better to rely on the Spring Boot dependencies management. That way you can be sure that all the artifacts brought by Spring Boot are tested together.

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.

Minimum version of spring for spring-boot v 1.3

I have an existing spring application built using spring framework version 3.1.2. I am trying to create a spring-boot application out of this existing application, but getting some dependency issues. So just wondering, what is the spring framework version, that is supported by spring-boot v 1.3.0.
Or to put it in another words, is it possible to have a spring-boot application from a spring 3.1.2 based application?
Spring boot has hard dependencies on classes in Spring 4 and could not be configured to work with Spring 3. If you are really interested in using Spring Boot the only way you can do this is to follow a migration path to Spring 4 and then add Spring Boot to your application.
It is worth mentioning that the "boot" in Spring Boot is meant to be short for bootstrapping, as in initial setup of an application. I'm not saying there would be zero benefits from migrating from Spring 4 vanilla to Spring Boot. But make sure you are migrating for the right reasons the main purpose of Spring Boot is easy bootstrapping of applications but here are some other features which might be worth making the move.
Spring Boot dev-tools (Auto restart on code changes)
Awesome spring boot plugins for maven and gradle to ease upgrading spring in the future (hint it upgrades many other dependencies for you)
Bootstrapping new features such as MongoDb through auto-configuration.
Migration from 3.1 to 3.2
https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/migration-3.2.html
Migration from Spring 3 to Spring 4.
https://spring.io/blog/2014/01/30/migrating-from-spring-framework-3-2-to-4-0-1
There are many features in spring boot that are dependent upon new features added to Spring 4. One primary example is the new list of annotations added to Spring 4 that allow conditional wiring/loading of beans. Which is the primary method of wiring configurations in a plugin-like way.
For example lets see the AutoConfiguration class for the H2 console
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java
The first thing we see is it's wired to be a Configuration class. It will only load if WebServlet.class is on the classpath and if the property spring.h2.console is = true. It is also configured to load SecurityAutoConfiguration first as this is a dependency at least for securing the h2 console page.
#Configuration
#ConditionalOnWebApplication
#ConditionalOnClass(WebServlet.class)
#ConditionalOnProperty(prefix = "spring.h2.console", name = "enabled", havingValue = "true", matchIfMissing = false)
#EnableConfigurationProperties(H2ConsoleProperties.class)
#AutoConfigureAfter(SecurityAutoConfiguration.class)
public class H2ConsoleAutoConfiguration {
When this Configuration is loaded it will check these conditions and upon all conditions being true then and only then will it load in the beans defined in the class. In this case it wires the h2console servlet.
#Bean
public ServletRegistrationBean h2Console() {
String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
return new ServletRegistrationBean(new WebServlet(), urlMapping);
}
There is also the security configuration in that class which introduces one more concept of conditionally loading a configuration based on another class being loaded into the context. These annotations do not always need to be on a Configuration level but can also apply to the bean level.
These concepts are core to how Spring Boot is implemented and therefore could not work with Spring 3.
Spring 3 list of annotations
http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/context/annotation/
Spring 4 Conditional Annotations
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/
Thanks Zergleb for posting detailed answer. I found a way to run the spring 3 app as an independent jar by created an uber jar with a little instrumentation to bootstrap spring through a java class.
It is explained nicely in a short post at https://mihhaillapushkin.wordpress.com/2013/02/18/spring-3-for-standalone-applications

Resources