Monthly Archives: June 2005

NetBeans Server Plugins

NetBeans 4.1 has built in support for Sun App Server and Tomcat 5.5. There is also a Server Plugins project for NB that adds support for JBoss 4, WebLogic 9 and WebSphere 6. The server plugins project is currently classified as experimental.

Currently the only way to try these plugins is to build NB and the required plugins – you can only download the source for them at the moment. Downloading and building is a easy process, albeit rather lengthy. Full details are given on the server plugins home page, but basically to download from CVS and build on Windows you need to do the following.

rem Create a directory to store and build NB in. 
mkdir netbeans 
cd netbeans 
   
rem Setup CVS 
set CVSROOT=:pserver:anoncvs@cvs.netbeans.org:/cvs
   
rem login to CVS - no password required. 
cvs login 
   
rem download NB relase 4.1 source
cvs -z 6 co -r release41 -P stable 
   
rem download server plugins source
cvs -z 6 co -P serverplugins 
   
rem build NB 
cd nbbuild 
ant 
   
rem build JBoss plugin 
rem change into the weblogic9 or websphere6 directories 
rem and run ant to build these plugins. 
cd ../serverplugins/jboss4
ant

Once this is all done, there should be a netbeans/bin directory from which you can run the freshly build NB with the new server modules.

Starting up NB and selecting “Tools – Server Manager” allows you to now add a server instance for JBoss, WebLogic or WebSphere.

I tried building the JBoss 4 plugin and it integrated correctly with my JBoss 4.0.2 installation. I was able to create an enterprise app from within NB and deploy and run it successfully to JBoss 4 – all from within NB.

Spring Connection Pooling with DBCP

Recently I wanted to add a connection pool to my Spring Web Application. I decided to use Commons DBCP to provide the connection pool as I’m using the Spring JDBC wrapper classes. Googling around didn’t find any examples of how to set up DBCP, so I’ve written my findings here.

Adding a connection pool to a Spring app is simply a matter of specifying the relevant entries in the Spring servlet configuration file. The XML snippet below shows an example of how a database connection pool can easily be configured.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"> 
  <property name="driverClassName"> 
    <value>net.sourceforge.jtds.jdbc.Driver</value> 
  </property> 
   
  <property name="url"> 
    <value>jdbc:jtds:sqlserver://localhost:1433/db;prepareSQL=0; 
SendStringParametersAsUnicode=False;</value> 
  </property> 
  <property name="username"> 
    <value>username</value> 
   
  </property> 
  <property name="password"> 
    <value>password</value> 
  </property> 
  <property name="initialSize"> 
   
    <value>2</value> 
  </property> 
  <property name="maxActive"> 
    <value>5</value> 
  </property> 
   
  <property name="maxIdle"> 
    <value>2</value> 
  </property> 
</bean>

Java Web Start

I’ve just noticed a poll that is currently running on the java.net home page asking if anyone has ever ran a Java Web Start Application.

I must say that the results were quite encouraging. At the time of writing, 80% of the respondents have answered “yes” to the question. (You can see the current poll results here).

Being able to run applications without having to install any software (apart from the loader) has got to be one of the most beneficial aspects available to modern computing. I still remeber the old days when IT departments had to manually install software on every workstation.

One of my favourite examples of using Web Start is on Santhosh Kumar’s WebLog (which, incidentally, I recommend to anyone doing Swing development) where he provides sample Java code and then a Web Start example of the code.

If you are one of the 20% that hasn’t run a Web Start application yet, have a look at Sun’s docs.