Difference between Java EE and Spring framework [closed] - spring

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am striving to know the difference between Java EE and Spring Framework. Could anyone please help me on this.

Java EE is an standard, official, specification for a full featured Enterprise Application Framework stack. Includes stuff like Object-Relational Mapping, Security, Web Applications, database connectivity, transactions...
On top of Java EE specifications there are JavaEE implementations/application servers like: JBoss, Glassfish, WebSphere, Weblogic.
Spring on the other hand, is a framework doing lots of the stuff on the Java EE specifications, but in its own form. They don't follow Java EE specifications and APIs for that. But they do include a Web Framework, transaction management, security and several other solutions Java EE offers.

Java EE:
Java EE industry approved standard API based framework
It is predominantly based on annotations and CDI
JFC MVC framework for web development
JPA specification to process DB operation
JTA API with implementation
EJB container and POJO based implementation
Oracle license
Spring:
Based on IOC and AOP
Based on XML configuration (now they are leveraging annotation)
Uses Spring DAO framework (based on Template design pattern) to connect to database
Provides abstraction layer to support various JTA implementation vendor
Integrates with various Java vendors to support different capabilities such as struts etc
Provides an end-to-end platform to build web application achieving loose coupling using DI and AOP
Open source license

Java EE:
A Sun/Oracle standard that app server vendors conform to
Based on Enterprise Java Beans
Implemented by many vendors: BEA/Oracle, WebSphere, JBOSS, Glassfish, etc.
Spring:
Not a standard; it's the brainchild of Rod Johnson and implemented by Spring/VMWare.
Not based on Enterprise Java Beans; it's a POJO model. Can manage EJBs if you wish to use them, but not required.
Not implemented by any vendor other than Spring.
EJB 3.1 has taken a great deal from Spring. Now it includes dependency injection, a form of aspects, and JPA. EJB 3.1 is much closer to Spring than EJB 2.0 was.

I provided an overview of Java EE here Frameworks for Layering reusable Architectures
This also contains a small comparison with Spring, which might be relevant for this question.

Related

Why to use JPA with Hibernate? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I work to a project that it has installed Spring, Hibernate and JPA.
I have read tutorials about Hibernate and JPA and the big picture is that JPA is an interface, and Hibernate is the implementation of JPA.
But why to use JPA, with what it helps me? What are the differences between JPA and Hibernate. First, i thought that annotations in POJO classes are from JPA, but no, they are from Hibernate Annotations.
So, the big question is, for what is good JPA?
Thanks!
The root reason for JPA to exist lies within the larger Java Enterprise specification. There was a growing need for a standardised ORM API to be part of the JavaEE 5 specification for standardisation across Java enterprise containers. That's it - that is why JPA exists and why existing ORM packages such as Hibernate do their best to implement it to the letter.
The net gain is quite simple; any Java Enterprise container (JBoss Wildfly, Weblogic, etc.) will support the JPA specification and will have an implementation for it built-in. Thus if you build an application or library and use only the JPA API in your code, you don't even have to package Hibernate or any other ORM with your application - it will during runtime just use whatever ORM the container provides.
Historically this wasn't usually possible because you'd still end up needing to add ORM specific configuration properties, so you at least needed to be aware of what ORM would be available on deployment to cater towards it. But since JPA 2.0 and 2.1 most of the common and uncommon configuration options have been standardised.
Long story short: if you're deploying to a JavaEE (or Spring Boot) container then using JPA is simply a good idea because it is readily available and is the standard (for object relational mapping).
If you're not going to be deploying to a JavaEE container and are going to be packaging an ORM with your application - well then you're even more free to do what you want. Just be aware that you wouldn't be the first to kick themselves when they're at a later point in time porting over code or maintaining a code base with mixed API usage.
Java Persistence Architecture (JPA) is a standard for Java object-relational mapping solution like Hibernate, TopLink, etc. Hibernate is a particular implementation of JPA.
You should be using JPA annotations so you aren't locked into Hibernate.
Make sure you are using JPA for a good reason. You might not need it. JDBC might be enough for your needs.

Spring vs EJB (advantage and disadvantage) [duplicate]

This question already has answers here:
When is it necessary or convenient to use Spring or EJB3 or all of them together?
(2 answers)
Closed 6 years ago.
I am currently preparing my final project study. I have to develop a distributed application for the management of human resources, but on my benchmark for technologies to use I found it confusing to decide between Spring or the EJB 3.1.
I do not know which will be the best suitable and easiest to use. I am a beginner for both technologies and therefore I hope so someone can help me.
You do not choose between EJB and Spring, you actually choose between Java EE and Spring because EJB is only a part of Java EE which includes also other components like JMS, Servlets, JSP, JSF, CDI, etc. In its early days (J2EE 1.4) programming model of enterprise edition of Java had a lot of flaws and deficiencies, but the most important ones were that it was tedious and verbose with a lot of boiler-plate code and tons of xml configurations. Spring was introduced as an alternative framework favoring convention-over-configuration principle. In other words, in Spring there were some sensible defaults that could be reconfigured if you need it. Java EE 5 introduced significant changes adopting the same convention-over-configuration principle from Spring, drastically reducing code amount and complexity required to get things going, so in this area Spring does not hold any sensible advantage any more.
It is also important to bear in mind that Java EE is just a specification. To build a real world app you need an implementation and there are plenty of them today - Glassfish, JBoss, TomcatEE, etc. all provide different implementations of Java EE specification introducing additional complexity - I mean, now you have to choose which Java EE implementation to choose. You can contrast that with Spring which comes from a single source.
Both frameworks gives you pretty much similar functionality. All support transactions, ORM, provide tools for building business logic, support CDI, AOP. In both Spring and Java EE you can only use the parts that you need, in other words you don't have to use the whole framework. You can even use them together - they can interoperate. Thanks to introduction of embeddable containers you now can even use Java EE features you need in areas like desktop applications which traditionally were the realm of Spring.
But one area where Java EE still lacks behind Spring is comfortable testability. It is not easy to write unit tests for EJB - for this you have to use a special third-party framework (Arquillian) and write some boilerplate code inside your tests (e.g. for building the test deployment package and deploying it onto the container, etc.). In fact, Java EE lacks any support for testing EJBs out of the box. In contrast, Spring is built with testability and TDD in mind. Testing Spring beans is easy since Spring includes bundled support for both testing (unit testing, integration testing) of all parts of the application as well as mocking.

