Wednesday, September 13, 2006

Programming: Steps for Building an Enterprise Application for JBoss Using NetBeans

Summary of steps to create a working Java EE 5 application using NetBeans, to be deployed to a JBoss application server, and persist data in a Microsoft SQL Server 2000 database.

(1) Downloads: NetBeans 5.5 Beta 2 with JBoss 4.0.4GA, Sun Java EE 5 SDK. Must have a database. I use Microsoft SQL Server 2000. Install the IDE, JDK.

(2) Install a J2SE 1.5+-aware JDBC driver, such as jTDS (extract the archive to the application server library).

(3) Data source: In the AS deploy directory, create a *-ds.xml file with configuration and JNDI information for accessing the database. Suppose the database is called [JEE5], the file shall contain:
[datasources]
[local-tx-datasource]
[jndi-name]JEE5[/jndi-name]
[connection-url]jdbc:jtds:sqlserver://localhost:1433/JEE5;tds=8.0;lastupdatecount=true[/connection-url]
[driver-class]net.sourceforge.jtds.jdbc.Driver[/driver-class>
[user-name]sa[/user-name]
[password]*****[/password]
[/local-tx-datasource]
[/datasources]
(4) Follow the steps in the EJB 3.0 Enterprise Beans for JBoss Application Server tutorial.

Only disappointments so far: the JBoss application server is not fully Java EE 5 compliant. At this time, it only supports EJB 3.0 and Hibernate 3.0.
It is advisable that you restart the server after deploying your application. For a while, my tables remained empty (no exceptions for failure to create/insert entities) until I restarted JBoss.

Notes: In #3, the data source name to use is java:/JEE5.

Friday, September 08, 2006

Programming: Tools Update

Despite how busy I have become, I still get an hour or two to review what's new in the Java programming world. I've recently decided to adopt the NetBeans development environement (now as beta version 5.5), especially after they have made a version available that's integrated with the JBoss application server (version 4.0.4 GA) and supports the latest Java enterprise edition, JEE5.
The trick is how I'll actually get to learn this new material: since I virtually no longer have free time outside of work these days, I'll cheat a couple of hours at work for 'skills/technology improvement'. I mean, my pet project Jaspora would greatly benefit from advances in these technologies, so I have no qualms about how well I'm using my time at work. I'm especially attracted to the ease of programming data access, enterprise java beans, and annotations. I expect that with the latest tools for Java development available, I should cut development time by about half! What's more, I take this as an excuse to learn how to test my code using JUnit. Believe it or not, all code I've written to this day has never seen unit tested such as JUnit does. It'd be a great time to incorporate code profiling and other optimization tools.
It's an exciting world out there. Now if I could add an hour to my day, I'd totally sell out to it.