Is Migration from Struts to Spring wholesale change? - spring

I have a Struts 1 application and I am exploring different options for upgrading the system. One option is Spring MVC or Spring Boot. If I were to choose either framework to migrate the application to, can I do so transitionally (piece by piece) or would it be a complete wholesale change or complete rewrite. Don't know if I'm making myself understood.

Spring 3.0, had explicit support for integrating struts 1. This was two major versions of spring and 9 years ago. There is documentation here:
https://docs.spring.io/spring/docs/3.0.5.RELEASE/reference/web-integration.html#struts
Integration consisted in either using the ContextLoaderPlugin to allow spring to manage all your action classes, or to make your action classes aware of the spring context. A fair amount of struts specific code was available to do things like map struts action handlers to action beans in the spring context.
You could probably reproduce a lot of this in spring 5, but you'd have to do a lot of heavy lifting on your own. There are probably very few struts/spring 5 users out there to help you.
You could also go with spring 3.0 to make the integration easier, allowing you to do the migration in steps, but then you are in a different bad place. You have an old version of spring that fewer people use, and none of the goodness that 9 years of releases have wrought.
If you want to migrate your struts 1 app to spring, you are probably going to have to do it all at once. Redo your action classes as springmvc controllers and then rewrite your views (templates). spring mvc is pretty view agnostic and there are many good choices.
Good luck and have fun!

Related

Is it possible to upgrade Struts 1.2.9 to Struts 2.5.22 [duplicate]

This question already has an answer here:
Migration from Struts 1 to Struts 2
(1 answer)
Closed 1 year ago.
My company plan to migrate Struts from 1.2.9 to 2.5.22 but found that might be the hard work and consume a lot of time.
I want to know for planning and manage the project, how much time it need to do.
Is possible to upgrade from 1.2.9 directly to 2.5.22 (the latest version at the time of question)
Or it need to upgrade like 1.2.9 -> 2.0.x -> 2.3.x -> 2.5.22 ?
And if you have a clear guide it would be appreciate.
Struts1 and Struts2 are completely different and therefore the code won't work just upgrading the Struts2 version: there are differences at all level from configuration, threading model, JSP tags and Actions classes.
You can read here
Our strategy when we migrated a significantly large (legacy) application followed those guidelines:
include Struts2 jar files and configuration files: they can happily co-exist with Struts1
create new screens with Struts2: define a new namespace so URLs are different and there is no collision (it also helps for debugging)
rewrite incrementally the application: move one screen at the time creating a new Struts2 action handler and new JSPs
We have used Spring for the new Struts2 implementation (again they all co-exist in the same WAR) since the integration is smooth.
We have been also able to re-use part of the service layer (business logic and DAO): the service code was refactored to be Spring-managed and injected in the Struts2 Action classes.

Spring 4 vs Grails - Open Source Plugins

I have used spring 3 but not sure what is the equivalent of a grails plugin. And now need to suggest a stack for a new app. Looking at grails it seems to be great for making data base models and has a lot of plugins. but it seems its more expensive at runtime.
So my question is that is there a equal or better repo of spring for every little thing you can need like facebook login or other social actions, ajax upload, joda etc or is this what we call a dependency and some code from a blog/ stack?
Is there any repo of small reusable code like we have on grails plug ins for regular spring mvc projects?
I know that your question is about pure spring alternatives, but I would honestly recommend just using Grails. I've done projects in both stacks. If you want to get rid of the configuration headaches and get started quickly on a new project while staying within the Spring stack, it is the way to go. It is a great framework and some of my employers have many production Grails applications supporting thousands of customers.
You can also upgrade to Grails 3 when it comes out next year and take advantage of the leaner code they provide in it due to Spring Boot!
You may need to check into Spring Boot. It does not provide a full stack framework, but it is hiding much of the extra coding you may need to do for a spring application. There are some new projects that enable you to get the benefits of spring boot. Check the below projects:
1- http://jhipster.github.io/ , use it if you need to make SPA with AngularJS also have commands to generate Entities for you using Yeoman
2- http://lightadmin.org/ , use it if you want to create CRUD pages based on Spring Data Entities
For both, you may have to use Spring Data and maybe even Spring Data REST. These may be helpful too.

What the difference between struts2 and spring MVC

