-2

I'm currently working on a project where I need to externalize the HTTP Session and other objects (Such as JSF state, Controllers, etc). My Project is in full JEE using JSF on the web tier (plus PrimeFaces and some other libs). Running on Payara Server, using Docker at AWS.

My Controllers are fully Stateful and I need to keep this way. I research about how I can easily externalize the user session without changing much code and I found out about Spring Session. The problem is that I have zero experience with Spring and how to introduce it into my project and all I failed all my attempts so far.

I don't user Maven, and at this point is very unlikely that I can use it, since the project is too big to move, so I have to import all the libs manually. I just want to import the libs (Spring + Spring Session), configure Redis access and change as little code as possible. Can it be that easy?

My question is: what's the best approach to use Spring Session in my situation? Does anyone know a better / easier way to externalize JSF session to Redis?

Thank you.

trulley
  • 9
  • 2
  • How do you build your project(s)? With ant? – m4gic Sep 06 '18 at 20:38
  • Yes. I use Netbeans, so it builds with ant. – trulley Sep 06 '18 at 20:40
  • Would you like to do session replication, therefore you are trying to "externalize" sessions? – m4gic Sep 06 '18 at 20:42
  • That's correct. But I don't want to replicate the sessions in all my Payara nodes (like Hazelcast does), only store it in an external service such as Redis. – trulley Sep 06 '18 at 20:44
  • First of all, welcome to stackoverflow. `I use Netbeans, so it builds with ant.`: What kind of relation is there between those two? Netbeans is an IDE, so you can do your builds in ant, Maven, Gradle.. – Aritz Sep 07 '18 at 06:12
  • And better to delegate session management to the servlet container. Including Spring just for this will result in more problems than it solves. And why redis? (not that it is bad, but since it is most likely all serialized java, I don't see an advantage of using redis) – Kukeltje Sep 07 '18 at 11:00
  • NetBeans is built on top of Ant, so by default the projects are built using ant. I just mentioned NetBeans because maybe there's some easy way to integrate spring in the project using the IDE. I want to use Redis because is one of the options in AWS Elasticache. Thanks for the suggestion Kukeltje, I'm gonna look into that. I know very little about session management, so I'm gonna do some more research before asking more questions. Thanks guys. – trulley Sep 07 '18 at 16:02

1 Answers1

0

What I would do: I would not try to reinvent the wheel, very probably in your budget there is not enough spare time and money to figure out such a solution.

Why?

You have a big ant based project, spring is maven based, it has a so huge dependency tree that you will not really be able to manage it without maven (I would not like to try to even build a hello world without maven in spring-boot/mvc). Even if you could put somehow them together, I bet that there will be a lot of classpath problems from jar version differences. You have to pay attention to your used Java version, you have to select the spring version so that your JDK will be supported by Spring.

And there is the technology difference: you will be able probably to call Spring beans from EJB or vice-versa using CDI (at least this has worked in this way on Wildfly), but if you think this over, you would not like to do that. If you have ever worked with Spring, you would know that this, is, khm, not easy.

And last but not least: you would like to replace/implement Payara Session replication using Spring... in order to do that, you have to know very well the Payara internals, the Spring internals and a lot of other stuff to do that.

All-in-all, if I were you, I would implement either the standard session replication, or, what would be even better, stateless backend. You can have more clusters, and in this way you will not replicate your sessions between all nodes.

You should really consider to move towards either maven or gradle, for a long term, it will have almost only benefits. Netbeans supports it well. The only drawback if you have a lot of custom ant tasks, but there is maven-antrun-plugin, and, if nothing would help on you, it is not that hard to write your own maven plugin.

m4gic
  • 1,461
  • 12
  • 19
  • Thank you for your time. We do have a lot of ant tasks, mostly to build some of our own sdks, but I'll take a look at that. For now, I think that we will got stateless. It's gonna be very painful since our application is very dependent on stateful beans. – trulley Sep 06 '18 at 21:26