IDE for JBoss JSF development - eclipse

I am planning to develop a medium to large size web application using JSF (plus PrimeFaces or other) for the view layer and EJB3 for business logic. The reason we've chosen EJB3 over more lightweight JSF beans that might only require a Servlet container (as opposed to an EJB3 container) is for additional EJB3 features like security. Since we are targeting deployment on JBoss AS I was wondering what IDE solution you would recommend. I've seen that both Eclipse and Netbeans support JBoss either out-of-the-box or with plugins.

Or even you can try IntelliJ Idea. All these IDEs has a support for all common servers (including JBoss) so that's really not a criterium for choosing IDE.
It just depends on what you are used to and if you have one of these IDEs already running (with Maven, Ant, SVN, Git or whatever you use for your project) then just go with it:-)

Related

JSF and Richfaces on JBoss AS 4

I need to develop a presentation layer for an existing Java EE application running on JBoss AS 4.2.1.GA. I have been reading on JSF, Facelets and RichFaces and tried a few examples - some things worked but others didn't because of the limitations of library versions I used, considering the outdated JBoss.
Can someone recommend the direction I need to be heading to get this done as quickly as possible by using the mentioned server? By this I mean the Eclipse tool (WTP, JBoss Tools, ...), type of project, dependencies, ... Also, to shorten development time, maybe also use JRebel?
I know I would be better off using the latest server, but unfortunately it is not an option.
Also, I have installed JBoss Tools for Eclipse Indigo, but for creating RichFaces Project, it requires JBoss EAP 6 or AS 7.1.
I had created applications using JSF 1.2, RichFaces 3.3.3, JBoss Seam 2.0.2 (not required) for JBoss AS 4.2.2.GA. For development was used Eclipse (3.4/3.5) IDE for Java EE Developers. Version of Eclipse is not important. Yes, you need WTP. In my projects seam-gen was used for generating project skeleton. If you don't use Seam you can create Web project.

Move a seam application to OSGI

i' ve some web applications developed using Seam Framework 2.3 + jBoss AS 7 + Hybernate.
Since i' ve been studying OSGI for a while, i was wondering if is possible to move my applications to the osgi world for modularizing everything; i' ve read a lot of blogs and these interesting discussions as well (how-to-modularize-an-enterprise-application-with-osgi-and-ee6 and how-to-modularize-a-jsf-facelets-spring-application-with-osgi) but honestly i still don't really know where i should start from, since i' ve never used OSGI before.
According to you
Is it possible (and useful) do such things?
According to your experience, what would be a good starting point?
Thanks for help
Approach
Possibly start with a toy application as a spike, a WAB (OSGi WAR) and single service bundle.
Definitely take an iterative approach. As far as I know JBoss supports the mixing of OSGi services and Java EE stuff, via JBoss modules/msc, this will allow you to try OSGi and migrate gradually.
I think you'll find some things are incredibly easy and others very hard, so pick easy battles while you're getting familiar. In the end you may stick with a hybrid approach.
Build
What's your build tool? Mostly like Maven or Ant, in which case have a look at maven-bundle-plugin
or bnd respectively. You'll need to ensure the OSGi metadata is present in each of your bundles (Bundle-SymbolicName, Import-Package, Export-Package, etc). If you're using Maven see this answer.
It can be tricky to divide a monolithic app into modules, but as a general rule when you migrate a reasonable sized module you should have separate bundles for API and implementation (which is good design anyway but has implications for the runtime too).
Interop
You can acquire OSGi services, access bundles etc using the low level framework APIs from an injected BundleContext, which will give you a low-level programmatic hook into OSGi. It should be as simple as:
#Resource
BundleContext context;
Unless your Java EE code is packaged as JBoss modules I don't think it will be easy for you to call the other way (e.g. OSGi service looking up Java EE service) without resorting to something like JNDI.
You should be able to install the webconsole and see what Java EE bits are registered in OSGi, and similarly check JNDI to see what's available OSGi for Java EE.
Migrating Services
While OSGi is a lot of fun, using the raw framework API results in quite a bit of boilerplate code and it's unlikely you'll need the power or want the coupling. You can use a number of dependency injection frameworks on top of OSGi; blueprint (Spring-like), Peaberry (Guice) and Declarative Services for example.
I'm biased but Declarative Services has a strong affinity to the OSGi µservice model and the implementations are lightweight.
CDI
I don't know much about Seam/CDI, but Pax CDI might help (though JBoss might already have covered this).
Web
Are you planning to have a highly modular UI with hot deploy of the various components? If not then probably best just to package the UI as a WAB. A WAB is a skinny WAR (i.e. it imports rather than embeds most dependencies). Even if you're after a highly modular, dynamic frontend, I would definitely do this for the first pass.
JPA
A word of warning - JPA implementations typically don't play well in OSGi environments, you may want to look at Apache Aries or Eclipse Gemini. Another option might be to leave the JPA stuff in Java EE space and access Java EE DAOs/Repositories as OSGi services. Again though you may experience some classloading issues.
Possibly useful examples https://docs.jboss.org/author/display/JBOSGI/Provided+Examples

reference for ejb jboss and eclipse development

is there a reference or book, maybe a tutorial that can get me started with ejb using the technologies that I have mentioned above?
thank you
You can take a look at the JBoss Tools if you're interested in developing Java EE applications in Eclipse.
If you already know EJB (and if you don't there is quite good Enterprise JavaBeans 3.1 book) you know you can develop your EJB's as plain POJO's just with annotations. No need for fancy plugins here.
You would, however, need a plugin to easily deploy your application to the server. In this case, take a look at these JBoss Tools and this topic.

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

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.

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.