Social Plugins: Is it possible to use any in a Java EE 6 environment?

As we know we have some social plugins for Java EE, like Spring Social and Seam Social.
The problem is that I m not using spring neither seam.. I'm using a Java EE 6 app using netbeans, with a javaee-web-api-6.0.jar to WAR project and EJB3.1 to EJB.
Well, my question is, do you guys know how to use sprint social or seam social in this case?
Or better, do you know any other API to social, like these two, but to work in a environment without spring or seam?
I'm the tech lead of Seam Social.
Seam 3 is not strictly a framework (like was Seam 2) but a collection of CDI extensions and CDI beans library. It is targeted to all CDI implementation. So you use those libs to extends your toolbox without leaving Java EE and CDI.
Being part of it Seam Social can be used with any environnement that has CDI (a Java EE 6 container would be the best solution).
Beside Spring Social (which will be very hard to use in your environment) and Seam Social, there are not generalist social network solution. You'll have to get specific libs for each social network (Twitter4j for Twitter is a good solution)

A fresh graduate confused by the Java EE jargon Spring, Struts, JSF, EJB, Jboss, JMS,

As we all know that we rarely get a chance to learn whats out there in the enterprise world when it comes to college. In my experience I have always seen people learning Core Java and may be some other languages and when they graduate they have no Idea about this enterprise jargon. I am in that boat now. I am a recent graduate with a programming job and I often get confused about all the jargon which appear in the news an discussions. I believe all the frameworks mentioned have a purpose at the time of creation which is intended to fill a void.
I am sure that many of you would have gone through this in the early stage of your career. Is there anything out there a blog post, book , video or forum discussion which helped you to understand how all these frameworks weave together to form a application.
A detailed article would be most appreciated. I tried to look for one but I could them in bits and pieces but not a comprehensive article.
You could google/wikipedia them 1 by 1.
From wikipedia
Java EE
"Java Platform, Enterprise Edition or Java EE is a widely used platform for server programming in the Java programming language. The Java platform (Enterprise Edition) differs from the Java Standard Edition Platform (Java SE) in that it adds libraries which provide functionality to deploy fault-tolerant, distributed, multi-tier Java software, based largely on modular components running on an application server."
The Spring framework is sort of an alternative to Java EE.
Spring
Struts
"Apache Struts is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model-view-controller (MVC) architecture. It was originally created by Craig McClanahan and donated to the Apache Foundation in May, 2000. Formerly located under the Apache Jakarta Project and known as Jakarta Struts, it became a top level Apache project in 2005."
and so on. Research at your liesure...
You don't need all of these frameworks for completing your application. Even though many frameworks provide integration and support for each other, you don't have to use them all. I suggest you go layer by layer. Spring has uses in almost all layers, Struts is mostly an MVC framework. Spring MVC (one part of Spring) and Struts fill the same void. Tiles is a view layer framework. I think FreeMarker, Velocity and Tapestry are also view layer frameworks. JBOSS is an application server.
Spring and EJB 2.x were competitors. Again, EJB is meant for some of the more complicated applications, find more on this from the creator of Spring who wrote an entire book on why EJBs are not suitable for all web applications, which laid the basis for what was to become Spring later on. Though now, the latest EJB version 3.x seems to be getting good reviews. You haven't even mentioned Hibernate and iBatis for the ORM needs of your web-app.
I suggest you get used to the plethora of frameworks in the enterprise java world. If anything, it shows that the java world is alive and active.

Enterprise Application

I am thinking about a platform for study application (it is team work). I mean standard Java EE 5 (or maybe try raw Java EE 6) and Spring. What is your choose? (I don't mean Spring MVC but Spring Beans and EJB 3.0)
Also I would like to know what app server you use? (now I use GlassFish v2)
I would recommend Spring without EJBs.
My favorite choice of Java EE app server is WebLogic, but I don't know if Oracle is as generous as BEA was about making it available to developers.
I'd recommend using Tomcat as your app server. If you need JMS, add ActiveMQ.
As duffymo says, look at Spring without EJBs. Spring is very powerful, regardless of how much/little you use. I don't know of anyone using EJBs now. Having said that, EJBs have changed dramatically over the years, and now resemble ORMs such as Hibernate (which is worth checking out in itself).
For app servers, check out JBoss. It's free/open-source, and you can choose the web component between Tomcat and Jetty. It's JMX backbone allows you to easily monitor its state and to integrate your own JMX beans into that backbone (if you're using Spring, you can JMX-enable any bean with a simple configuration).
If you want Java EE 6 then the choice appears to be either Glassfish 3 or the beta of JBoss 6. As some of the others have said, I also prefer Spring to Java EE's EJBs.
I don't see much point in looking at Java EE 5, unless you think you will be working with it in the future (possible as some companies are conservative in using newer versions of technology).

Resources