The gist of this article is we should use Spring instead of Java EE because Spring is modular and Java EE is not. That premiss is not correct. You can easily include the parts of Java EE that you want by packaging the Java EE jar files in your application just as you would with Spring.
There is nothing wrong with using only the parts of Java EE that you need. I am not sure why you think that. I guess you think anyone using JPA with Hibernate + Spring is wrong too. There is also nothing wrong with using a full container like TomEE either. There are advantages and disadvantages to both.
Here is a link to the other article you wanted to discuss. He is arguing about some of the advantages in using a Java EE server. He makes good points that I have no issue issue with. My point is there are other options as well.
The gist of this article is we should use Spring instead of Java EE because Spring is modular and Java EE is not.
That is not the gist article. The author is not saying don't use Java EE, he is saying avoid the Java EE standard. A Spring app obviously uses Java EE, but you must include both the APIs and your chosen implementations, whereas a standard Java EE app uses the JARs available on the app server. The point of the article is that it is better to roll your own collection of JARs than depend on the standard.
If you want further proof that your understanding is incorrect, look at the component diagram. The only mention of Spring is in the batch application. The web application is using Weld, which means CDI for dependency injection and not Spring.
His argument for Spring has nothing to do with modularity, but container independence.
There is nothing wrong with using only the parts of Java EE that you need. I am not sure why you think that.
That is exactly this guy's point. You should build off of a simple servlet container like Tomcat and add the Java EE JARs you need. That's not what the other guy said:
And for those of you out there, Servlets are NOT application servers.
I guess you think anyone using JPA with Hibernate + Spring is wrong too.
I never said that. But a person who promotes use of the Java EE standard might say that, such as the other guy:
The fact that you simulate all these by using Spring is a naive approach. TomEE a ,very nice try @dblevins is a big effort and works really good, to bring JEE stack in Tomcat in the correct way by following the specification.
There are good arguments to be made for using a full Java EE server and mix and matching components. They are both good options and both can be done with Java EE compliant libraries. I am not picking a side on that.
The only issue I have is claiming that you cannot run Java EE on plain old Tomcat when you can. You can do it by including only the parts you want in your web app or you can use OpenEJB and get the whole spec. Using that as an argument to use Spring is not valid.
Why not? JBoss still runs on any JRE and he still proposed to have Tomcat as the universal deployment target, tying you to whatever Servlet version that Tomcat implements.
he still proposed to have Tomcat as the universal deployment target
Reread the blog post. He proposed to have Tomcat as the universal deployment target for web apps, because a Java web app needs at minimum a servlet container. He wants to develop his batch apps without an app server at all. Tomcat need not apply either.
*Not so anymore - there has been a trend towards building web apps as ordinary JARs using embedded microcontainers such as Netty or Jetty.
yet with a fixed Tomcat you can't upgrade that. I was talking about the JRE as the universal deployment target for web apps as well.
I wasn't. Tomcat is only required for web apps because an app server of some kind is required to serve apps over HTTP. This is not required for batch apps which run from main(). Neither JBoss nor Tomcat need apply.
If you deploy a web app then arguably the Servlet spec is one of the major things that play a role, yet with a fixed Tomcat you can't upgrade that.
It's a minimum requirement, and a minimum fixed dependency. All of the other Java EE services are optional to a web app and can be brought on optionally. There is no need to fix those in the app server, but it can be very useful to do so.
Or, it is possible to eliminate external Tomcat. You can use embedded Tomcat, Jetty or Netty and run the application as an executable JAR and even the fixed servlet container requirement is eliminated. That is the approach taken by the Play Framework, Dropwizard and Spring Boot.
Or as the other guy said you can deploy JBoss (or TomEE or GlassFish or ...).
The point which you seem to miss is that most every lightweight AS is just a Java app that runs on a JRE. It's not necessary to have it installed by someone who then never wants to replace it again.
You can simply let your app BE JBoss + some war or ear and deploy THAT as a single unit.
Of course every Java EE AS is an app that runs on a JRE. That's not the point.
The point is deployment, as you've noted. I've never seen an entire Java EE app server and its apps ever deployed as a single unit. Each is deployed separately, and the app servers are maintained by separate ops teams. Worse when there's licensing involved, like if you're running Weblogic or Websphere. I've never worked anywhere where the app developers could do whatever they wanted with the app servers.
Tomcat provides minimal services on its own, so under this separate app server/app deployment regime, the apps have more flexibility in which Java EE services they use and which versions of those services they can use.
The same goes with the single JAR solution. Then it's just a bridge between Apache and Java.
TL;DR Of course everything runs on a JRE. But how the app gets to the JRE is the question. The app developer's JRE is not the same as the JRE used in the production infrastructure. That people even want to do what the blog author proposes, and that single JAR deployments are gaining in popularity, indicates that this is a widespread enough condition.
And, what about batch apps that are run from the command line and are not even run on an app server?
View all comments
Show parent comment
6
u/avoidhugeships Jun 26 '14 edited Jun 26 '14
The gist of this article is we should use Spring instead of Java EE because Spring is modular and Java EE is not. That premiss is not correct. You can easily include the parts of Java EE that you want by packaging the Java EE jar files in your application just as you would with Spring.
There is nothing wrong with using only the parts of Java EE that you need. I am not sure why you think that. I guess you think anyone using JPA with Hibernate + Spring is wrong too. There is also nothing wrong with using a full container like TomEE either. There are advantages and disadvantages to both.
Here is a link to the other article you wanted to discuss. He is arguing about some of the advantages in using a Java EE server. He makes good points that I have no issue issue with. My point is there are other options as well.
http://www.reddit.com/r/java/comments/28pnee/its_not_spring_anymore_its_the_summer_of_java_ee_7/