Database Applications Made Easy With WebSphere

Embed Size (px)

Citation preview

  • 8/14/2019 Database Applications Made Easy With WebSphere

    1/44

    Database applications made easy with WebSphereApplication Server Community Edition, DB2Express-C and EclipseSkill Level: Intermediate

    Anitha Krishnasamy ([email protected])Senior Consultant, WebSphere BPTSEIBM

    Sridhar Kuna ([email protected])Staff Software Engineer, WebSphere AdaptersIBM

    13 Feb 2008

    Section 1. Before you begin

    To create an environment for developing and hosting database applications that useJava Platform, Enterprise Edition (Java EE) technology, you need:

    A development platform or tool for developing your applications.

    A database for storing and retrieving data.

    A Java EE 5 compliant application server for your test and production

    environments so you can test and host your applications.Achieving this environment could actually be easier -- and considerably lessexpensive -- than you might expect, thanks to an ideal combination of software thatyou can obtain and use at no charge:

    Eclipse is a popular open source development platform.

    IBM DB2 Express-C is a full function data server capable of supportingboth relational and pure XML data storage.

    IBM WebSphere Application Server Community Edition V2.0 is a

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 1 of 44

    mailto:[email protected]:[email protected]://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlmailto:[email protected]:[email protected]
  • 8/14/2019 Database Applications Made Easy With WebSphere

    2/44

    lightweight, Java EE 5 certified application server from IBM, based onApache Geronimo.

    Using these tools as a foundation, this tutorial explores some of the key features ofWebSphere Application Server Community Edition and DB2 Express-C, introducesyou to Eclipse and its plug-ins, and explains how to set up and use these products

    and tools so you can develop and deploy a database application.

    To follow the tasks described in this tutorial, you will need:

    IBM WebSphere Application Server Community Edition V2.0

    IBM DB2 Express-C 9.1

    Eclipse SDK 3.3 and Web Tools Platform 2.0

    WebSphere Application Server Community Edition V2.0 WTP ServerAdapter (formerly Eclipse plug-in)

    See Resources to download this prerequisite software, all of which is available freeof charge.

    The next sections describe features and setup tasks for the above software.Instructions for building and deploying a simple database application for WebSphereApplication Server Community Edition V2.0 will follow.

    Section 2. About WebSphere Application ServerCommunity Edition

    IBM WebSphere Application Server Community Edition V2.0 (hereafter calledCommunity Edition) is a free-to-use Java Platform, Enterprise Edition 5 (Java EE)certified application server with a very small footprint, based on Apache Geronimo2.0.1. Community Edition is built on a highly customizable and modular architecture,and functions as a framework that supports existing open source components,forming a complete Java EE application server package made up of over 30

    best-of-breed open source projects.

    Community Edition's wealth of rich features has made it extremely popular. Forexample:

    Community Edition is a Java EE 5 certified application server thatsupports Servlets 2.5, JSP 2.1, and EJB 3.0.

    Administration of local and remote servers can be easily performed usingeither commands or a GUI Web-based console.

    Diagnostic capabilities, such as enhanced logging, a class loader viewer,

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 2 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    3/44

    and a JMX browser, are available through the administrative console.

    Community Edition supports the Eclipse IDE (Europa V3.3 and WTP 2.0release).

    Sample applications are included with the product to demonstrate Java

    EE 5 capabilities.

    The application server is easily customizable, based on the applicationscenario.

    Application high performance and high availability can be achievedthrough tuning and clustering.

    Enhanced application and administration security is provided throughvarious types of realms and SSL certificates.

    An excellent logging and tracing system supports simplifiedtroubleshooting.

    World class IBM support is available.

    Community Edition is available to use free of charge.

    In addition, Community Edition provides:

    Database connector support for Apache Derby, IBM DB2, Oracle,Microsoft SQL Server, MySql.

    Directory support for Apache Directory Server, IBM Tivoli DirectoryServer, MS Active Directory, OpenLDAP Server, and Sun ONE

    Directory Server.

    Integration capability with WebSphere MQ.

    The Community Edition product package contains:

    IBM SDK, Java 2 Technology Edition

    Sample applications to demonstrate Java EE 5 capabilities

    Community Edition Web Tools Platform (WTP) Adapter (formerly calledEclipse plug-in)

    JDBC drivers for Apache Derby and IBM DB2.

    Community Edition comes pre-integrated with several open source projects so youcan immediately provide applications with external resource components, such as adatabase, a messaging server, and a directory server. Such open source projectsinclude:

    Apache Geronimo: An open-source Java EE application server projectthat provides the foundation for Community Edition.

    Apache Tomcat: A servlet container that is used in the Reference

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 3 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    4/44

    Implementation for Java Servlet and JavaServer Pages technologies.

    OpenEJB: An EJB container.

    Apache Derby: A robust, small footprint database server.

    ActiveMQ: JMS provider.

    See Resources for more details on Community Edition features and systemrequirements.

    Section 3. About DB2 Express-C

    DB2 Express-C is a free-to-use data server capable of supporting both relational and

    pure XML storage. You can use DB2 Express-C for developing and deploying XML,C/C++, Java, .NET, PHP, and other applications.

    DB2 Express-C is optimized for powering Web services, Web 2.0, and SOA-basedsolutions, is available for both Linux and Windows platforms, has simplifiedpackaging that makes it easy to transparently install from within an application, andfeatures all the autonomic manageability features of other DB2 database products,with which it is fully compatible and to which it is fully scalable. DB2 Express-C canbe run on up to two dual-core CPU servers, with up to 4 GB of memory, any storagesystem setup, and no database size restrictions.

    To enable you to work effectively with the database system, DB2 Express-Cprovides many tools and facilities, including:

    Command line: Execute DB2 commands, database utilities, and SQLstatements.

    Administrative functions: Run administrative tasks to manage databaseconnections and database objects, perform preventive maintenance,manipulate data, analyze queries, and manage applications.

    Monitoring features: Monitor database activity, analyze events, and view

    memory utilization. Database setup: Connect and monitor remote databases.

    Product information: Access the Information Center and get informationon product updates.

    Application development encompasses the creation of database applications,migrating applications from other databases, creating stored procedures or userdefined functions, and programming applications with different applicationdevelopment tools. The DB2 database system comes with a variety of programmingfeatures, including routines that you can use (database objects that encapsulate

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 4 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    5/44

    programming and database logic related to a specific task), that run on the databaseserver, to supplement or extend your applications.

    DB2 Express-C provides support for these popular integrated developmentenvironments (IDEs):

    Eclipse

    IBM Rational Developer tools

    DB2 Database Add-ins for Visual Studio .NET

    DB2 Developer Workbench.

    Programming languages supported by DB2 Express-C include:

    C/C++ and DB2 Call Level Interface (CLI) and ODBC: A dynamic SQL

    programming interface for creating C/C++ applications that access DB2databases.

    C/C++ and embedded SQL: DB2 applications developed using C/C++programming languages can use embedded SQL techniques to createapplications using static and dynamic SQL statements.

    Java and Java Database Connectivity (JDBC): Provides a standard setof interfaces and classes for accessing databases from Java applicationsusing SQL.

    Java and Embedded SQL for Java (SQLJ): SQLJ support for DB2

    database applications has been optimized for executing embedded SQLstatements within Java applications. Compared to using JDBC, SQLJreduces the amount of Java application code required.

    Microsoft ADO.NET and Visual Basic .NET and Visual C# .NET: TheDB2 .NET data provider is an ADO.NET interface to DB2 databasesystems. By using the DB2 .NET data provider classes, your .NETapplications will have managed, secure, high-performance access to DB2data.

    PHP: An open source scripting language specially suited for Webdevelopment. You can access your DB2 database systems by using the

    ibm_db2 PHP extension or the PHP Data Objects (PDO) driver,.

    Perl: An open source scripting language. Using the DBD::DB2 driver withthe Perl Database Interface (DBI) module (available from the Perl DBIWeb site), you can create DB2 database applications with Perl.

    See Resources for more details on DB2 Express-C features and systemrequirements.

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 5 of 44

    http://dbi.perl.org/http://dbi.perl.org/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://dbi.perl.org/http://dbi.perl.org/
  • 8/14/2019 Database Applications Made Easy With WebSphere

    6/44

    Section 4. About Eclipse

    Eclipse is a lightweight, Java-based, extensible development platform with whichyou can develop a variety of applications using Java, Java EE, PHP, C, C++, XML,and others. Eclipse is an open source IDE that is community-managed by theEclipse Foundation, a not-for-profit, member-supported organization whose projectsare focused on building an open development platform comprised of extensibleframeworks, tools, and runtimes for building, deploying, and managing softwareacross the lifecycle. As with other open source projects, Eclipse software isdeveloped by open source developers (called committers), and is volunteered orcontributed by organizations and individuals.

    You can customize and extend your Eclipse environment by adding (or removing)plug-in packages to extend available features based on your applicationrequirements. For example, adding the Web Tools Platform (WTP) gives you theability to deploy your applications on Community Edition directly from Eclipse. TheEclipse WTP project extends the Eclipse platform with tools for developing Web andJava EE applications. It includes:

    Source and graphical editors for a variety of languages.

    Wizards and built-in applications to simplify development.

    Tools and APIs to support deploying, running, and testing applications.

    Community Edition requires the Eclipse WTP.

    See Resources for more details on getting started with Eclipse

    Section 5. Install and configure Community Edition

    To help you get up and running, the next sections include general instructions to

    help you install and configure the software components you need to create yourdevelopment environment.

    WebSphere Application Server Community Edition is a fully licensed productavailable for you to download and use for free (using Download Director, whichrequires a Java-enabled browser, provides pause-and-resume capability for largedownloads, high-speed transfer, and file access through firewalls). Be sure youreview all the system prerequisites for Community Edition and prepare yourenvironment accordingly before proceeding with the installation.

    Support for Community EditionWhen you download Community Edition, you are automatically

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 6 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    7/44

    entitled to limited online support during the initial 30-day period atno charge. If you require IBM support and maintenance beyond thisinitial period, several fee-based support plans are available

    After downloading, you can install the software using either a silent method or one ofthe installation wizards provided in the product download package for these

    platforms:

    For AIX, Linux, or Solaris: wasce_setup-version-unix.bin

    For Windows: wasce_setup-version-win.exe

    See these Resources for more details on installing and getting started withCommunity Edition:

    Get started with WebSphere Application Server Community Edition

    Launcher and Installer options while installing WebSphere ApplicationServer Community Edition

    Silent installation of WebSphere Application Server Community Edition

    Verify your installation

    To verify that Community Edition has been installed properly, start the server usingeither of these tasks:

    Select Start => Programs => IBM WebSphere => Application ServerCommunity Edition => Start the server.

    Execute the startup.bin/sh file from the \bin folder, where is the Community Edition installation directory.

    Figure 1. Community Edition successful start

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 7 of 44

    http://www.ibm.com/developerworks/downloads/ws/wasce/trialsupport.htmlhttp://www.ibm.com/developerworks/downloads/ws/wasce/learn.html?S_TACT=105AGX28&S_CMP=DLMAINhttp://www.ibm.com/developerworks/websphere/techjournal/0512_gawor/0512_gawor.htmlhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221595&loc=en_US&s=UTF-8&lang=enhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221595&loc=en_US&s=UTF-8&lang=enhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221596&loc=en_US&cs=UTF-8&lang=enhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221596&loc=en_US&cs=UTF-8&lang=enhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221595&loc=en_US&s=UTF-8&lang=enhttp://www-1.ibm.com/support/docview.wss?rs=2359&context=SS6JMN&dc=DB520&uid=swg21221595&loc=en_US&s=UTF-8&lang=enhttp://www.ibm.com/developerworks/websphere/techjournal/0512_gawor/0512_gawor.htmlhttp://www.ibm.com/developerworks/downloads/ws/wasce/learn.html?S_TACT=105AGX28&S_CMP=DLMAINhttp://www.ibm.com/developerworks/downloads/ws/wasce/trialsupport.html
  • 8/14/2019 Database Applications Made Easy With WebSphere

    8/44

    Figure 1 shows a successful server startup message, along with a list of applicationsand application modules deployed on the server.

    Provided your installation was successful, launch the administrative console byaccessing this URL: http://hostname:portnumber/console, where portnumberrepresents the Tomcat Connector HTTP port. To login to the console, use thedefault admin user ID and password, which are system and manager, respectively.

    System administration

    Community Edition provides two ways for you to perform system administrationtasks:

    Administrative console

    Community Edition's Web-based administrative console provides a userfriendly interface for administering many aspects of the local or remoteserver. It's important to remember that the Web-based admin console

    depends on other components operating within the server (for example,OpenEJB) to function properly. If any of these components are stopped orremoved from the server configuration (for example, using theload="false" attribute in the corresponding element inconfig.xml), your browser will report an HTTP 404 or Not Found errorwhen you attempt to access the console. See Resources for anintroduction to many common admin tasks that you can perform using theconsole.

    Commands

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 8 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    9/44

    Commands for managing the server from a command prompt or terminalsession are also available for Community Edition. All commands arelocated in the \bin folder where is theCommunity Edition installation directory. (The one exception to this, theuninstaller command, is located in the \_uninst folder.)

    See the WebSphere Application Server product documentation in Resources fordetails on both system administration methods.

    Section 6. Install and configure DB2 Express-C

    As with Community Edition, DB2 Express-C is a fully licensed product available foryou to download and use for free. Be sure you review all the system prerequisites forDB2 Express-C and prepare your environment accordingly before proceeding withthe installation.

    Support for DB2 Express-CA 12-month support subscription is available for DB2 Express-C.

    After downloading DB2 Express-C, launch the installation wizard by executingsetup.exe/bin, and then follow the simple steps to complete the installation.

    To work with DB2 Express-C after installation, you can launch either of these

    interfaces, which are delivered with the DB2 Client:

    DB2 Command Line Processor (CLP): A text-based interface you canuse to run DB2 commands, database utilities, and SQL statements.

    DB2 Control Center: A graphical interface you can use to manage andadminister database systems, databases, and database objects. You canalso open other centers and tools from the Control Center.

    Figure 2. DB2 Express-C first steps

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 9 of 44

    http://www.ibm.com/db2/expresshttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/db2/express
  • 8/14/2019 Database Applications Made Easy With WebSphere

    10/44

    If you are a novice user, the DB2 Express-C First Steps tool introduces you to basicdatabase maintenance tasks and directs you to information on how to use the CLPand the Control Center to perform some of these tasks. First Steps also points youto additional resources about DB2 database systems.

    To launch DB2 First Steps, select Start => Programs => IBM DB2 => Setup Tools=> First steps.

    See Resources to get a good headstart with DB2 Express-C.

    Section 7. Install and configure Eclipse components

    Community Edition requires the Eclipse Web Tools Platform (WTP) for developingand deploying applications. You must have these prerequisite project packages

    installed before you you can install or use WTP:

    Eclipse Platform (Platform, JDT, PDE)

    Eclipse Modeling Framework (EMF, XSD InfoSet, SDO)

    Graphical Editing Framework (GEF)

    Data Tools Platform (DTP)

    You can download these packages separately or you can get them together in theWTP All-In-One zip package, which contains the complete set of prerequisite

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 10 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    11/44

    software distributions from the Europa release so you can begin using WTPimmediately.

    If you install the packages separately, you must first extract the basic Eclipseplatform to the local system directory, then extract the remaining packages under the

    \plugins directory in the sequence specified above, then extractWeb Tools Platform to the plugins directory.

    Eclipse Workbench

    The Eclipse Workbench is the environment in which all of your applicationdevelopment will be performed. To launch the workbench:

    1. Navigate to the Eclipse home folder.

    2. Execute the eclipse.exe/bin file or run the eclipse command under the\bin directory. If you are doing this for the first time, thenexecute the command with the clean option, eclipse -clean, whichmakes Eclipse recognize newly installed plug-ins.

    3. Specify the directory path for your workspace. Eclipse SDK will store yourprojects in a folder called "workspace" (Figure 3).Figure 3. Eclipse workspace

    4. Figure 4 shows the Eclipse workbench environment with four mainpanels:

    Left panel lists your projects.

    Middle panel is where you can work on or code your project files.

    Right panel shows the outline of the work item in the center pane.

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 11 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    12/44

    Lower panel lists views to help you troubleshoot and deploy theproject.

    (You can maximize or minimize any panel by double clicking on it.)Figure 4. Eclipse Workbench panels

    Section 8. Install and configure Community Edition WTPAdapter

    Installation alternativeTo install the same plug-in offline, download and extract thewasce-eclipse-plugin-2.0.0-updatesite.zip file into your localdirectory, then click New Local Site... and point to that directory.

    Click OK and then Finish.

    A new WTP server adapter is available that supports both Community EditionVersions 1.1.0.x and 2.0. To configure the WTP adapter for Community Edition V2.0:

    1. Launch the installation wizard for new features and plug-ins in Eclipse byselecting Help => Software Updates => Find and Install (Figure 5).Figure 5. Launch Update Install manager

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 12 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    13/44

    2. Select Search for new features to install.

    3. Select New Remote Site... and then add the download URL (Figure 6):http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasc

    Figure 6. Specify remote repository URL

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 13 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    14/44

    4. Select the list of options that need to be installed through this plug-in,which include all the options selected in Figure 7.Figure 7. Select the options of features to install

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 14 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    15/44

    5. In the next panel, read and accept the terms in the license agreement.

    6. The update manager will download the files from the remote repository. Ifyou prefer that this process be performed in the background, click theRun in Background button.

    7. Click Install in the Feature Verification panel (Figure 8).Figure 8. Feature install verification

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 15 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    16/44

    8. When the system asks for restart, click Yes and restart the Eclipse SDKfor the changes to take affect.

    Installation of the Community Edition adapter is now complete. You now need to addthe Community Edition runtime for application deployment.

    Add Community Edition to the configuration

    To add Community Edition so that it is listed in the Servers view:

    1. Select Window => Show View => Other... (Figure 9).Figure 9. Add new view to Eclipse workbench

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 16 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    17/44

    2. In the list, expand the Servers section. Select Servers and click OK. TheServers view is added to the lower panel of the Eclipse workbench.

    3. Right-click in the new Servers view, the select New => Server.

    4. In the New Server dialog, select IBM WASCE v2.0 Server and then Next(Figure 10).Figure 10. Select Community Edition V2.0 server

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 17 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    18/44

    5. In the Edit Server Runtime dialog, select the proper JRE runtime versionfor the JRE field, then browse and select the Community Edition

    installation folder for the Application Server Installation Directory field(Figure 11).Figure 11. Specify applicable Community Edition installation values

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 18 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    19/44

    6. In the New Server dialog (Figure 12), enter appropriate values for theHostname, Administrator id, and Administrator password, and then click

    Finish.Figure 12. Specify server administration values

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 19 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    20/44

    Your Community Edition server has now been successfully added to Eclipse.

    Running Community Edition within Eclipse

    You can operate Community Edition within Eclipse in one of three modes:

    Start Server mode

    This is a typical server startup mode. When started in this mode, theserver gets started along with the applications deployed on the server.

    To start the server in this mode, go to the Servers view, right-click on theserver, and then click the Start icon on the popup window. (The server

    is automatically started when you right-click on a file and then select RunAs => Run on Server.)

    Debug mode

    If you want to debug your projects while a server is running, you can starta server in debug mode. Once the server is running in debug mode youcan run the projects that are associated with the server, and then stopand restart the server at any time. The status of the server is displayed in

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 20 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    21/44

    the Status column of the Servers view. The status of the breakpoints inyour file is displayed in the Debug view.

    To start the server in this mode, go to the Servers view, right-click on theserver, and then click the Debug icon . The status of the server

    changes to debugging.

    Profile mode

    Data related to an application's run time behavior can be collected andpresented in both graphical and tabular views while the application isrunning. This occurs in profile mode, where you can see which operationstake the most time; this can help you find and resolve memory leaks.Once you have started a server in profile mode, you can run the projectsthat are associated with its configuration, and then stop and restart theserver at any time. The status of the server is displayed in the Statuscolumn of the Servers view.

    To start the server in this mode, go to the Servers view, right-click on theserver, and then select the Profile icon . The status of the server

    changes to profiling.

    To stop Community Edition, go to the Servers view, right-click on the server to bestopped, then click the Stop icon from the list. (You can also start or stop the

    server by clicking the appropriate icon on the right corner of lower panel of Eclipse.)

    To launch the administrative console, go to the Servers view and right-click on theserver you want to administer. Select the Launch WASCE Console option from thelist. Login to the console using your administrators ID and password (default valuesare system and manager, respectively.

    Section 9. Create a sample application

    With your environment setup now complete, this section presents an exercise tohelp you get some hands-on experience creating and deploying a Web applicationwith the Eclipse development platform. In this exercise, you will create a sampleWeb application that contains JSP and servlet pages.

    Create an Eclipse project

    1. To work with Java EE components easily, your Eclipse workbench shoulddisplay the Java EE perspective. In Eclipse, the current perspective is

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 21 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    22/44

    displayed in the right corner. If you need to change the perspective, selectWindow => Open Perspective => Other... => Java EE.

    2. To create a new project in Eclipse, right-click on the left panel (the ProjectExplorer window), then select New => Project => Web => Dynamic Web

    Project, then click Next (Figure 13).Figure 13. Create new dynamic Web project

    3. Specify your new Project name. For the purpose of this exercise, nameyour project Test (Figure 14). Also, select these values:

    Target Runtime: IBM WASCE v2.0

    Configurations: Default Configuration for WASCE v2.0

    Do not check Add project to an EAR (this option is for creating anenterprise application). Click Next.Figure 14. Specify project name

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 22 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    23/44

    4. Specify a value for Context Root, which provides the unique URL qualifierfor the applications deployed on the server. In this example, use Test(Figure 15).Figure 15. Specify context root for the project

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 23 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    24/44

    5. Select Generate Deployment Descriptor to generate the basictemplates of the deployment descriptors. (If you do not select this option,

    you can create the deployment descriptors later by right-clicking theproject, then select Java EE =>Generate Deployment Descriptor stub).Specify Version as 2.0.

    6. Specify (optional) values for Group Id, Artifact Id, Version, and ArtifactType (Figure 16), then click Finish to create the Dynamic Web Project.Figure 16. Mentioning Artifact Id and Type for the deployment

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 24 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    25/44

    Upon successful creation, the Test project will display in the Project Explorer panel.

    Create a JSP page

    To create a sample JSP page:

    1. In the Project Explorer panel, navigate to the new Test project.

    2. Right-click on WebContent and select New (Figure 17).

    3. Select JSP from the list that displays. (If JSP does not display, selectOther => Web => JSP).

    4. In the New JavaServer Page panel, enter a name for the JSP, such asTest, and then click Finish. If successful, a Test.jsp file will be created inthe WebContent folder with the basic JSP template.

    Figure 17. Create new JSP page

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 25 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    26/44

  • 8/14/2019 Database Applications Made Easy With WebSphere

    27/44

    7. Save the JSP file.

    Create a servlet

    To create a sample servlet:

    1. In the Project Explorer panel, navigate to the Test project.

    2. Right-click on WebContent and select New => Other. Expand Web andselect Servlet.

    3. For Java package, enter com.test.servlet, and for Class name, enterTestServlet. Click Next.Figure 18. Create sample servlet

    4. In the next dialog, click the Add button to add initialization parametersand URL mappings.

    5. Next, on the Select Modifiers, interfaces to implement, and method stubsto generate panel, the items shown in Figure 19 should be checked bydefault. Click Finish to create the servlet.Figure 19. Specifying interfaces and methods in servlets

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 27 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    28/44

    6. Upon successful creation, the TestServlet.java file will be created underJava resources, in the src\com.test.servlet folder with the basic servlettemplate.

    7. To launch the file for editing, navigate to the Test project in the ProjectExplorer, and double-click on the TestServlet.java file.

    8. For the purpose of this exercise, copy and paste the sample code fromListing 2 into the TestServlet.java file. (This sample code displays "Youare here seeing the sample JSP page deployed on Community Edition2.0!!" as a body message and "Community Edition 2.0 - Sample JSPPage" as a title message.)Listing 2. Sample servlet code

    package com.test.servlet;

    import java.io.*;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;

    /*** Servlet implementation class for Servlet: TestServlet

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 28 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    29/44

    **/public class TestServlet extends javax.servlet.http.HttpServlet implements

    javax.servlet.Servlet {static final long serialVersionUID = 1L;

    /* (non-Java-doc)* @see javax.servlet.http.HttpServlet#HttpServlet()*/

    public TestServlet() {super();

    }

    /* (non-Java-doc)* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,* HttpServletResponse response)*/

    protected void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

    doPost(request,response);

    }

    /* (non-Java-doc)* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,* HttpServletResponse response)*/

    protected void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

    PrintWriter out = response.getWriter();out.println("Sample Serlvet page on Community Edition

    2.0");

    out.println("");out.println(" You are here seeing

    the sample Servlet deployed on Community Edition 2.0..!!!");out.println("");

    }}

    9. Save the servlet file.

    Deploy the sample application on Community Edition

    Community Edition uses a Geronimo-specific deployment descriptor, also referred toas a deployment plan, which has a format that looks like a J2EE 1.4 deploymentdescriptor, but differs in that it is specific to the application server. It is an XML filebased on an XML schema that contains configuration information related to the

    application module or service.

    The Community Edition WTP adapter for Eclipse provides an editor for Geronimodeployment plans with which you can easily modify the context root value, and addor modify resource references, security roles, dependencies, and so on.

    Figure 20. Geronimo Deployment Plan Editor

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 29 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    30/44

    Deployment alternativeIf you wish to use an alternative method for deployment, you canright-click on the Test project in the Project Explorer window, selectRun As => Run on Server, select the Community Edition server,then click Finish to deploy the project.

    To deploy the sample application on Community Edition:

    1. In the Servers view, right-click on the Community Edition server andselect Add or Remove Projects.

    2. The Add and Remove Projects panel has two sections:

    Available projects lists the projects that are available in Eclipse.

    Configured projects lists the projects deployed on Community Edition(Figure 21).

    Select the Test project from the Available projects list, click the Addbutton, then click Finish.Figure 21. Add and Remove Projects

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 30 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    31/44

    The project is now successfully deployed on the Community Edition server.

    To remove (or undeploy) the project from the server, navigate to the Add andRemove Projects panel (Figure 21), select the project under Configured projects,click Remove, and then Finish.

    To run the application you just deployed on Community Edition, access this URLusing a Web browser: http://localhost:portnumber//. (The value ofcontext-rootcan be found in the geronimo-web.xml file.) Alternatively, you can alsoclick the URL corresponding to your application from the Applications section of theWeb console.

    Section 10. Create a database application

    Next, you can put together your main enterprise database application.

    With your Web application built, you will now deploy another sample Web project,called StudentWeb, that uses DB2 Express-C as a backend database server, create

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 31 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    32/44

    a database pool for this application, then package everything in an EAR file anddeploy it all on Community Edition.

    To do this will requires two additional tasks:

    Create the database and related components on the database server.

    Create a database pool (data source) in Community Edition.

    Create a database

    To create the database and tables required for the application:

    1. Launch the DB2 Express-C Control Center by selecting Start =>Programs => IBM DB2 => General Administration Tools => Control

    Center.

    2. Right-click on All Databases and select Create Database => Standard(Figure 22).Figure 22. Create database in DB2 Express-C Control Center

    3. Enter a database name, such as student, and click Finish.

    4. Expand the new database, student, that you just created.

    5. Right click on Tables then select Create.

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 32 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    33/44

    6. Enter a name (you can use student again) and description for the table,then click Next.

    7. Click the Add button to create the columns required for the table. Add thecolumns as shown in the table below for this sample project.

    Column name Data type Length

    Rollno VARCHAR 30

    Name VARCHAR 50

    Dob VARCHAR 30

    8. Click Finish when done. You have now created the database and therequired table for the sample database application.

    9. Download the sample Web Archive (WAR) application included with thistutorial, StudentWeb, to your local system. StudentWeb uses the JSP fora display page (view) and a servlet for the controller logic. (This sampleapplication adds and displays records from a table called "student.") Inthe Project Explorer in Eclipse, right-click then select Import => WAR file.

    10. Browse to the WAR file you want to import (Figure 23) and select the AddProject to an EAR option (the Web module will be packaged with EARfile later).Figure 23. Import WAR file

    11. Click Finish. The Web module StudentWeb and the application module

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 33 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    34/44

    StudentWebEAR have been created and should be displayed in theProject Explorer panel.

    Create a database pool

    A database pool is a data structure that contains information about a specificdatabase that the JDBC driver needs in order to connect to that database.Community Edition provides database connection pools with which you can bind acertain database to JNDI and access it from your applications.

    Listing 3 shows sample code for creating a database pool.

    Listing 3. DB2 Express-C database pool deployment plan

    console.dbpoolstudentpool1.0rar

    com.ibm.db2db2jcc9.1

    jar

    com.ibm.db2db2jcc_license_cu9.1jar

    javax.sql.DataSource

    studentpool

    G00dluck

    com.ibm.db2.jcc.DB2Driver

    Anitha

    jdbc:db2://localhost:50001/student

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 34 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    35/44

    100

    When you deploy the above code on Community Edition, the correspondingdatabase pool, named studentpool, is created on the server. To deploy the plan:

    1. For the purpose of this exercise, copy and paste the above code into anXML file called dbplan-file.xml.

    2. Add this plan file to the top level of your EAR file directory structure, under

    EarContent.

    3. Copy the RAR file fromGERONIMO_HOME/\repository\org\tranql\tranql-connector-ra\1.3\tranql-connector-ra-1.to the top level of your EAR file under EarContent.

    Modify database connection information as appropriate for your environment (that is,database name, user ID, password, and so on).

    In the META-INF\geronimo-application.xml in EAR file

    Listing 4 shows how to specify the resource references in thegeronimo-web.xml file.

    Listing 4. Sample geronimo-application.xml

    ---> Application module configuration

    defaultStudentWebEAR2.0ear

    tranql-connector-ra-13.rar ---> Resource Adapterdbplan-file.xml ---> Database pool plan

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 35 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    36/44

    You need to include XML file and the Resource adapter values in theGeronimo-application.xml file between and tags.This will create the corresponding database pool on the CommunityEdition server during application deployment. Make sure that the filenames are correct.

    Create the connection between your application and thedatabase pool

    To enable your application to connect to the database through your new databasepool, you need to create a connection between the application and the databasepool. To do this, you need to declare a resource reference and map it to a specificconnection pool available to the application module (the module code must look upthe connection pool through JNDI.)

    In the WEB-INF/web.xml in the WAR file

    Once the database pool has been deployed, application modules canrefer to it using the name specified in the configuration information. To dothis, declare a resource-ref with a type of javax.sql.DataSource in itsstandard J2EE deployment descriptor (web.xml). Listing 5 shows how tospecify the resource reference in the web.xml file.

    Listing 5. web.xml

    jdbc/MyDataSource ---> Resource referencejavax.sql.DataSourceContainerShareable

    In the WEB-INF/geronimo-web.xml in the WAR file

    In the Geronimo deployment plan for that module, you need to specifywhich connection pool in the server will be used to satisfy the data sourcerequired by the Web module. To do this, you need to specify the name ofthe database pool to the ref-name which should be mapped with theresource-ref in web.xml. Listing 6 shows how to specify the resourcereference in the geronimo-web.xml file.

    Listing 6. geronimo-web.xml

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 36 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    37/44

    StudentWeb2.0war

    /StudentWeb

    jdbc/MyDataSource ---> Resource referencestudentpool

    The database pool name mentioned in your sample database applicationis "studentpool." You can find this value from the database pool plan inListing 4.

    Application code for looking up the database connection pool

    Listing 7 shows the code in the application module to lookup the created databaseconnection pool.

    Listing 7. Application code

    InitialContext ctx = new InitialContext();

    DataSource ds = ctx.lookup("java:comp/env/jdbc/MyDataSource"); ---> Resource referenceConnection con = ds.getConnection();

    The JNDI lookup string is java:comp/env/ plus the res-ref-name used in web.xml(Listing3). Also, keep in mind that the resource reference name jdbc/MyDataSourceshould be the same in web.xml, geronimo-web.xml, and in the application code.

    Deploy and launch the database application

    To deploy the sample application in Community Edition:

    1. In the Servers view, right-click on the Community Edition server.

    2. Click on Add or Remove Projects.

    3. Select the StudentWebWAR project from Available Projects and clickAdd (Figure 21).

    4. Click Finish. The project is now deployed on the Community Editionserver.

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 37 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    38/44

    5. Once deployed, you can launch the application by accessing this URLfrom your Web browser: http://localhost:portnumber/. TheURL for the sample StudentWebEAR database application is:http://localhost:portnumber/studentweb/.

    Figure 24. Sample database application

    (The value of context-rootcan be found in the geronimo-web.xml file.Alternatively, you could also click the URL corresponding to theapplication in the Applications section of the Web console.)

    Section 11. Troubleshooting

    Should you encounter any errors during deployment, chances are it will be due toone of these issues:

    Problem 1

    Deployment failed:Unable to resolve resource reference 'jdbc/MyDataSource' (Couldnot find resource'samplepool'. Perhaps it has not yet been configured, or yourapplication does nothave a dependency declared for that resource module

    Cause: This error occurs when the application tries to connect to a database poolthat does not exist on the server.

    Solution: If you are bundling your Web application and the database pool in thesame EAR file, then make sure you are specifying the correct name for the database

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 38 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    39/44

    pool in the Geronimo-web.xml file. This name can be found in the database pooldeployment plan. If you are deploying the Web application separately, then createthe database pool before you deploy the application.

    Problem 2

    Caused by: org.apache.geronimo.kernel.repository.MissingDependencyException: Unable toresolve dependency console.dbpool/studentpool//

    atorg.apache.geronimo.kernel.repository.DefaultArtifactResolver.resolveInClassLoader(DefaultArtifactResolver.java:123)

    atorg.apache.geronimo.kernel.repository.DefaultArtifactResolver.resolveInClassLoader(DefaultArtifactResolver.java:102)

    atorg.apache.geronimo.kernel.repository.DefaultArtifactResolver$$FastClassByCGLIB$$e847b746.invoke()

    atnet.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)

    atorg.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)

    Cause: If you are bundling your Web application and the database pool deploymentplan in the same EAR file, you do not need to add the database pool as adependency in Geronimo-web.xml file like this:

    console.dbpoolstudentpool

    This is only required when you are deploying the Web application and the databasepool separately. This error occurs when you add the database pool as a dependencywhen deploying both application and the database pool through same EAR.

    Solution: Remove the dependency lines for the database pool from theGeronimo-web.xml file.

    Problem 3

    Invalid alt vendor dd url: databaseplan-file.xmlorg.apache.geronimo.common.DeploymentException: Invalid alt vendor dd url:databaseplan-file.xml

    atorg.apache.geronimo.j2ee.deployment.EARConfigBuilder.mapVendorPlans(EARConfigBuilder.java:1030)...Caused by: java.io.FileNotFoundException: JAR entry databaseplan-file.xml not found inC:\DOCUME~1\Anitha\LOCALS~1\Temp\geronimo-deployer8118.tmpdir\Junk.ear

    at sun.net.www.protocol.jar.JarURLConnection.connect(Unknown Source)

    Cause: This error occurs when the geronimo-application.xml file points to the wrong

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 39 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    40/44

    database plan file.

    Solution: Make sure that geronimo-application.xml points to the proper databaseplan and resource adapter file, as in this geronimo-application.xml code:

    Problem 4

    22:47:50,265 ERROR [[jsp]] Servlet.service() for servlet jsp threw exceptionjava.lang.NullPointerException

    at org.apache.jsp.student_jsp._jspService(student_jsp.java:106)at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

    Cause: This error occurs when there is a mismatch between the resource mappingsin web.xml and either the geronimo-web.xml file or resource JNDI lookup in theapplication code.

    Solution: Make sure that resource reference in web.xml and geronimo-web.xml ismapping properly with the resource JNDI lookup code in the application.

    Problem 5

    22:59:10,359 WARN [ConnectorModuleBuilder] Problem loading driver class'com.ibm.db2.jcc.DB2Driver', possibly due to a missing dependency on the driver jar!!java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver in classloaderdefault/StudentWebEAR/2.0/ear

    Cause: This error occurs when the database pool plan doesnt contain the requireddependency JAR files.

    Solution: Add the required driver JAR files in the database pool plan as

    dependencies, as in this code sample:

    com.ibm.db2db2jcc9.1jar

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 40 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    41/44

    Section 12. Conclusion

    This article offered a technical introduction to working with WebSphere ApplicationServer Community Edition V2.0, DB2 Express-C, and Eclipse with a sampledatabase application development exercise. The exercise provided hands-onexperience with:

    Installing and setting up the Community Edition, DB2 Express-C, andEclipse environments.

    Creating database artifacts required for the application.

    Developing a sample database application in Eclipse.

    Deploying the sample database application on Community Edition.See the Resources section for a deeper understanding of these products, andexperiment further by deploying the sample applications available from theCommunity Edition download page, and with your own test applications.

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 41 of 44

    http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtml
  • 8/14/2019 Database Applications Made Easy With WebSphere

    42/44

    Downloads

    Description Name Size Download method

    0802_krishnasamy.ZIP925 KB HTTP

    Information about download methods

    developerWorks ibm.com/developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and EclipsePage 42 of 44 Copyright IBM Corporation 1994, 2007. All rights reserved.

    http://download.boulder.ibm.com/ibmdl/pub/software/dw/wes/0802_krishnasamy/0802_krishnasamy.ZIPhttp://www.ibm.com/developerworks/library/whichmethod.htmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/library/whichmethod.htmlhttp://download.boulder.ibm.com/ibmdl/pub/software/dw/wes/0802_krishnasamy/0802_krishnasamy.ZIP
  • 8/14/2019 Database Applications Made Easy With WebSphere

    43/44

    Resources

    Learn

    WebSphere Application Server Community Edition product documentation

    DB2 Express-C Information Center

    The Eclipse Foundation

    Eclipse documentation

    WebSphere Application Server Community Edition resources

    Get started with WebSphere Application Server Community Edition

    Using the Web console in WebSphere Application Server Community Edition

    Advanced administration in WASCE: Working with database realms and

    security elements Get to know Java EE 5

    Recommended Eclipse reading list

    IBM developerWorks WebSphere

    Get products and technologies

    Download IBM WebSphere Application Server Community Edition V2.0

    Download IBM DB2 Express-C 9.1

    Download Eclipse SDK 3.3 and Web Tools Platform 2.0

    Download WebSphere Application Server Community Edition V2.0 WTPAdapter (formerly Eclipse plug-in)

    Discuss

    Forum: IBM WebSphere Application Server Community Edition and ApacheGeronimo

    About the authorsAnitha Krishnasamy

    Anitha Krishnasamy is a Software Engineer working with the WebSphere BPTSEteam in the IBM India Software Labs, Bangalore. Anitha's areas of expertise includebusiness integration and J2EE technologies, and she holds a masters degree inComputer Applications from the National Institute of Technology, Trichy, India.

    ibm.com/developerWorks developerWorks

    Database applications made easy with WebSphere Application Server Community Edition, DB2 Express-C and Eclipse Copyright IBM Corporation 1994, 2007. All rights reserved. Page 43 of 44

    http://publib.boulder.ibm.com/wasce/Front_en.htmlhttp://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsphttp://www.eclipse.org/http://www.eclipse.org/documentation/http://www.ibm.com/developerworks/websphere/zones/was/wasce.htmlhttp://www.ibm.com/developerworks/websphere/techjournal/0512_gawor/0512_gawor.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0608_krishnasamy/0608_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0702_krishnasamy/0702_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0702_krishnasamy/0702_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0707_barcia/0707_barcia.htmlhttp://www.ibm.com/developerworks/opensource/library/os-ecl-read/?S_TACT=105AGX44&S_CMP=ECLLPhttp://www.ibm.com/developerworks/websphere/http://www.ibm.com/developerworks/downloads/ws/wasce/support.htmlhttp://www-306.ibm.com/software/data/db2/express/download.htmlhttp://download.eclipse.org/webtools/downloads/http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/http://www.ibm.com/developerworks/websphere/http://www.ibm.com/developerworks/websphere/http://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/legal/copytrade.shtmlhttp://www.ibm.com/developerworks/websphere/http://www.ibm.com/developerworks/websphere/http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/http://download.boulder.ibm.com/ibmdl/pub/software/websphere/wasce/updates/http://download.eclipse.org/webtools/downloads/http://www-306.ibm.com/software/data/db2/express/download.htmlhttp://www.ibm.com/developerworks/downloads/ws/wasce/support.htmlhttp://www.ibm.com/developerworks/websphere/http://www.ibm.com/developerworks/opensource/library/os-ecl-read/?S_TACT=105AGX44&S_CMP=ECLLPhttp://www.ibm.com/developerworks/websphere/library/techarticles/0707_barcia/0707_barcia.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0702_krishnasamy/0702_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0702_krishnasamy/0702_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/library/techarticles/0608_krishnasamy/0608_krishnasamy.htmlhttp://www.ibm.com/developerworks/websphere/techjournal/0512_gawor/0512_gawor.htmlhttp://www.ibm.com/developerworks/websphere/zones/was/wasce.htmlhttp://www.eclipse.org/documentation/http://www.eclipse.org/http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsphttp://publib.boulder.ibm.com/wasce/Front_en.html
  • 8/14/2019 Database Applications Made Easy With WebSphere

    44/44

    Sridhar Kuna

    Sridhar Kuna is a Staff Software Engineer working with the WebSphere Adaptersteam in IBM India Software Labs, Bangalore. His area of expertise includes businessintegration and J2EE technologies. Sridhar holds a Masters degree in SoftwareEngineering from Birla Institute of Technology and Science, India.

    developerWorks ibm.com/developerWorks