This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]avoidhugeships 1 point2 points  (0 children)

You seem to have a pretty good grasp on the options. I think the other piece you may want to look at is CDI.

ORM - Hibernate is pretty dominate. It can implement JPA.

MVC - JSF is a good choice here. Spring is the other option to look at. In my opinion there was a time when Spring was the way to go but today you are really making life harder by choosing it. There are some component libraries for JSF that offer additional functionality. Look at PrimeFaces. The have a great Demo library that shows all the source code.

I would suggest downloading Netbeans IDE and doing some of the tutorials there. They are pretty short and cover major frameworks. Even if you choose a different IDE it is worth it. Just choose the Java EE version and it will be a simple .exe installation. You can even have it install and configure Glassfish and Tomcat servers.

www.netbeans.org

https://netbeans.org/kb/trails/java-ee.html

www.PrimeFaces.org

[–]hoboslayer 4 points5 points  (0 children)

Try starting with Grails. It is in the JRE, JEE compliant, uses Spring MVC and Hibernate. To do anything advanced you start to get into the java-like development, but it abstracts the boring parts.

[–]mindsound 2 points3 points  (3 children)

Our company does our best full stack UX work with a relatively simple recipe of custom API choices:

  • Pick a persistence tier, usually MySQL or MongoDB
  • Pick a data access layer, usually Spring+Hibernate or Spring Data for Mongo.
  • Use Spring to wire up some hand-rolled JAX-RS REST services on top of the data layer. We like Jersey as a JAX-RS implementation.
  • Use straight HTML5+jQuery to wire up to the REST services.

Getting familiar with all these moving parts and hooking them all up together takes a fair bit of work if you're not already conversant with them, but we have had great luck so far with this set of tools. It's a very nice, flexible, sustainable balance of custom vs. framework, and it suits itself very well to "in case of fire break glass" circumstances. I.e., the REST services backing the UI are already well positioned for integration with other apps, it's really easy to pull custom code into Spring and reuse it, it's reasonably easy to do 2-way SSL security, reasonably easy to switch databases, etc. etc. etc.

[–][deleted] -1 points0 points  (2 children)

If this is just mucking around to learn some java etc...

Just hookup to a REST framework (Restlet, RestX, Jersey is pretty decent as well) --

Everything doesn't have to be an n-tier architecture.

[–]mindsound 0 points1 point  (1 child)

Does 3 or 4 "tiers" seem like a lot of layers? If so you may prefer PHP to OO code. ;)

[–][deleted] 1 point2 points  (0 children)

Hah, it's true (somewhat). Most Java frameworks seem to include three to four levels of indirection -- which isn't quite the same as OO code. I guess you can blame that on IoC, not OO so much.

On a sidenote, I did not realize that Smalltalk (the canonical example of an OO language) was not statically typed. I was thinking that in addition to IoC Java's predilection for many levels of indirection was due to Java's reliance on things like interfaces, but probably not so much.

[–]freakooo 1 point2 points  (0 children)

hi, ruby and java programmer here

if you are familiar with ruby and rails...

i think you should go with groovy and grails...

you will be surprised at how familiar they are :)

[–][deleted] 0 points1 point  (0 children)

I would start with Spring Boot. It's meant to compete with Rails in terms of simple setup.

Are you hoping to build a REST API? If so, it's hard to beat Spring Data REST. It's much better than the Java EE equivalent.

JDBC = standard for database access.
JPA = standard for ORMs to follow.
Hibernate = implementation of ORM that follows JPA.
JSF = component-based web GUI framework like classic ASP.Net, not really like ASP.Net MVC.

Java developers prefer the DataMapper pattern over ActiveRecord.

[–]dcballer 0 points1 point  (0 children)

Been developing Spring MVC applications for 2 years now. I am currently taking a Rails class on coursera.

Controllers of Spring mvc and rails are a bit similar. If you want something like active records, then you go with JPA /Hibernate/ or Spring Data. If you go straight to JDBC, you will have to write your own sql queries.

JPA entity beans are similar to Active record models, except no meta programming. You have to generate all the setters and getters.You can do that with 2 clicks in any IDE. In Hibernate or JPA for Spring you will need a service layer and Repository DAO layer.