I am learning Java EE and wanna build up a complete management system for a restaurant. Now I am confused what presentation layer should I use for my RMS because I heard that the struts 2 is one of the best UI layer but, the thing is, if I am using spring for my business logic layer then I can use the spring MVC can't I? By the way, I am really interested to build a complete application which is follow the multi-tier architecture.
Yes, of course you can use Spring MVC.
You can use Struts 2 if you'd like as well, because Spring integrates with it nicely.
But I don't see any reason why you'd want to do that. The person who told you that Struts 2 is
one of the best UI layer [sic]
is misguided. If you compare it to Spring MVC, you'll see that the two are based on similar ideas, but Spring improves on Struts. JSF has superceded Struts as the default Java EE web view technology, so it's not even considered "best" by the Java EE standard.
Stick with Spring. You won't be sorry.
I will not blame struts 2, indeed it's a great product, I work with it every day. But in my experience spring MVC is a lot simpler and clearer. This doesn't mean you don't get as much features.
Try both, and you'll see what I mean.
Tell us which one you choose!

Migrate struts action to spring action

I am looking for a good tutorial on migrating from struts to spring. I have multiple struts actions that I would like to refactor into spring components.
Here's one (assuming you're talking about Struts 1, although you don't specify).
Not sure how helpful it will be; depending on how clean the original Struts code was it could be relatively straight-forward, or brutal.
In my experience the bulk of the work lies in the JSPs, not the actions themselves, particularly if the S1 code made extensive use of the Struts tags. The actions themselves are easier to deal with because of strong IDE support.

What are the advantages/disadvantages of Seam over Spring?

What are the advantages/disadvantages of Seam over Spring? Why would I use Seam in lieu of Spring?
Is there anything that can be done in Seam that can't be done in Spring? Anything in Spring that can't be done in Seam?
What about stateful/stateless architecture? I am a Spring user, so I am biased, naturally.
Why Spring?
Cleaner code
Streamlined application configuration
Nice integration with popular open source products
First class AOP support
Enterprise-scale security: Acegi
Highly flexible MVC
Abstracted data access (JDBC is OK)
Enterprise Java without EJB
Testing is easy
Why Seam?
Merge Java EE 5 standards (EJB 3.0, JPA, JSF, Annotation) seamlessly
Stateful by design
Bijection
Integrated Ajax (ICEfaces and Ajax4JSF)
Business process integration (jBPM)
Business rules integration (Drools)
Workspace management
Deliver complete stack (from JBoss & RedHat)
Seam Text and EL enhancements
Probably will be a standard (JSR-299: Web Beans)
From Framework Deathmatch: Spring vs Seam. Thomas Wiradikusuma (Spring). Joshua Jackson (Seam). Java User Group Indonesia. JaMU 07.03. March 17, 2007 power point presentation here
although seam does have many advantages over spring, there is a magic word that really is worth paying attention to and this is PERFORMANCE!!! if you are not worried about performance issues I would go with seam. From the other hand if you want your application to be as fast as possible and your hardware is limited I would use spring. I am not saying that you can not develop fast applications with seam, but in order to do this you really need to know what you are doing. I have used both of them (i am not a guru in any of them) and what I found out is that although spring needs more effort to build what you want, at the end the result is more flexible and is performing better. I do not think that there is something that can be done in one framework that it can not be done in the other, saying that, remember that I am not an expert to any of those.
Seam will give you a pretty, ah, seamless, integration between the components that make up the seam stack. All very nice as long you keep within that stack, and within the seam model and foing things. It all starts to look a little less convincing as soon as you start doing something unusual, though.
If it's not too much of a generalisation, Seam is very "microsofty" in that regard. This isn't a bad thing, it's just a stylistic thing. Spring is more open-ended and takes more effort to get going, but it's ultimately more flexible, and a lot more open.
You can use Spring and Seam together - Spring for backend components, Seam for enhancement of web layer (JSF/GWT/Wicket) and other stuff. Seam offers a lot of Spring functionality (i.e. IoC container, transaction managment) - in your project you can decide - witch implementation to use.
More details on integrating Seam with Spring - "Seam in Action - free bonus chapter"
Let's compare the two.
What is common?
Both are open source, follow MVC architecture and has a servlet based front controller.
Advantages of Spring MVC
Extension of Struts.
View can be developed using JSP and HTML. You can also plugin other's like PHP or velocity.
Has large number of controllers predefined.
Integrated out of the box with Spring framework.
Advantages of Seam
Extension of JSF
View can be developed using JSF component library. There are large number of vendors to choose from.
Integrates JPA entities with Web layer
Annotation based validation
Integrates with EJB 3.0
Out the box jBPM support which provides process flow definitions.
Integrates with Drools where you can define web layer business rules.
Good community support.
Conclusion
Since Seam is built on JSF, it has large number of UI Component libraries to pick from. It reuses Java EE stack better. It has lot of interesting modules integrated beforehand.
Spring MVC is built on top of Struts and Spring, so it will reuse Spring framework stack far better than others. But the view is built using JSP, so we have to rely on JSP tag library vendors to build rich components.
Seam framework would be a better choice as Spring framework is anyway extensible enough to be leveraged by Seam.

Resources