Spring 4.0 vs Java EE 7 [duplicate] - spring-mvc

I have been doing Java SE for some years now and moving on to Java EE. However, I have some trouble understanding some aspects of Java EE.
Is Java EE just a specification? What I mean is: Is EJB Java EE?
Are EJB/Spring different implementations of Java EE?
I am sorry to ask but I have some difficulties to understand what Java EE is.
Could someone explain what Java EE is? And EJB?

(Updated Feb 2022)
First of all, "Java EE" has since Sep 2019 been renamed to "Jakarta EE", starting with version 8. Historically, there was also the term "J2EE" which covered versions 1.2 until 1.4. The term "Java EE" covered versions 5 until 8. See also Jakarta EE, History on Wikipedia.
Is Jakarta EE just a specification? What I mean is: Is EJB Jakarta EE?
Jakarta EE is indeed an abstract specification. Anybody is open to develop and provide a working implementation of the specification. The concrete implementations are the so-called application servers, like WildFly, TomEE, GlassFish, Liberty, WebLogic, etc. There are also servlet containers which implement only the JSP/Servlet part of the huge Jakarta EE API, such as Tomcat, Jetty, etc.
We, Jakarta EE developers, should write code utilizing the specification (i.e. import only jakarta.* classes in our code instead of implementation specific classes such as org.jboss.wildfly.*, com.sun.glassfish.*, etc) and then we'll be able to run our code on any implementation (thus, on any application server). If you're familiar with JDBC, it's basically the same concept as how JDBC drivers work. See also a.o. In simplest terms, what is a factory?
EJB is part of the Jakarta EE specification. Look, it's in the Jakarta EE API. Full-fledged Jakarta EE application servers support it out the box, but simple JSP/Servlet containers don't.
See also:
Where can I find a list of all the reference implementations for Java EE 6?
Java / Jakarta EE web development, where do I start and what skills do I need?
What to learn for making Java web applications in Java EE 6?
Are EJB/Spring different implementations of Jakarta EE?
No, as said, EJB is part of Jakarta EE. Spring is a standalone framework which substitutes and improves many parts of Jakarta EE. Spring doesn't necessarily require Jakarta EE to run. A bare-bones servlet container like Tomcat is already sufficient. Simply put, Spring is a competitor of Jakarta EE. E.g. "Spring" (standalone) competes EJB/JTA, Spring MVC competes JSF/JAX-RS/MVC, Spring DI/IoC/AOP competes CDI, Spring Security competes JAAS/JASPIC, etc.
Back during the old J2EE/EJB2 times, the EJB2 API was terrible to implement and maintain. Spring was then a much better alternative to EJB2. But since EJB3 (Java EE 5), the EJB API was much improved based on lessons learnt from Spring. Since CDI (Java EE 6), there's not really a reason to look at again another framework like Spring to make the developers more easy as to developing among others the service layer.
Only when you're using a bare-bones servlet container such as Tomcat and can't move on to a Jakarta EE server, then Spring is more attractive as it's easier to install Spring on Tomcat. It isn't possible to install e.g. an EJB container on Tomcat without modifying the server itself, you would basically be reinventing TomEE.
See also:
When is it necessary or convenient to use Spring or EJB3 or all of them together?
Java EE 6 vs. Spring 3 stack
Using JSF as view technology of Spring MVC

Java Enterprise Edition (Java EE) is an umbrella specification that references a number of other more detailed specifications, of which Enterprise JavaBeans (EJB) is one of the more important ones.
Read this - it explains the difference between Java EE and Spring
Thanks...

Source -- Java 2 Platform, Enterprise Edition (J2EE) defines the standard for developing component-based multitier enterprise applications. J2EE simplifies building enterprise applications that are portable, scalable, and that integrate easily with legacy applications and data .
Source -- Enterprise JavaBeans (EJB) technology is the server-side component architecture for Java Platform, Enterprise Edition (Java EE). EJB technology enables rapid and simplified development of distributed, transactional, secure and portable applications based on Java technology.
Is Java EE just a specification? What I mean is: Is EJB Java EE?
Java EE is a specification.
EJB is server side component architecture for Java EE
Are EJB/Spring different implementations of Java EE?
Both EJB and Spring are different frameworks following Java EE.

