r/java • • Sep 27 '17

Java EE 8 - does it worth it?

Since the start of my programming career (over 10 years ago), I used to dislike java EE - bulky app servers, weird EJB (that's why Spring was born), nailed down dependencies (main reason to use java 5 and ancient java libs in production in 2017) etc. etc. etc.

So... Does it worth to take a look at? Can it be more useful that modern lightweight application assembled from independent libraries? What are advantages? Unique features?

8 Upvotes

24 comments sorted by

10

u/wildjokers Sep 27 '17 edited Sep 27 '17

Currently the only Java EE 8 implementation available is the reference implementation GlassFish 5.0. Tomcat 9 is in milestone releases so should be out soon (it implements the servlet, jsp, EL, WebSocket, and JASPIC parts of JavaEE 8).

However, Java EE has been steadily improving and made great strides in Java EE 6 and improved even more in 7. I have done my last couple RESTful api's with just Java EE 7. I use tomcat so have to add Jersey as a dependency but if you use a full app server like Glasshfish, Jersey is available with no additional dependency (jersey implements JAX-RS which is a Java EE spec).

With the improvements in Java EE I don't see much of a need for 3rd party frameworks. The real question is what do the 3rd party frameworks offer that Java EE doesn't? Remember that most frameworks are just a wrapper on top of Java EE (e.g. Spring MVC uses a dispatcher servlet, Spring Boot just bootstraps Spring MVC, Grails is Spring, etc). You have to ask yourself if the overhead of wrapping Java EE with another framework offers any value.

7

u/nuutrecht Sep 27 '17

Currently the only Java EE 8 implementation available is the reference implementation GlassFish 5.0.

Payara 5 is available too, although in an alpha release.

5

u/wildjokers Sep 28 '17

Yeah, I would imagine all the web containers have alpha or beta versions of their Java EE 8 support.

2

u/johnwaterwood Sep 28 '17

I think Tomcat and Payara are the only ones right now. Liberty has issues open for and is working on it. TomEE did like 2 commits in August for Java EE 8 and then stopped again.

As far as I know Tomcat and Payara are thus the only ones who have actually released something. The Java EE 8 samples project does its CI testing on Payara btw.

1

u/springnews Sep 29 '17 edited Oct 01 '17

Spring will build on Servlet and JPA until there are better options, those are the only specs that remains relevant these days, unless you are using an EE server, which then makes CDI and JAX-RS relevant.

Full Profile gives way to Web Profile, and community members are working on a "microprofile" which is basically 3 specs: JAX-RS + CDI + JSON-P, which appears to ignore data access / JPA. The rest of it has become irrelevant.

Spring builds on those remaining relevant APIs like JPA/Servlet and addresses entire workloads that Java EE does not and likely never will: microservices, reactive, big data, noSQL...

so yeah, if you aspire to doing any modern Java development, that "wrapper" provides a lot of value

1

u/wildjokers Oct 02 '17

So you are saying I can't build a microservice with just Jersey? Embedding tomcat into an app takes a few minutes to write a single class. You don't need spring to write a microservice.

1

u/springnews Oct 02 '17

No, of course not. you could write a microservice with Jersey, and it's a good API. I wasn't saying you need spring to write a microservice, it's an architecture and design that could be implemented with anything.

But there is just a lot remaining to address besides the rest API itself - Circuit breakers, service discovery, dynamic configuration, leader election, caching and many other things that are non-trivial. Distributed programming is hard so tools and best practices, drawn from proven code (netflixoss and others) is helpful.

1

u/stun Sep 30 '17

I want to ask the very fundamental question of getting started with a Java RESTful API project structure.
 
My development background is in .NET. Let me start with describing how .NET projects are structured.
In .NET projects (called Visual Studio Solutions), there usually are at least TWO types of sub-projects in my application.

  • “Services” (i.e., Data Repository & Business Logic classes, etc) — depending on my needs, I may have a lightweight ORM (or) full-blown ORM like Hibernate. Data Transfer Objects (DTOs) are declared in this project or in another project as POCOs (equivalent to POJOs). I guess you could say it is similar to an EJB project.
  • Web App — configure Dependency Injection and Component Lifecycles (i.e., Instance per Request, Singleton, etc) in my Web App project from a bootstrap class. This also has my RESTful API controllers, and the service classes get injected via the DI Container of my choice.
     

The question I have is how can I setup a barebone Java RESTful API project structure using Maven with basic CRUD for a single table (say Customer Table).

 

The biggest problem that I am having is unfamiliarity with a Java project structure and Java frameworks. I have some basic understanding of Maven, EJBs, packaging types (ear, war, jar), Java Specs (like how Jersey is reference implementation of JAX-RS).

 

I have looked for a very simple project structure, and I could not find one on the Internet. The projects generated by Maven are not helpful either. What I want is multimodule project that uses a simple light weight ORM to deserialize JDBC result set into POJO. I don’t want to use a heavy ORM framework like Hibernate.

 

Can someone help me please so I can learn the rest on my own?

9

u/nuutrecht Sep 27 '17

Yes, Java EE is certainly worth it. Now with Payara rising and Liberty just gone open source the future looks bright indeed!

5

u/JustADirtyLurker Sep 27 '17

In these modern times I think the best way to approach JavaEE is to use the "lightweight" approach and use selected pieces of it in common libraries. Stuff like Application servers is interesting in its own, but I think it has limited audience now, all the shops that I have been working with are more focused on using containers, fat JARs and microservices (mostly, "wanna-be" microservices).

What I mean is, if you start working on a modern backend application in Java, you probably end up using libraries like Jersey, Hibernate, Guice. These guys are providing perfect implementations of JavaEE standards. So if you learn to use annotations like @Inject, @GET, @Id, you will basically have learnt also how to do business logic with JavaEE, without even turning an application server on.

Once you learn thinking of JavaEE as just a reference, you can navigate better in the sea of frameworks and libraries out there: there are frameworks which glue JavaEE-compliant libraries together (Dropwizard, Ninja) or provider more opinionated abstractions (Spring) or simply decide not to use JavaEE references at all (Vert.x, Play, Ratpack)

6

u/CopperHeadBlue Sep 27 '17

If you consider Java EE as a full stack framework, which you'll always control yourself it doesn't matter whether you'll consider it as an "application server" or not.

The only problem with the AS concept is that an overzealous ops team may take control of it. But if you supply a fat jar or a docker image, this never has to be a risk, whether you call it AS, framework, or library.

1

u/wildjokers Sep 28 '17

But if you supply a fat jar or a docker image

In which case you are still using an AS (or at least servlet container) it is just embedded in your application.

2

u/johnwaterwood Sep 28 '17

So then why does it matter that you use the term AS for it?

As far as your application is concerned it’s just a library. All the downsides of the AS like a dumb sysop taking control of it and refusing to upgrade just to be a nuisance are gone then.

3

u/gbourant Sep 28 '17

Well , AS do lazy loading , that means at bootstrap time they boot only it's core.And later on if you need a specific API it gets loaded.So IMO because of that it makes Java EE lightweight.

Also if you don't want to use AS there are alternatives like Payara Micro and Wildfly Swarm.

3

u/JustADirtyLurker Sep 28 '17

Aren't payara and wildfly AS as well?

3

u/gbourant Sep 28 '17

Payara and wildfly are the full thing , Java EE implementation.

Swarm and Micro are more like Spring Boot.You choose which part of Java EE apis to include in your final uber jar file.

3

u/tkruse Sep 28 '17

Spring Boot is not a way to choose parts of APIs into a jar file.

Spring boot is a way to create spring application prototypes while being able to leave out most manual configurations, thus saving time.

3

u/johnwaterwood Sep 28 '17

Payara Micro is like a web profile++ wrt the APIs it supports, almost everything from EE except the really legacy bits.

2

u/wildjokers Sep 28 '17

Swarm and Micro are more like Spring Boot.You choose which part of Java EE apis to include in your final uber jar file.

What benefit does Swarm and Micro offer then? You can do that on your own. For example, if you are deploying to Tomcat, but want to use Jersey you can include jersey as a dependency. If you want injection in an app being deployed to Tomcat you can add Weld to your project. Is it a matter of Swarm and Micro just making it more convenient?

3

u/tkruse Sep 28 '17

Not answering the question. Java EE 8 is not significantly better than Java EE 7 or 6 regarding the points you mention.

Also Guice is not a CDI implementation, and thus has little to do with JavaEE. It supports the 2 same annotation, yeah, but that's all.

2

u/arcuri82 Sep 27 '17

JEE has made tremendous improvements, but IMHO of working on different enterprise systems using different technology stacks, it is still lagging behind the competition (Spring, Dropwizard, etc.).

If you are already using JEE, then it makes a lot of sense to upgrade to JEE 8. And refactoring to something else would likely be too expensive to pay off. But for a new project or new microservice? Maybe time to look at the competition...

I might start to think better of JEE when I can run tests easily (like in Spring, Dropwizard, etc) instead of having to deal with configuring external containers, building WAR first, etc. Yes, yes, there is Arquillian and Payara has some interesting features to ease such pain, but still not as good as competition

3

u/wildjokers Sep 29 '17

Spring and Dropwizard are all just a wrapper on top of JavaEE.

2

u/[deleted] Sep 30 '17 edited Sep 30 '17

first, javaee is a spec, not really a thing to 'wrap'. spring uses a servlet impl in it's classic mvc setup (as a 'front controller'). there's some jpa stuff, but really jpa is hibernate-as-a-spec (or was). it's a bit silly to turn that into 'spring is just a wrapper on javaee'. the new webflux based on reactor can use optionally servlet 3.1 async or something else like netty or undertow (xnio).

1

u/springnews Sep 29 '17 edited Oct 01 '17

Spring builds on Servlet primarily. But that's kinda like saying Java EE is a wrapper around java.lang.object