NetBeans, Derby, JSF and Jetty

Netbeans 5.5 has made developing web apps almost as easy as Microsoft’s flagship Visual Studio. However, there are still elements which can still be hard to figure out. Here are some personal notes:

1. The Derby databases are located in your home directory, under .netbeans-derby. (In Netbeans, Tools, Java DB Database, Create Java DB Database … reveals the derby.system.home)

e.g. C:\Documents And Settings\Chui\.netbeans-derby

2. Deploying JSF applications on Jetty requires a minimum Jetty-6.1.2.rc0. Previous versions fail parsing faces-context.xml, due to the logging interface not being completely implemented. (Bug number: JETTY-222)

3. Deploying database backed webapps on Jetty requires the webapps-plus config (for JNDI to work).

java -jar start.bat etc/jetty.xml etc/jetty-plus.xml

(Drop the .war in webapps-plus directory)

4. Configuring JNDI on Jetty requires the following file in your web app

webapps-plus/WebApplication2/WEB-INF/jetty-env.xml

<?xml version="1.0" ?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
  <!-- Add a DataSource only valid for this webapp                     -->
  <New id="mydatasource" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg>jdbc/TravelPack</Arg>
    <Arg>
     <New class="org.apache.derby.jdbc.ClientDataSource">
        <Set name="databaseName">travel</Set>
        <Set name="password">travel</Set>
        <Set name="serverName">localhost</Set>
        <Set name="portNumber">1527</Set>
        <Set name="user">travel</Set>
    </New>
    </Arg>
<Configure>

5. derbyclient.jar needs to be in Jetty’s lib directory

Leave a Reply