J2EE/JEE/Jakarta EE
Java Enterprise Edition (JEE) is used to develop distributed application &
web services.
It’s a component based approach to develop web app.
JEE web apps are considered as 3 tiered apps, since it is divided on 3
different machines/tiers
Client (Presentation)
J2EE sever (Application/Business)
Database (Data Access)

Everything you need to know about Java EE may be found by starting # Oracle official website, among other. You may also find interesting to read the specification APIs for release 8. It is worth taking the time to go through the Java EE 8 tutorial. You may want to start with it actually, because it provides a very good overview of the whole platform.

To put simply - JavaEE is a platform.
It is made up of many specifications which are just APIs. The specific concrete implementations of these APIs are the so called 'Reference Implementation'
EJB is just one specification within the JavaEE platform
No, Spring is a application framework that can allow you/has support for you to develop JavaEE applications
EJB is Enterprise Java Beans

Related

Creating a Hello World application with Servlet 4.0 (Java EE 8) and HTTP/2

I am trying to understand how Servlets 4 (Java EE 8) help us to gain the benefits of HTTP/2 by writing Hello World kind of application. I am aware that Java EE 8 is yet to be released.
Is there a way I can try these features on beta release of any servlet container like GlashFish?
Is there a pre release for developers to try out the Java EE 8 API?
Disclaimer: Once Java EE 8 and the Servlet API 4.0 (which supports HTTP/2) are under development, this answer may not be updated.
What's currently available (July 6th 2016)
At the time of writing, here are a few resources that you may find useful:
GlassFish 5 nightly builds (looks like it's a fork of GlassFish 4.1 and seems not to incoporate Java EE 8 components).
Java Servlet API 4.0 JAR (currently released as beta) available on Maven repositories.
Apache Tomcat 9 (not released as a final version yet), which supports the Servlet API 4.0.
Payara 5 (under development), which is a branch of the Payara project to be used for Java EE 8 features.
The JSR for the Java Servlet API 4.0 (currently available as an early draft).
More details about Java EE 8
Quoting the Java EE overview from Oracle website:
As the industry begins the rapid adoption of Java EE 7, work has begun on Java EE 8. With a survey that received over 4,500 responses, the community has prioritized the desired features for Java EE 8. In fact, the following JSRs have already been submitted:
JSR 366 - Java EE 8
JSR 367 - The Java API for JSON Binding
JSR 368 - Java Message Service 2.1
JSR 369 - Java Servlet 4.0
JSR 370 - Java API for RESTful Web Services 2.1
JSR 371 - Model-View-Controller 1.0
JSR 372 - Java Server Faces 2.3
JSR 373 - Java EE Management API 1.0
JSR 374 - Java API for JSON Processing 1.1
JSR 375 - Java EE Security API 1.0
The results of the survey can be seen in the following chart:
If you want to try out Servlet 4 with server push functionality (the new PushBuilder which allows the server to push data to the client), you need:
latest glassfish5 nightly build (http://download.oracle.com/glassfish/5.0/nightly/latest-glassfish.zip)
JDK > 1.8.0_131 + (latest one is _144 at the time of this writing)
make sure you access the servlet over HTTPS, HTTP/2 doesn't work without SSL apparently.
Check out a complete example here: https://en.kodedu.com/2017/04/first-look-http2-server-push-java-servlet-4-0-specification/
An important requirement when using Servlet 4 and the Server Push feature is that you must secure the connection and an able HTTPS. It is an extra step required when using HTTP/2 on the server and the client is a browser. Here is a blog post about how to set up HTTPS and Servlet 4.0.
Browsers vendors have implemented HTTP/2 over TLS and even though this is not a specification requirement it is required that you set up a secure connection.
I have a simple example of how to use Server Push in a servlet that should help get you started.

Converting Play Framework Application to Spring MVC

We have done a quick proof of concept web application using PlayFramework1.2 and now we would like to proceed for production release however one of the concern is that Play Framework not enterprise compatible and wanted the application to be ported over to Spring.
Any tools or guidelines for porting over playframework project to spring MVC ?
Note: I'm saying not enterprise compatible because it seems Play1.x development been abandoned and no any new Play 1.x release recently. Also current Play framework 2.0 more focus on Scala rather than Java.
As above posters mentioned Play 1.x was an initial draft. I was in your shoes contemplating whether to rebuild the app in Spring but I gave Play 2.x a chance and now I don't think I want to go for Spring at all. With every release Play is becoming more and more feature rich. I think before migrating to Spring you should give Play 2.1 a chance. Moreover if you need Spring for DI then you can actually mix Spring with Play 2.1 as well. See this demo app:
https://github.com/guillaumebort/play20-spring-demo
Hope that helps.

WS-I Basic Profile 2.0 compliant frameworks

In Wikipedia a number of WS-I Basic Profile (BP) compliant frameworks are listed. However, it is not clear to which version of the BP the framework is compliant to. So my question is as follows:
Which frameworks/products (Java, .NET and others) are compliant to WS-I Basic Profile 2.0?
The answer of this question may be of interest in the selection of an enterprise web service standard. It seems as if most frameworks are compliant to BP 1.1, but the question is whether the IT environments are ready to be upgraded to BP 2.0 (including MTOM binary attachments, WS-Addressing, SOAP 1.2 and UDDI 3.
Studying one example framework, the IBM WebSphere Message Broker (WMB), more closely I found the following information:
the platform supports WS-I Basic Profile Version 1.1
the platform supports e.g. WS-Addressing and SOAP 1.2
by using the HTTP proxy servlet pattern you indirectly get the same support as given by the Java EE application server
However, I did not find any explicit statement detailing that the product supports WS-I Basic Profile Version 2.0. The same seems to be the case for many frameworks...

spring framework & asp.net mvc

I heard there is a port of spring framework to .Net framework which is called spring.net.
Anyone can compare those two frameworks? If design the system, which one is prefered or both can be used.
Spring is for Java, Spring.NET is a .NET port of the Java framework.
See the overview page for a summary of the modules it implements.
You can't use both since they are written for different platforms. If you're designing the system and have the freedom to choose which platform you're implementing in, you can choose either Spring for a Java implementation or Spring.NET for a .NET implementation.
They are slowly getting a bit different, especially with the support for .NET specific things, such as WCF.
If you're going to decide to implement in .NET/Java I would take more into account than simple Spring/Spring.NET.
Spring is the original Java version and Spring.NET is a .NET version. Spring is better, as the .NET port is not as good as the original. For .NET, you are better of with Castle Windsor. The best thing is to use none of the dependency injection containers because dependency injection is not a good design pattern to follow. Neither is MVC. Java has many differences from .NET. .NET has advantage of Web Forms over Java. If you are using .NET, use the best UI platform which is Web Forms. If you are using Java use JSF.

What is the difference between Java EE and Asp.net

I like to know the difference between Asp.net and Java EE.
J2EE (since 3 years to be called "Java EE") is a bit broader than ASP.NET (that was an understatement). You can best compare "ASP.NET" with "JSF". They both have the same purposes/capabilities: a component based MVC framework which offers taglibs which are to be used in respectively ASP and JSP pages. The major difference is that ASP.NET is to be runt with C# "codebehind", while JSF is to be runt with Java "codebehind".
That's basically all. The one is based on C#, the other is based on Java.
Java and .NET? ahem
You would love working on Java EE ;)

Resources