Spring MVC Java Configuration session replication - java

I'm working on porting over an application into Spring MVC using Java Configuration so I don't have to use a web.xml file anymore.
For the most part it is working, except for session replication. The app currently runs on Tomcat and we use the distributable tag in the web.xml for session replication.
Does anyone know a way to make this work using Java configuration?

You could use Hazelcast for that. Please, see How to configure Hazelcast for session caching using spring while limiting it to a set of nodes? for how to configure it.

Related

spring.session.timeout vs server.servlet.session.timeout

I'm looking to extend the user session in a Spring MVC app with Spring boot and Tomcat. Looking at the documentation there seems to be 2 relevant properties:
server.servlet.session.timeout
spring.session.timeout
Most examples out there seem to suggest to use server.servlet.session.timeout; what is the purpose of spring.session.timeout? Which one should be used to extend the user session?
spring.session.timeout is the property from a Spring sub-project called Spring Session. It will fallback to server.servlet.session.timeout if it is not set.
In short , Spring Session allows you to store HttpSession in RDBMS / Redis / Hazelcast Cluster / MongoDB rather than an internal map inside Tomcat .So the sessions is stored in the container agnostic way and make session clustering easier as you do not need to configure a Tomcat cluster.
So if you do not use Spring Session , you should use server.servlet.session.timeout
You should be able to set the server.session.timeout in your application.properties file to do the same
I think, If you add spring.session.timeout in application.properties the session timeout value mentioned using server.session.timeout will be overridden

Integrating Hibernate to Spring running on embedded jetty

I have just returned to Spring after 5 years of gap and it seems lot is changed. I have a task to create a REST Service using Spring with hibernate as an ORM, So far I am able to run a basic Rest Service using embedded jetty and able to make GET/POST calls, the next is to integrate hibernate into it so that the data fetch/Sent operation actually use MySQL instead of sending hard-coded response(which I have done currently).
The issue is earlier I used to work on Spring MVC using Tomcat where we had web.xml to define the dispatcher servlet and application-context which in turn were used to define hibernate config and other beans declaration, but now having embedded jetty I am not finding a way to integrate hibernate to my REST app, Is the way to add configuration is changed from XML to class based config. I searched over internet but maybe I am out of words or not using correct keywords, in short, Have no luck finding some solution to integrate hibernate to my Spring app which is using embedded jetty.
Could some please breif me about the recent changes or point me to the right tutorial ?
Any help appreciated, thanks in advance !
ps - I have used this example to progress so far https://github.com/pethoalpar/SpringMvcJettyExample
Yes , lot of changes in these 5 years and one of the game-changer is spring-boot
If you want to build a brand new project especially if you want to run the web application on the embedded container such as Jetty , you can check out spring-boot.It already provides integration with Jetty , hibernate and Spring MVC REST service.
The end result is that you just need to change a little bit configuration (most probably the DB connection info) and you can quickly get a production-ready REST service backed by JPA/Hibernate which can just run without any XML configuration anymore.
There are tons of tutorials in Internet talking about how to do it . You should easily find them out such as this using the keywords something likes "springboot webservice hibernate jetty" etc.

Spring-JPA-MVC-Hibernate Session per Request with Java Config

I have a spring-jpa-mvc-rest-hibernate web application that I use Java Config almost 99% on the whole app.
How can I configure Session per Request on pure Java Config? Preferable not using hibernate specific code, if that is possible.
I'm using Spring 4.2.2.RELEASE, Spring Data 1.11.0.RELEASE, Spring JPA 1.9.0.RELEASE, Spring WebMVC 4.2.2.RELEASE and Hibernate 5.0.2.Final.
Thanks a lot.

Using spring core functionalities in tomcat based jersey application

I want to use spring's dependency injection for now(other core functionalites later maybe) in tomcat application.
I want to set up spring 2.5.5 in tomcat7, But don't have clarity on how to do this.
Specifically I am confused because I don't know whether to use Spring MVC or use just spring in tomcat.
I found this question helpful: Tomcat with Spring, But still didn't get the whole scenario on how to setup tomcat with spring.
You can do either, using just core spring with tomcat is fine. MVC provides additional functionality.
Take a look at the spring source examples on github, and read their docs.
(BTW I thouroughy spring-MVC component - it really saves time developing webapps)

JAAS - Web SSO integration on Tomcat

I'm trying to integrate Web SSO via JAAS in my web application under Apache Tomcat.
I've worked through Apache documentation and other stuff to get inside.
Common approach is to implement login module, configure web application (web.xml to be exact), configure server (jaas.config, server.xml) as described at http://jakarta.apache.org/slide/howto-jaas.html.
On my company environment I've faced issue with configuring server. Configuring environment variables as proposed by Apache is even worse.
Is there any way to make all configuration inside my web application?
PS. I do know about Spring security framework.
Thanks.
You are looking for http://spnego.sourceforge.net. There is a filter which does true SSO and JAAS.
There is a way to implement all security inside web app, except the security realm properties files (or LDAP / DB if you prefer). Read up on Java security. Also about tomcat's SSO valve

Categories

Resources