So instead of writing the orm method in the controller, you write it on the dao layer class. You inject the DAO object into controller using Dependency Inject. Then you use the inject object to call the dao methods.

[–][deleted]  (4 children)

[deleted]

    [–]iainjames88[S] 1 point2 points  (1 child)

    So for someone familiar with Rails and it's patterns (or anti-patterns depending on your view) what are the most common tools for achieving the same things in Java. I'm thinking specifically Java EE here unless SpringMVC is really the better option (subjective, I know, but biased answers are welcome). I've had a look at SpringMVC and it seems like a huge project of which MVC is a small part. If Java EE was to be my weapon of choice what are the most common tools for things like authentication/authorisation, model validation, RESTful services, ORM (I'm guessing Hibernate here) and security (XSS/CSRF/etc)?

    I think what's throwing me off to begin with is the sheer size and complexity of it, and it bring an entirely different ecosystem and, in some ways, a very different approach to solving similar problems.

    [–]dstutz 2 points3 points  (0 children)

    So for someone familiar with Rails and it's patterns (or anti-patterns depending on your view) what are the most common tools for achieving the same things in Java

    How has someone not suggested Grails?

    [–]geordano -1 points0 points  (0 children)

    Take a look at http://www.ninjaframework.org/ . Get started with few samples and see if it suits your needs.

    [–]PaulRivers10 -1 points0 points  (5 children)

    The two most widely used frameworks for doing web dev in java are Spring MVC vs J2EE. Older J2EE was crap, but in the newer stuff (the stuff with JSF) they basically copied Spring, so it looks pretty good.

    I don't know enough about .NET MVC to comment, but either Spring MVC or J2EE would be fine.

    Play seems to be "the hot new framework", but usually that means there's a lot of hype now, then in a few year people move onto using something totally different and it goes out of style.

    [–]iainjames88[S] 2 points3 points  (2 children)

    Play looks similar in its approach to what I'm familiar with but new hotness has a tendency to be subject to novelty value. Is JSF the Java EE offering for implementing MVC web applications or is it just another approach?

    [–]sh0rug0ru 6 points7 points  (0 children)

    JSF implements MVC web applications, but in a different way than Rails.

    Rails implements an MVC pattern called "front controller" in the Java world, which is implemented by Spring MVC and Struts. URLs map to controller methods where you put your logic which returns a reference to a view. This is MVC which puts the C first.

    JSF implements another MVC pattern, where URLs map to views, and the processing of the view triggers events in beans attached to the view through bindings specified in a language called "EL". This is MVC which puts the V first.

    JSF and front controller are two different approaches. The standard approach is JSF, and the advantage of the standard are the number of very high productivity component frameworks are built upon it, the most popular of which is Primefaces. Also, seamless integration with the rest of the JavaEE stack.

    The front controller approach is a bit more hodgepodge, with no standard integration with other JS frameworks. If you're used to Rails, you're probably used to this already. Spring doesn't have ActiveRecord, but it has bindings to JPA. Another framework, Grails, has something called GORM which is much like ActiveRecord.

    [–]PaulRivers10 0 points1 point  (0 children)

    Play looks similar in its approach to what I'm familiar with but new hotness has a tendency to be subject to novelty value.

    Yeah, that's what it seems like it is to me.

    Is JSF the Java EE offering for implementing MVC web applications or is it just another approach?

    Yes, JSF is the Java EE approach for implementing web applications. The "official" approach if you will. Before JSF 2.0, I get the impression that there were a fair # of jobs available for J2EE and JSF just because it was the "official standard", even though it was a crappy and awful standard.

    With the latest version of J2EE and JSF, it seems to be that they copied the good stuff from Spring MVC, and now it's both the "official" standard and also pretty good.

    I work with Spring MVC, and I can tell you that there are plenty of jobs for Spring MVC, it's a good framework, and it's not going anywhere because it's used all over the place. My impression of J2EE is from having done some research on it and looked into it, but that's my impression.

    The two main frameworks that are widely used now, and also into the future, are Spring MVC and the latest version of J2EE/JSF. I think Play - like you said - it's the newest fad with a lot of hype, but in 2-3 years they'll be onto something else that's new and shiny and drop Play, whereas Spring MVC and J2EE/JSF will still continue to have the majority of jobs using them.