Posts

Showing posts from August 21, 2011

Minimal 3-tier Java EE app, without any XML config

Image
Older versions of Java EE and Java frameworks in general were rather heavy with regard to required XML for configuration. Notorious were EJB2, Spring 2.x, JSF 1.x, Servlet 2.5 and many more. These days things have improved quite a lot. In this post I'll demonstrate a very simple, yet 3-tiered, Hello word application for Java EE. It uses JSF 2.1 and EJB 3.1 and absolutely not a single line of XML configuration. The entire application consists of just 3 files: page.xhtml , BackingBean.java and BusinessBean.java . To run the application, create a dynamic web project called 'mytest' in Eclipse (EE edition) and delete everything that's generated by default in WebContent. Copy page.xhtml to WebContent and copy both .java files to src. Add the app to your server (e.g. Payara 164) and browse to localhost:8080/mytest/page.jsf to see all the action. The following shows the code of the 3 files involved: page.xhtml <html xmlns="http://www.w3.org/1999/xhtml"...