Can Jetty be used as a Java EE lightweight application server? - jpa

In the scope of deploying small Java EE web applications at various client sites, I am searching for an easy application server solution.
I think I remember hearing that it was possible to use Jetty as a JavaEE 6 lightweight application server but I can't seem to find more evidence on this right now on the web.
Knowing that my development environment is JSF2 + RichFaces, CDI (Weld) and JPA 2 => NO EJBs at this point), is Jetty a possible solution for me?
If yes, could you point me to some docmentation or specific keywords helping me?
If no, what other lightweight Java EE 6 application server should I use?

Jetty is a servlet container, just like Tomcat. At the moment it's utterly unsuited as a Java EE 6 application server since the core requirement for a servlet container in that stack is being a Servlet 3.0 container.
Jetty 7, the latest stable version, is still at Servlet 2.5. At the moment nobody knows when Jetty 8, which will support Servlet 3.0 will be released, but experimental releases can already be downloaded. See http://www.eclipse.org/projects/project-plan.php?projectid=rt.jetty
Even when Jetty 8 will eventually be available, you'll of course still need to add JSF2 (Mojarra), CDI (Weld) and JPA2 (Hibernate).
Currently lightweight alternatives are Glassfish V3 (especially the Web Profile version). This weighs in at a 47MB download and gives you the full web profile. Glassfish starts up in approximately one second on modern systems and something like 2 or 3 on older ones. Memory overhead is minimal.
Yet another alternative is Caucho Resin. It's an inch away from being Java EE 6 Web Profile certified (see http://caucho.com/resin-4.0/changes/resin-4.0.14.xtp), and for all practical purposes is already fully useable as a Java EE 6 application server. Although I haven't personally used Resin, being lightweight seems to be their top priorities.
(do note that 'lightweight' is a vague and much disputed term)
Finally, you could give JBoss AS 6 a spin. Few people would call JBoss AS 'lightweight' (startup time on fast hardware is at least 12 seconds, and its download size is 181MB), but its free and open source and depending on your definition of lightweight those numbers may be 'good enough'.

I was very happy with a solution very similar to yours but using Spring 3 instead of CDI. It's almost the same. Everything was bundled inside WAR and for development mvn jetty:run was enough. No local app server needed.
However I'm sure you can embed Weld CDI implementation inside WAR. Still I'd prefer either "real" CDI JEE 6 stack or Spring.

Related

Is the GlassFish project still alive?

I wonder if the GlassFish project is dead or still alive? I am realy a fan of glassfish from the early first days. I started projects with GlassFish2 and have lot of customers using GlassFish3.
Since a few months I try to migrate some of my projects to GlassFish4. But I did not really have success. The problem for me is, that I can't find support form the community. It's hard enough to find a forum. To me it looks like Oracle had did a lot to stop any community driven development.
In the mean time I migrated my main project to Wildfly 9. In contrast to Oracle's GlassFish, RedHat's Wildfly is working perfect. There is a vital community, where you can ask questions and discuss open issues.
So I wonder what is the sense of the GlassFish project? Is it just the place where the 'reference' implementation can be hosted. A reference implementation which is (and maybe should not) be productive ready?
What did you think about this project?
GlassFish is absolutely still alive, there was a new minor release just a few days ago. It is still the reference implementation for Java EE, so you can expect GlassFish to be around for as long as Java EE is.
Oracle's other application server, WebLogic, still doesn't even fully support Java EE 7 - both they and IBM seem to have similar strategies of maintaining stability in their "full-fat" releases while being more "bleeding edge" with GlassFish for Oracle and the Liberty Profile for IBM's WebSphere.
It's also important to take note of the Payara project, which provides support for GlassFish, but also is actively looking for and fixing bugs in the upstream codebase. Some of the bugs which have been fixed in Payara have now also been incorporated to the latest GlassFish 4.1.1 release.
Finally, your point about whether or not GlassFish is "production ready" doesn't take into account the amount of GlassFish which is comprised of other projects, like Apache Catalina, Jersey, EclipseLink, Weld and others. These are the same technologies used in JBoss EAP, WebLogic, Tomcat etc.
It's difficult to get a good idea of activity in the GlassFish project, but it's easy to see how active Payara is.
Edit: David Delabassee has tweeted that the first nightly build of GlassFish 5.0 is now available to download
There do seem to be forums at www.java.net/forums/glassfish-0 and https://community.oracle.com/community/java/java-ee-java-enterprise-edition/java_ee_sdk but not very active as you've probably seen. There seems to be more information on the mailing list, the archive of which you can see here https://java.net/projects/glassfish/lists/users/archive
It is hard to find any information about the development plan is, so I think (especially as Oracle would like you to move to Weblogic and pay them lots of money) that its aiming to be a reference implementation.
Having said that, we've been using Glassfish for quite awhile and have been using Glassfish 4 in Production since April this year. What problems are you having migrating your projects?
Z

Java EE 6 + CDI on JBoss 7 - hot deployment possible like in Seam?

I did several projects using Seam 2 on JBoss5/6 and liked the feature that certain java classes (usually GUI handlers and util classes) could be put in a special src folder and be hot replaced through a special class loader after saving the file and an explode target running automatically afterwards.
Now I like to switch to Java EE 6 + CDI and use JBoss7, so I started with a maven based Java EE web project generated by JBoss tools in eclipse Juno. If I only change xhtml files, I can see the changes after the automatic re-publish, but not so with changes in java files.
Is there a way to get a similar behaviour in my new project setup than I had before with Seam 2 without using 3rd party tools like JRebel?
Edit 2012/07/23:
I add another point to the question - with newer containers like JBoss7, restart of an application seems to go quite fast - so is it even necessary trying to integrate code replacement tools and hoping for the best?
When I evaluated JRebel about a year ago for that stack (Java EE 6 / CDI / JBoss AS 6), even that tool did not cope with CDI. This might have improved in the last 12 months, but generally speaking:
I'm not aware of any advanced hot-deployment support of Java EE 6 on JBoss AS, with or without tooling support.
(If you read the thread to the end the situation seems to be better for GF, but that's out of the scope of your question)
Take a look at JRebel. CDI parts are constantly being improved and although there's still a way to go, it can be quite a time saver. If you find the cases when JRebel fails to deliver, report at the forum and the devs will do their best to improve the experience.
In regards to the second question, even if container startup takes no time, like in case of Tomcat or Jetty, the application deployment time will not get much faster and might still take considerable amount of time.
So the answer is - yes - code replacement tools are still relevant even with the lightweight containers.

What's the ideal setup for a quick turnaround in Java EE development?

I'm currently struggling with the project setup while implementing a Java EE 6 application with Eclipse Indigo and JBoss 6. The application server and the IDE is pretty much set in the project. Maven 3 is used and was the base for the setup by using the WELD archetype and creating a WAR.
Now, the problem is, that I'm very disappointed about the development turnaround. I don't have a working automatic redeploying within eclipse and often need to restart JBoss since it gets confused with the new publishing and then is not able to redeploy correctly. This is very frustrating and time consuming. (Plus I feel the smirks behind me from the guys preferring script languages.)
From earlier projects we were using Seam 2 and the project created by seam-gen came with a somewhat decent republishing, although I still had to do a manual application restart whenever I changed Java classes. Then, from playing around with Netbeans 7 and the integrated GlassFish 3.1 I found that automatic redeployment was working ok. And since Java EE 6 is very wide spread, I assume, there must be a better setup than I have now.
So with this post I hope to get some more insight in having a good project setup for fluent development of Java EE 6 based WAR projects on JBoss and eclipse - who can share some best practices?
Thanks a lot!
You should use JBoss Tools plugins for Eclipse. JBoss Tools 3.3M2 is compatible with Indigo and JBoss AS 7 (which is 10 times faster than JBoss 6 for redeploy).
Regarding an equivalent to Seam Gen with CDI, you should really take a look to Seam Forge which is included in JBoss Tools 3.3 now.
Finally I'm using Jrebel to reload class and configuration without restarting the server. But for now it doesn't work yet with JBoss AS 7, so if you stick with JBoss AS 6 it's a goof combination.
This might not be the answer to your question, but if you want Java and fast turnaround look at http://www.playframework.org/ your script colleagues will be astounded.
For Eclipse to work well, use Eclipse Java EE edition and then add the JBoss server adapter.
The usual WTP-tooling then works for automatic deployments etc.

What are the most important differences between full AppServer (like JBossAS) and Seam?

If client of the system is on the web there are no advantages JBossAS+Seam over Tomcat+Seam?
Your questions suggests you're confused about what is what.
Seam is a framework for building web applications in Java.
JBoss AS is a Java EE application server.
Tomcat is a Java servlet container.
You can run Seam on either JBoss or Tomcat.
Since JBoss is a full EE app. server, you get certain features like Enterprise Java Beans out of the box with JBoss.
With Tomcat, you don't, but this isn't usually a big concern since, for example, Spring framework can replace Java EE if you need that functionality.
It does matter what you use, since the majority of your system will be probably coded in the back end (server side Java).
If you want the minimum amount of hassle when using Seam, I'd suggest using JBoss since that company made Seam.

Starting a project in Java EE

I am thinking of using Java EE for my college project. Previously, I have used C# for a desktop application. I am new to Java and Java EE.
My question is this. What do I have to consider before starting a project in Java EE? I am thinking about using NetBeans as my IDE. Is this a good idea? I can choose either MS Sql Server or Oracle as my back end.
What do I have to consider before starting a project in Java EE?
This question is very broad and I don't know if this is exactly the expected answer but my suggestion would be to go for Java EE 6 (more precisely, for the Java EE 6 Web Profile which is a subset of the entire specification but should be more than enough in your case) and to use the following APIs:
JSF 2.0 for the presentation layer.
EJB 3.1 Lite for the services layer.
JPA 2.0 for the persistence of your domain objects.
For the runtime environment (the server to run the code), I suggest using GlassFish 3.0.1 Web Profile.
I am thinking about using NetBeans as my IDE. Is this a good idea?
That would be my recommendation. NetBeans is a very decent IDE, is beginner friendly IDE (but still powerful), it provides very good support for Java EE 6, very good integration with GlassFish, and has are plenty of tutorials and documentation available to get started:
Getting Started with Java EE 6 Applications
Java EE & Java Web Learning Trail
I can choose either MS Sql Server or Oracle as my back end.
Java uses an unified low level API called JDBC (JPA being a higher level API built on top of it) to interact with a database so choosing one or the other doesn't really matter from a Java point of view and it won't make any difference for a college project so pick the one you want to work with (if you already used SQL Server for your C# project, you might want to get some experience with Oracle).
Related questions
What to learn for making Java web applications in Java EE 6?