borland introduction jbuilder 7 and websphere 4.0 integration · ® websphere ® 4.0 integration...

45
Borland ® JBuilder 7 and IBM ® WebSphere ® 4.0 Integration Jump start developing, deploying, debugging EJBs and JSPs by Sudhansu Pati, Systems Engineer Borland Software Corporation August 2002 Introduction Borland ® JBuilder Enterprise is the most comprehensive set of award-winning visual development tools for creating enterprise-scale applications written entirely in the Java programming language for the Java 2 Platform, Enterprise Edition (J2EE ). JBuilder 7 Enterprise provides integration with the market-leading J2EE platform application servers like Borland ® Enterprise Server, BEA ® WebLogic Server 5.1, 6.0, 6.1, 7.0, IBM ® WebSphere ® 3.5, 4.0, iPlanet 6.0, 6.5, Oracle9i Application Server, Sybase ® EAServer, and JBoss. This paper provides an overview of the development, deployment, and debugging life cycle of Enterprise JavaBeans (EJB ) and JavaServer Pages (JSP ) with Borland JBuilder 7 Enterprise and IBM WebSphere 4.0 Advanced Edition Single-Server (AES). The platforms and software used to create the exercises are JBuilder 7 Enterprise, Oracle ® 8.1.7, WebSphere 4.0 AES, and Microsoft ® Windows XP and Internet Explorer ® 6.0. This paper is not a reference on developing EJBs, JSPs/servlets, or Java technologies. Rather, it provides a jump- start while using JBuilder 7 Enterprise with WebSphere 4.0 AES, allowing developers to reach maximum productivity in the minimum amount of time. Contents Installing JBuilder 2 Installing WebSphere 4.0 AES 2 Configuration 3 Working with JSP and servlets 6 Troubleshooting 15 Working with session bean 17 Troubleshooting 24 Working with entity bean 26 Troubleshooting 38 Remote debugging 40 Troubleshooting 43 Additional information 45 Feedback and suggestions 45

Upload: others

Post on 22-May-2020

23 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland®

JBuilder™ 7 andIBM® WebSphere®

4.0 IntegrationJump start developing, deploying,debugging EJBs™ and JSPs™

by Sudhansu Pati, Systems EngineerBorland Software Corporation

August 2002

Introduction

Borland® JBuilder™ Enterprise is the most comprehensive set

of award-winning visual development tools for creating

enterprise-scale applications written entirely in the Java™

programming language for the Java 2 Platform, Enterprise

Edition (J2EE™). JBuilder 7 Enterprise provides integration

with the market-leading J2EE platform application servers like

Borland® Enterprise Server, BEA® WebLogic Server™ 5.1,

6.0, 6.1, 7.0, IBM® WebSphere® 3.5, 4.0, iPlanet™ 6.0, 6.5,

Oracle9i™ Application Server, Sybase® EAServer, and JBoss.

This paper provides an overview of the development,

deployment, and debugging life cycle of

Enterprise JavaBeans™ (EJB™) and JavaServer Pages™ (JSP™)

with Borland JBuilder 7 Enterprise and IBM WebSphere 4.0

Advanced Edition Single-Server (AES).

The platforms and software used to create the exercises are

JBuilder 7 Enterprise, Oracle® 8.1.7, WebSphere 4.0 AES, and

Microsoft® Windows XP™ and

Internet Explorer® 6.0.

This paper is not a reference on developing EJBs,

JSPs/servlets, or Java technologies. Rather, it provides a jump-

start while using JBuilder 7 Enterprise with WebSphere 4.0

AES, allowing developers to reach maximum productivity in

the minimum amount of time.

ContentsInstalling JBuilder™ 2Installing WebSphere™ 4.0 AES 2Configuration 3Working with JSP™ and servlets 6Troubleshooting 15Working with session bean 17Troubleshooting 24Working with entity bean 26Troubleshooting 38Remote debugging 40Troubleshooting 43Additional information 45Feedback and suggestions 45

Page 2: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

2

Installing JBuilder™ 7Platforms, system requirements, and registration

JBuilder 7 can be installed in Windows,® Solaris,™ Linux,® or Mac® OS X platforms. The minimum systemrequirement for JBuilder 7 Enterprise is 256MB. Also the recommended hard disk space is 700MB. Refer tothe link http://www.borland.com/jbuilder/pdf/jb7_sysreqs.pdf for the details.

JBuilder can be installed with a trial or licensed CD which can be obtained from a Borland Sales Office. AfterJBuilder 7 installation, obtain the trial license key from the following linkhttp://www.borland.com/products/downloads/download_jbuilder.html.

If you already have the license keys, register JBuilder with those keys.

Tuning JBuilder™ 7The default heap size for the Java™ Virtual Machine (JVM™) can be changed in<JBuilder_Installed_Dir>\bin\jbuilder.config

Change the size of the heap to suit to your machine environment in the following two lines of jbuilder.config.

vmparam –Xms32m

vmparam -Xmx128m

Note: For the rest of this white paper, the JBuilder 7 installation directory is assumed asC:\Borland\JBuilder7.

Installing IBM® WebSphere® 4.0 AESPlease check with the IBM Web site http://www-3.ibm.com/software/webservers/appserv/ for installationinstructions, system requirements, and registration process.

IBM WebSphere has Standard, Advanced, and Enterprise editions. This white paper uses Advanced SingleServer Edition.

Note: For the rest of the white paper, the WebSphere installation directory is assumed asC:\WebSphere.

JBuilder does not require WebSphere 4.0 to be installed in the same machine where JBuilder is installed.WebSphere can be installed anywhere in the network. If WebSphere is installed in UNIX, the drives must beavailable via NFS, SAMBA etc.

SAMBA is available from www.samba.org or ftp://ftp.samba.org/pub/samba/ Selectsamba-latest.tar.gz. Note that JBuilder 7 does not include any software or licenses for WebSphere.

Installing the database A database has to be installed to work with Entity Beans. For this white paper, Oracle 8.1.7 is installed inC:\oracle\ora81.

Oracle can be installed in the same machine or any other machine in a different operating system. It is notrequired to provide Oracle installation directory access to JBuilder. JBuilder is a pure Java IDE, and it canaccess Oracle using the Oracle JDBC® driver classes12.zip.

Make sure that Oracle is up and running during this exercise.

For this white paper, it is assumed that ORCL database is installed. ORCL is a default database and getsinstalled with Oracle. You can work with any other database you like, but this white paper will use the ORCLdatabase.

Make sure that ORCL database is up and running.

Page 3: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

3

Configure JBuilder™ 7 with WebSphere® 4.0 AESTo configure JBuilder 7 with WebSphere 4.0 AES, start JBuilder 7, from the JBuilder menu bar. Click Tools ->Configure Servers. Select WebSphere Application Server Single Server 4.0 from the left-hand pane. ClickEnable Server checkbox. Enter C:\WebSphere\AppServer under Home Directory (if your IBMWebSphere Installation Directory is something other than C:\WebSphere, change the entry accordingly).The Main Class, VM parameters and Working Directory fields should be automaticallypopulated.

Click the General tab from the right-hand pane. Hit the Add button and add jaxrpc.jar fromC:\Borland\JBuilder7\lib and click Move Up to make it the first jar file. Note that this jar file isrequired only if you want to test Web Services.

Click the General tab from right-hand pane. Hit the Add button and add classes12.zip fromC:\oracle\ora81\jdbc\lib. Note that these jar files are required only if you want to test Entity Beanswith Oracle database.

See Figure 1 for details.

Figure 1: Configuration of WebSphere with JBuilder 7

Note: Make sure that the node name specified in JBuilder Server Parameters window is consistent with thenode name specified in server-cfg.xml. To check the consistency, open server-config.xml with yourfavorite editor, look for a line startling like <nodes xmi:id. Many times the ID and name fields are blank.You can specify any ID and name you like. An example is shown below.

<nodes xmi:id="SUDS" name="SUDS">

Save the changes to server-cfg.xml. In JBuilder Configure Servers window, click the ellipses on ServerParameters, and specify the same node name as you have specified in server-cfg.xml.

Page 4: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

4

Click the Custom tab. If you have installed IBM® DB2,® provide the DB2 Installed Directory name. Note thatJBuilder has already picked up the JDK® from WebSphere.

Configuration of Oracle® database

The Oracle database has to be configured with JBuilder, so that JBuilder knows the location of the JDBC®

driver classes12.zip. Create a library for JDBC® driver for Oracle database

From JBuilder menu bar, click Tools -> Configure Libraries. JBuilder opens the Configure Libraries window.

From the left-hand panel, click New. In the New Library Wizard, enter name as Oracle and select Locationas User Home. Click Add and find classes12.zip from the network.

This process creates a library named Oracle in JBuilder and adds the library to JBuilder User Home. See Figure2 for details.

Figure 2: Create a library to hold classes12.zip

Page 5: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

5

Create Oracle® database configuration

From the JBuilder main menu bar, click Tools -> Enterprise Setup -> Click Database Driver tab from theEnterprise Setup window. Click Add, and from Select one or more Libraries window, clickOracle from User Home.

Now you should find an entry Oracle.config in the Enterprise Setup window. JBuilder adds the library toits classpath. So from now onwards, JBuilder knows where the oracle driver classes12.zip is.

Test the Oracle® connection

This step is not required if you are already working with JBuilder and Oracle, and you are sure that the Oracledatabase is accessible from your JBuilder environment.

To test the Oracle database connection, start the Database Pilot. Database pilot can be started by clickingTools -> Database Pilot.

From the Database Pilot window, click File | New ->select oracle.jdbc.driver.OracleDriver from thecombo box in New URL window and provide the url name under the URL textbox. The URL used for ourexercise is jdbc:oracle:thin:@hostname:1521:ORCL.

Now an URL entry for Oracle as oracle:thin:@localhost:1521:ORCL is created under DatabaseURLs. Double-click on this url, provide user ID and password to connect to ORCL database. You can usethe default User ID scott and default password tiger.

Now using the Database Pilot, you can see most of the database information including the stored procedures,tables, columns, fields, definitions, data. etc. You can also execute SQL queries from Database Pilot.

Figure 3 shows data from table EMP.

Figure 3: Database Pilot; you can see the contents of table EMP

Page 6: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

6

Working with JSPs™ and servletsCreate a project

Start JBuilder. Click File -> New -> Select Project tab from the Object Gallery window -> click Project ->click OK. In the Project Wizard–Step 1 of 3, specify a Directory Name and a Project Name. Leave theTemplate as (Default Project). Hit Finish.

Note: For this exercise, the project directory is C:/JBWebSphere and Project Name is TestWeb.

Attach the WebSphere® Server to current project

You can attach WebSphere Server to the current project. From the JBuilder menu bar, click Project -> ProjectProperties -> Click Server tab.

See Figure 4 for details.

Figure 4: Option to use Single Server for all services; you can even use modular services provided by different servers

Note: JBuilder provides the users with the options of choosing one server for all services in the project ormultiple servers providing different servers. Choosing Modular Services provided by different servers, theusers can configure different services to be run by different servers.

Example: a user can select Tomcat for JSP/Servlet, Borland® Enterprise Server for EJB, and some other serverfor connector.

For simplicity, select WebSphere Application Server Single Server 4.0 from the combo box and selectSingle server for all services in the project.

Page 7: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

7

Note: JBuilder is intuitive to automatically discover the services provided by a selected server. In our case, allservices other than Deployment, EJB, and JSP/Servlet are grayed out because those services can’t be providedby WebSphere Single Server AES 4.0.

WebSphere uses the IBM JDK and not the Sun JDK. Once you select WebSphere as the target server, JBuilderautomatically assigns the JDK java J2RE 1.3.0 IBM build cn130-20010609 to the project. Tosee which JDK is used, from the JBuilder menu bar, click Project -> Project Properties -> Paths. The JDKmust be an IBM JDK.

Hit OK to choose WebSphere Single Server for the current project.

Attach the WebSphere® Server to all the projects

If you decide to use WebSphere Server for all of your projects, you can assign WebSphere to Default ProjectProperties. From the JBuilder menu bar, click Project -> Default Project Properties -> Click Server tab.Select WebSphere Application Server Single Server 4.0 from the combo box and choose Single server forall services in the project.

Create a Web application

JBuilder allows you to create a Web application which can host applets, Web Start launchers, JSPs and servlets.

From the JBuilder menu bar, click File -> New -> Web tab in Object Gallery -> Web Application. Clickthe check box saying Generate War.

Enter a name and directory for the web application. For this exercise, the Web application name isTestWebApp and directory is TestWebApp.

Note: JBuilder has recognized that the target server is WebSphere, so it automatically createdweb.xml,ibm-web-bnd.xmi and ibm-web-ext.xmi as the deployment descriptors specific toWebSphere for this Web application.

Create a JSP™

From the JBuilder menu bar, click File -> New -> Web tab in Object Gallery -> Java Server Page. Enter aJSP name. Click the checkbox generate error page. For this exercise, the JSP name is TestJSP. Click Nextand enter a package name in JSP Wizard—Step 2 of 4. For this exercise, the package name is testweb.Click Next and then Finish.

This wizard creates a sample JSP, a sample JSP bean and an error page.

Note: The JSP wizard provides many options to the users like creation of a Sample Bean, Creation of an ErrorPage, entering the package name, creation of a runtime configuration etc.

Make the project

To make the project press Cntl+Shift+F9 or click the Make icon from the JBuilder toolbar. JBuilder mayshow some warnings because of the use of deprecated methods. To hide the deprecation click Project ->Project Properties -> Build -> uncheck Show warnings and Show deprecation.

As a result of make, JBuilder automatically creates the WAR file for the Web archive. The WAR file for thisexercise is TestWebApp.war.

See Figure 5 for details.

Page 8: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

8

Figure 5: The JSP Wizard created the JSPs and bean; the view of the source code of TestJSP.jsp

Create an EAR file

WebSphere AES 4.0 allows only EAR files as deployable files.

To create an EAR file, from the JBuilder menu bar, click File -> New -> Enterprise tab from ObjectGallery, click EAR icon and hot OK.

In the EAR Wizard—Step 1 of 6, leave the defaults. The EAR file name is TestWeb. Hit Next until youget to EAR Wizard—Step 5 of 6. Click the check box under the column Include of WebApp Nodes tab.The Context Name TestWebApp is populated automatically. You can always change the context name. HitFinish.

Now you should be able to see an entry in the project tree named TestWeb.eargrp. Right click onTestWeb.eargrp and click Make to generate the EAR file TestWeb.ear.

Deploy and run the JSP™ in WebSphere® Single Server

To deploy and run the JSP, WebSphere server needs to be started in JBuilder, then the EAR file needs to bedeployed, and finally WebSphere Server has to be restarted to run the deployed EAR file(s).

WebSphere Single Server AES 4.0 has to be restarted after each deployment, because it does not support hotdeployment. Other advanced versions of WebSphere Server support hot deployment.

To start WebSphere with JBuilder, click the Run icon from JBuilder toolbar, and click TestJSP. Note that thisis a runtime configuration automatically created by JBuilder. To check the information about this runtimeconfiguration, from the JBuilder menu bar, click Run -> Configurations -> click Edit.

Page 9: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

9

Note: JBuilder adds a tab WebSphere AES 4.0 http:9080 in message pane for WebSphere. Here9080 is the port number on which WebSphere is started.

Figure 6 shows WebSphere running within JBuilder .

Figure 6: JBuilder has opened a tab in message pane and WebSphere is running inside JBuilder

To deploy the EAR file TestWeb.ear to WebSphere, right-click on the EAR file -> click DeployOptions for TestWeb.ear -> click Deploy.

Page 10: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

10

Figure 7 shows the deployment step.

Figure 7: Showing deployment Options—Deploy, Redeploy, Undeploy, List Deployments

JBuilder creates another tab in the message window named WebSphere Application ServerSingle Server 4.0 Enterprise Deployer. A message Installation CompletedSuccessfully confirms the successful deployment of the EAR file to WebSphere.

Page 11: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

11

Figure 8 shows deployment of EAR file TestWeb.ear to WebSphere.

Figure 8: JBuilder has opened a tab to show the deployment status WebSphere

Now close the Enterprise Deployer tab, stop the WebSphere Server by clicking the red icon (reset button)from WebSphere AES 4.0 http:9080 tab of JBuilder message pane and start it back by clicking thegreen icon (Run button). The WebSphere server starts again in JBuilder.

You may get some warnings from WebSphere server tab. Some of the warnings are mentioned below. Ignorethose warnings.

• Servlet Error: ERROR: Cannot set header. Response already committed.:java.lang.IllegalStateException: ERROR: Cannot set header. Responsealready committed.

• SRVE0115E: Error occurred while invoking error reportercom.ibm.servlet.engine.webapp.WebAppErrorReport: ERROR: Cannot setheader. Response already committed.

• SRVE0091I: [Servlet LOG]: Error page exception The server cannot usethe error page specified for your application because of theexception printed below.

• SRVE0092I: [Servlet LOG]: Error Page Exception: :com.ibm.servlet.engine.webapp.WebAppErrorReport:

• SRVE0092I: [Servlet LOG]: Unable to report exception to client:java.lang.ArrayIndexOutOfBoundsException

If you don’t want to receive those error messages, please follow the instructions below.

Page 12: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

12

Stop WebSphere Server. From the JBuilder main menu bar, click Run-> Configurations -> Select theruntime configuration TestJSP -> click EDIT -> click JSP/Servlet from the Category menu -> Replace thecontents of Launch URI by a slash (/). Click OK to close the Runtime Properties window and OK again toclose the Project Properties window.

Refer to Figure 9 for details.

Figure 9: Remove the contents of Launch URI and just replace by a slash (/)

To test the JSP, open your favorite browser and typehttp://localhost:9080/TestWebApp/TestJSP.jsp. A successful execution of JSP should askyou to Enter new value and after you enter a new value and hit Submit, the value should be printed againstValue of Bean property is :

Note: This JSP is a simple JSP created with JBuilder JSP wizard which accepts a string in the Text box anddisplays it. Check the source code TestJSP.jsp and TestJSpBean.java for details of the source code.

Debug the JSP™

To debug the JSP, assign breakpoints in the source code wherever necessary. To assign a breakpoint, simplyopen the source file and click the mouse on that line.

Note: For this exercise, the breakpoints are assigned at 8th and 20th line of the TestJSP.jsp and 16th and21st lines of TestJSPBean.java.

Page 13: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

13

Stop the WebSphere server. Press Shift+F9 or just click on the Debug Project icon -> Click TestJSP to startWebSphere in debug mode within JBuilder.

Then start your favorite browser and type http://localhost:9080/TestWebApp/TestJSP.jspNow JBuilder window automatically gets highlighted with the debugger pointing to the 8th line ofTestJSP.jsp.

See Figure 10 for details.

Figure 10: Debugger stopped at the breakpoint. This is recognized by a green arrow on the top of the breakpoint

Note: When you click Debug Project, JBuilder starts WebSphere Server in debug mode. You can now click thedebug icons to see the thread information, breakpoint information, console output etc.

Also you can click step over, step into, step out, and other icons at the bottom to perform your debugoperations.

Working with servlets

Create a servlet in the previous project TestWeb and in the same Web application TestWebApp.

To create a servlet, from the JBuilder menu bar, click File -> New -> Web tab of Object Gallery -> Servlet.Enter a package name and servlet name in Servlet Wizard—Step 1 of 5. Click Next.

Note: For this exercise the package name is testweb and the servlet name is TestServlet.

In Servlet Wizard—Step 2 of 5, enter the methods that you want to use in the servlet. You can also generatean SHTML file with the servlet. Click Next.

Page 14: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

14

Note: For this exercise the method, doget() and doPost() are checked, and also Generate SHTMLfile checkbox is checked.

In Servlet Wizard—Step 3 of 5, you can enter the servlet name and URL pattern. Leave the defaults and clickNext.

In Servlet Wizard—Step 4 of 5, you can enter the Servlet Request Parameters. Click Next.

Servlet Wizard—Step 5 of 5 allows you to create a runtime configuration for the servlet. Click the check boxCreate a Runtime Configuration and leave the default configuration name as TestServlet. Hit Finish.

Make the project. To get help on how to make a project, refer to the section “Make the project” of thischapter.

To run the servlet, stop the WebSphere Server, redeploy the EAR file TestWeb.ear, start WebSphere, andrun the servlet from an external browser.

Refer to the previous section “Working with JSPs” to get help on how to start and stop WebSphere fromJBuilder. To redeploy the EAR file, right-click on the EAR file from JBuilder project tree, click Deployoptions for TestWeb.ear and click redeploy.

To run the servlet, open your favorite browser and typehttp://localhost:9080/TestWebApp/testservlet. A successful execution of the servletshould show the following line.

The servlet has received a GET. This is the reply.

See figure 11 for details.

Note: The link http://localhost:9080/TestWebApp/testservlet is used to run the servletbecause testservlet is the name of the servlet. Double-click web.xml from project tree of JBuilder andclick source from the editor pane. Refer to the following lines

<servlet-mapping id="ServletMapping_2"> <servlet-name>testservlet</servlet-name> <url-pattern>/testservlet</url-pattern> </servlet-mapping>

you can always change the <url-pattern> to something else and use that in your link to run the above servlet.

Page 15: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

15

Figure 11: Servlet is running in Internet Explorer successfully

TroubleshootingNote: The Troubleshooting tips provided here are simple workarounds to understand and fix theJBuilder/WebSphere integration problems. Borland is not responsible for supporting WebSphere relatedissues/fixes. Please contact WebSphere support team for other support related questions/issues aboutWebSphere.

Useful links

Refer to the following link for IBM WebSphere related issues:http://www-3.ibm.com/software/webservers/hostpublisher/library/publications/admin/guide12.htm

Refer to the following link for list of bugs that are fixed in 4.0.3:http://www-1.ibm.com/support/manager.wss?rs=180&rt=0&org=SW&doc=1052938

Refer to the following link for the release notes of WebSphere 4.0 AES: http://www-3.ibm.com/software/webservers/appserv/doc/v40/aes/infocenter/was/relnotes.html

Refer to the following link for the release notes of all versions of WebSphere 4.0 AES:http://www-3.ibm.com/software/webservers/appserv/doc/v40/aes/infocenter/was/relnotesindx.html

Refer to the following link for PDF files helping identification of problems and providing solutions:http://www-3.ibm.com/software/webservers/appserv/doc/v40/ae/infocenter/was/pdf/nav_PDguide.pdf

Page 16: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

16

Error 1: Server startup failed in JBuilder. Node not foundError description

d2f5ef7 StandardServe F WSVR0002E: Node Node_1 not found in/WebSphere/AppServer/config/server-cfg.xml.

java.lang.Throwable

When did this happen?

I am trying to run WebSphere within JBuilder.

Cause

This is because the node name you have specified in server-cfg.xml and in JBuilder does not match.

Solution

Check the node name in server-cfg.xml from C:\WebSphere\AppServer\config and makesure that the same node name is provided in the VM parameters of Server Configuration window. Check the“Configure JBuilder 7 with WebSphere” section for details.

Error 2: Cannot set header; but my servers starts fine

Error description

6bb228c WebGroup X Servlet Error: ERROR: Cannot set header.Response already committed.: java.lang.IllegalStateException: ERROR:Cannot set header. Response already committed.

When did this happen?

I have created the EAR file containing a Web application (WAR file) and then started WebSphere withinJBuilder. My servers starts fine, even with this error, and this does not appear in red.

Cause

IBM WebSphere has had this issue for a long time. This happens when setHeader() is called after theresponse is committed. Please refer to the following link for more information about this issue in the previousrelease of WebSphere (version 3.5.5).

http://www14.software.ibm.com/webapp/download/postconfig.jsp?id=4001070&pf=Multi-Platform&v=3.5.5&e=All+Editions&cat=&fam=&s=p&S_TACT=&S_CMP=&p=TDUN-49EVRT

IBM has created a patch for this issue “PQ54405” and the patch works only with version 3.5.5. It does notwork with version 4.0. Please refer to the following link for the issue in WebSphere version 4.0.

http://www-1.ibm.com/support/manager.wss?rs=180&rt=0&org=SW&doc=85256B4F006CCA2486256BEF0081B37D

Solution

The workaround is explained in the section “Deploy and run the JSP in WebSphere."

Page 17: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

17

Error 3: Error Page Exception, but my server starts fine

Error description

6bb228c WebGroup I SRVE0091I: [Servlet LOG]: Error page exception Theserver cannot use the error page specified for your application becauseof the exception printed below.

6bb228c WebGroup I SRVE0092I: [Servlet LOG]: Error Page Exception: :com.ibm.servlet.engine.webapp.WebAppErrorReport:

When did this happen?

I have created the EAR file containing a Web application (WAR file) and then started WebSphere withinJBuilder. My servers starts fine even with this error, and this does not appear in red.

Cause

We are not sure what is the cause of this error. This may be the effect of other errors. Since the server startsfine and everything works OK even with this message, we would like users to ignore this message.

The workaround is explained in the section “Deploy and Run the JSP in WebSphere.”

Working with session beansCreate a project and assign WebSphere Server as the target server for the project. If you need help on this, referto the sections “Create a project” and “Attach WebSphere Server to current project” from the previoussection.

Note: For this exercise, the name of the project is TestSes.

Create an EJB™ module

From the JBuilder menu bar, click File -> New -> Enterprise tab of Object Gallery -> EJB Module. Hit OK.

In the EJB Module Wizard, enter the module name and select the EJB version.

Note: For this exercise, the module name is TestSesMod. Websphere Server 4.0 AES does not support EJB2.0. So JBuilder doesn’t even provide the EJB 2.0 compliant option.

Create a session bean

JBuilder has a visual EJB designer which helps creating and working with EJB 2.0. Since WebSphere Server 4.0AES does not support EJB 2.0, we can’t take advantage of the visual EJB designer here.

To create a session bean, from the JBuilder menu bar, click File -> New -> Click Enterprise tab of ObjectGallery -> Click Enterprise Java Bean 1.x -> Click OK.

The Enterprise Java Bean Wizard—Step 1 of 3 pops up, and JBuilder has automatically selected TestSesMod asthe EJB module.

Note: You can create a new EJB module in this step, if it is not created already, by clicking New.

Hit Next, which brings up Enterprise Java Bean Wizard–Step 2 of 3. You can enter the package name, Beanname, Bean Type, and other parameters. Note: For this exercise, the package name is com.borland.demo.ejb, Class Name is TestSes, BeanType is Stateless session bean and Base Class is java.lang.object.

Page 18: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

18

Hit Next, which brings up Enterprise Java Bean Wizard—Step 3 of 3. Leave the defaults and hit Finish.

The above wizard just created a session bean with the specifications provided.

Check the project tree in Figure 12 for the created session bean classes.

Figure 12: The session bean TestSes is created visually and the contents of TestSes.java displayed

For this exercise, we will add a business method in the session bean and call that method from a test client.

To add a method in the session bean, double-click on TestSes.java, add the following method to TestSes.javausing the editor pane.

public String getName(){ return "Session Bean Call Successful"; }

Now to expose the method to the remote interface, double-click TestSesRemote.java from JBuilder projecttree, click Bean tab from editor pane, click Methods tab, and click on the checkbox against getName().

See Figure 13 for details.

Page 19: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

19

Figure 13: Exposing business method to the remote interface, in this case getName()

Note: The above operation exposes the bean method getName() as a remote method. It means the remotemethod definition is added to TestSesRemote.java.

Double-click on TestSesRemote.java from JBuilder project tree to see the changes to the file. The followingcode snippet is from TestSesRemote.java.

public interface TestSesRemote extends EJBObject { public java.lang.String getName() throws RemoteException;}

Create deployable JAR file

To run the session bean, first make the project, then create an EAR file, deploy the EAR file, restartWebSphere. To get help on how to make the project, create EAR file, start and stop WebSphere, refer toprevious sections.

At the time of make, JBuilder runs the WebSphere compiler to generate the deployment descriptors andcontainer-generated files.

Figure 14 shows the running of EjbDeploy (of WebSphere) from JBuilder.

Page 20: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

20

Figure 14: JBuilder is running WebSphere utilities to create the deployment descriptors and container-generated classes

Note: After the make, the WebSphere specific container-generated files and deployment descriptors are createdin JBuilder. Expand TestSesBean.java to view the container-generated files and double-click TestSesMod.jarto view the deployment descriptors in the structure pane.

See Figure 15 for details.

Page 21: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

21

Figure 15: The container-generated files and deployment descriptors created specific to WebSphere

Now create an EAR file. To create an EAR file, from the JBuilder menu bar, click File -> New -> clickEnterprise from Object Gallery -> click EAR -> hit OK. Leave the defaults in EAR Wizard—Step 1 of 5 andclick Next . Check the TestSesMod checkbox in EAR Wizard–Step 2 of 5. Click Finish.

Right-click on the eargroup TestSes.eargrp from JBuilder project tree and click make. The make processcreates an EAR file TestSes.ear.

Create a runtime configuration

JBuilder allows users to create runtime configurations for running different applications.

From the JBuilder menu bar, click Run -> Configurations. The Project Properties window shows up with theRun tab selected. Hit New to create a new runtime configuration. In the Runtime Properties window, click the Server tab and enter a Configuration Name.

You can change the Build Target as <None>, otherwise JBuilder will make the project each time you run it.

Note: For this exercise, the Configuration Name is Server. Hit OK, then OK.

Page 22: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

22

See Figure 16 for details.

Figure 16: Creating a runtime configuration to run WebSphere within JBuilder

Run WebSphere® Server within JBuilder™

Click on the Run icon from the JBuilder menu bar and click Server. Now WebSphere Server will run withinJBuilder. It opens a tab WebSphere AES 4.0 http:9080 in JBuilder message pane.

Deploy EAR file to WebSphere®

Right-click on TestSes.ear -> Click Deploy options of TestSes.ear -> click Deploy.

JBuilder starts another tab WebSphere Application Server Single Server 4.0 Enterprise Deployer in JBuildermessage pane to show the deployment status.

A successful deployment will show a message “Installation Completed Successfully in the Enterprise Deployer”tab.

After the deployment, restart the WebSphere Application Server.

Create a test client to test the session bean

To test the session bean, you can create a test client using JBuilder.

From the JBuilder menu bar, click File -> New -> Enterprise tab of Object Gallery -> EJB Test Client. HitOK.

Note: For this exercise, enter the class name as TestSesTestClient and package name ascom.borland.demo.ejb.

Page 23: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

23

Change the main method of the TestSesTestClient.java as follows.

public static void main(String[] args) { TestSesTestClient client = new TestSesTestClient(); try { client.create(); String name = client.getName(); System.out.println("Name from the Test Client = " + name); } catch (Exception ex) { }}Make the TestSesTestClient.java ( Richt-click on TestSesTestClient.java and hit Make ).

Run the test client

To run the test client, create a runtime configuration for the client.

To create a runtime configuration for the client, from the JBuilder menu bar, click Run -> Configuration ->Click New. In the Runtime Properties window, click Run tab -> Application tab, then select Main class asthe TestSesTestClient by clicking the ellipses and enter a name under the configuration name.

You can change the Build Target as <None>, otherwise JBuilder will make the client each time you run it.

Note: For this exercise, the configuration name is Client. Now right-click on the test client TestSesTestClient.java, click Run using Client.

See Figure 17 for details.

Figure 17: Running test client to test the EJB deployed in WebSphere

Page 24: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

24

Note: The test client runs within JBuilder by creating another tab in the message pane. You can see thesuccessful execution of the test client from the last line Name From the Test Client = SessionBean Call Successful.

TroubleshootingNote: If you are not finding the troubleshooting tips from here, please refer to the tips from the previouschapters.

Error 4: Build Failed: TestClient is showing error

Error description

"TestSesTestClient.java": Error #: 300 : method getName() not found ininterface com.borland.demo.ejb.TestSesRemote at line 101, column 35

When did this happen?

I have created my session bean successfully, I have created my test client. I right-click on test client and clickMake and got the above error.

Cause

Seems like the getName() method is not exposed to the remote interface.

Solution

Double-click on TestSesRemote.java (the remote interface) from the project tree of JBuilder and check thesource code in the editor pane. Do you find the getName() method signature? If not, double-click onTestSes.java from JBuilder project tree, click Bean from the editor pane, click Methods and check thecheckbox against the method getName() (refer to Figure 12).

Now delete the test client by right-clicking on the TestSesTestClient.java and clicking DeleteTestSesTestClient.java. Then create the test client again by selecting File | New | Enterprise Tab | EJBTestClient. Replace the main() method with the following code .

public static void main(String[] args) { TestSesTestClient client = new TestSesTestClient(); try { client.create(); String name = client.getName(); System.out.println("Name from the Test Client = " + name); } catch (Exception ex) { }}

Rebuild the whole project, and run the test client again.

Error 5: TestClient Failed: NameNotFoundException:TestSes

Error description

javax.naming.NameNotFoundException: TestSes

Page 25: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

25

When did this happen?

I have deployed my EAR file successfully and restarted my server. Then when trying to run the test client, I gotthe above error from the TestSesTestClient tab of the JBuilder message window.

Cause

The cause of this error may be either because the client is unable to reach the session bean or the session beanTestSes is not deployed properly. If TestSes is not deployed properly, then it may not be running inWebSphere.

Solution

Click on the WebSphere AES 4.0 http:9080 tab from the JBuilder message window. Look closely at themessages displayed. If you find the following message, then it is for sure that the deployment is unsuccessful ora corrupted EAR file got deployed.

d2108d8 EJBEngine X WSVR0062E: Failed to start EJB,TestSes#TestSesMod.jar#TestSes:com.borland.demo.ejb.EJSStatelessTestSesHomeBean

JBuilder follows certain steps while creating the EAR file. Sometimes the users need to do a make again againstthe EAR group to regenerate the EAR file.

To check the contents of the EAR file, open Windows Explorer, navigate toC:\JBWebSphere\TestSes and open the TestSes.ear with WinZip.® Extract the JAR fileTestSesMod.jar from the archive and then Open TestSesMod.jar with WinZip.

Do you see just three class files (TestSes.jar, TestSesHome.jar, TestSesRemote.jar) in the contents? If that is thecase, the EAR file is not correct. Go to JBuilder project tree -> Make the eargroup to regenerate the EAR fileTestSes.ear, and then redeploy the EAR file.

Refer to Figure 18 and Figure 19. Figure 18 shows the wrong JAR file TestSesMod.jar, which does not includethe container-generated files of WebSphere. Figure 19, in fact, is the correct JAR file, which includes all therequired class files for deployment.

Figure 18: Wrong JAR file, TestSesMod.jar, doesn’t include the container-generated files from WebSphere

Page 26: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

26

Figure 19: Correct JAR file, TestSesMod.jar, which includes the container-generated files

Working with entity beanThis exercise assumes that Oracle is up and running, and the default Oracle database ORCL is up and running.To make sure if the database ORCL is running, check the connectivity from JBuilder Database Pilot. Refer tothe section “Test the Oracle connection” to learn on how to connect to Oracle from JBuilder. If you are usinga database other than ORCL, you can still follow this section to create entity beans.

Create a project, assign WebSphere Server as the target application server for the project and create an EJBmodule. To get help on how to create a project, how to assign WebSphere Server to current project, refer toprevious sections. To get help on how to create an EJB module, refer to the section “Create an EJB module.”

Note: For this exercise, the name of the project is TestEnt and name of the EJB module is TestEntMod.

Create an entity bean using Entity Bean Modeler

With EJB 2.0, JBuilder 7 can import the whole database schema and entity beans can be created visually rightfrom the schema. Since WebSphere 4.0 AES does not support EJB 2.0, the EJB 1.x Entity Bean Modeler willbe used to create entity beans.

From the JBuilder menu bar, click File -> New -> click Enterprise tab from Object Gallery -> click EJB 1.xEntity Bean Modeler -> click OK.

The EJB Entity Bean Modeler Wizard–Step 1 of 7 should pop up. Leave the default EJB module TestEntModand hit Next.

In EJB Entity Bean Mode Modeler Wizard—Step 2 of 7, provide the database information. Enter the DatabaseDriver, URL, Username, Password, and JNDI name.

Note: for this exercise, Oracle will be used as database. Enter the following values in the Database SchemaProvider window.

Driver : oracle.jdbc.driver.OracleDriverURL : jdbc:oracle:thin:@localhost:1521:ORCLJNDI name : DemoDataSource.

See Figure 20 for details.

Page 27: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

27

Figure 20: EJB Entity Bean Modeler Wizard–Step 2 of 7

Click Next, which should bring EJB Entity Bean Mode Modeler Wizard–Step 3 of 7. This step allows you toselect the tables from the database. The left panel shows the list of available tables for the database you haveselected in the previous window; the right panel shows the selected tables.

Move the EMP table from the Available list to the Selected list.

See Figure 21 for details.

Page 28: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

28

Figure 21: SCOTT.EMP Table was selected from left panel and moved to the right panel

Click Next -> which should take you to EJB Entity Bean Modeler Wizard—Step 4 of 7. This screen shows thecolumns that are used in the entity bean. By default, all the columns are selected.

Note: For this exercise, the selected fields are EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM,DEPTNO.

Click Next -> which brings up EJB Entity Bean Modeler Wizard—Step 5 of 7. This screen shows the columnmappings with the column types. This also shows the primary key of the table.

If you want to change the Field Type for any field, click on that row and click Update Field Type.

See Figure 22 for details.

Page 29: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

29

Figure 22: EJB Entity Bean Modeler Wizard–Step 5 of 7 showing the columns of Table EMP and the field mapping of eachcolumn

Click Next. This screen EJB Entity Bean Modeler Wizard–Step 6 of 7 allows you to change the defaultpackage name and default bean class names.

Note: For this exercise, change the package name to com.borland.demo.ejb.

Click Next. This is the final step of EJB 1.x Entity Bean Modeler Wizard. Leave the defaults and hit Finish.

Now the entity bean Emp is created. The bean files Emp.java, EmpBean.java, and EmpHome.java are createdunder the package com.borland.demo.ejb in JBuilder project tree. Also DemoDataSorce is created under JDBC1 Datasources in JBuilder project tree. An entry CMP 1.1 is created under the EJB module TestEntMod of JBuilder project tree. Double-click onCMP 1.1 to see the CMP fields in the editor pane.

Create a session bean

Please refer to the section “Create a session bean” for details on how to create a session bean.

Note: For this exercise, the name of the stateless session bean is EmpSes which is created under the samepackage name com.borland.demo.ejb.

Double-click EmpSes.java from JBuilder project tree and add thegetEmpName(java.math.BigDecimal empNo) method as follows.

public String getEmpName(java.math.BigDecimal empNo) { String empName = "name not found"; try {

Page 30: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

30

javax.naming.Context context = new javax.naming.InitialContext(); Object object = context.lookup("java:comp/env/Emp"); EmpHome empHome = (EmpHome)javax.rmi.PortableRemoteObject.narrow(object, EmpHome.class); Emp emp = empHome.findByPrimaryKey(empNo); empName = emp.getEname();

}catch (Exception ex){ ex.printStackTrace(); } return empName; }

See Figure 23 for details.

Figure 23: Source code of EmpSes.java displayed in the editor pane. getEmpName() is our business method

Expose the bean method to remote interface

To expose the bean method getEmpName() to remote interface, go to the JBuilder project tree and double-click on EmpSesRemote.java, click Bean tab from editor pane, click Method tab and click the checkboxagainst getEmpName(java.math.BigDecimal)

As a result of this operation, the getEmpName() method signature is added to EmpSesRemote.java.

Page 31: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

31

Here is how EmpSesRemote.java looks:

public interface EmpSesRemote extends EJBObject { public java.lang.String getEmpName(java.math.BigDecimal empNo) throwsRemoteException;}

See Figure 24 for details on how to expose a bean method to remote interface.

Figure 24: A check mark in the box against getEmpName(java.math.BigDecimal) adds the method to the remote interface(EmpSesRemote.java)

Assign entity bean reference to session bean

Since the session bean EmpSes is calling the entity bean Emp, the entity bean reference has to be stored in thedeployment descriptor of the session bean EmpSes. The JBuilder deployment descriptor tool can be used tocreate a reference visually.

Double-click EmpSes under TestEntMod from the JBuilder project pane and click EJB references tab at thebottom of the editor pane.

Click Add and enter the name as Emp in EJB Reference window. Hit OK.Enter the following values for the entries.

Name : EmpType : EntityHome : com.borland.demo.ejb.EmpHomeRemote : com.borland.demo.ejb.EmpJNDI Name : EmpRefer to Figure 25 for details.

Page 32: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

32

Figure 25: Session bean EmpSes reference to entity bean Emp. The reference is done visually

Create a test client

Create a test client to call the session bean EmpSes which in turn calls the entity bean Emp. The entity beanEmp gets the data from the EMP table of database ORCL, sends to the session bean, and the session beansends the data to the test client. Please refer to the section “Create a test client to test the session bean” to gethelp on how to create a test client.

Note: For this exercise the name of the test client is EmpSesTestClient. Modify the main() method of the TestClient EmpSesTestClient.java as follows.

public static void main(String[] args) { EmpSesTestClient client = new EmpSesTestClient(); try { client.create(); String empName = client.getEmpName(new java.math.BigDecimal("7369")); System.out.println("Employee Name from the Test Client is = " +empName); } catch (Exception ex) { ex.printStackTrace();} }

Page 33: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

33

Save all and make the project

To save all the files (including deployment descriptors), click the Save All icon from the JBuilder Toolbar.Then make the project. To get help on how to make a project, refer to the section “Make the project.”

Create an EAR file

To get help on how to create an EAR file, refer to the section “Create an EAR file.” For this exercise, whilecreating EAR file, leave all the defaults, and click the checkbox against TestEntMod of EJB modules tab toinclude the JAR file in the EAR. The name of the EAR group is Testent.eargrp. Right-click the EAR group,and click Make to create the EAR file TestEnt.ear.

Create runtime configurations

For this exercise, create two runtime configurations.

Server type to run WebSphere server within JBuilder. Application type to run the test client.

To create the server type runtime configuration, from the JBuilder menu bar, click Run -> Configurations ->click New -> click Server tab -> enter a Configuration Name. Hit OK.

Note: For this exercise, enter the Configuration Name as Server. Also, you can change Build Target to<NONE> in the Runtime Properties window.

To create an application type runtime configuration, from the JBuilder menu bar, click Run ->Configurations -> click New -> click Application tab -> find the Main Class -> enter a ConfigurationName. Hit OK

Note: For this exercise, enter the Configuration Name as Client. Click the ellipses and find the test clientcom.borland.demo.ejb.EmpSesTestClient. Also, you can change Build Target to <NONE> inthe Runtime Properties window.

Start WebSphere® Server and administration console

To start WebSphere server, from command prompt run startServer. startServer.bat is available inC:\WebSphere\AppServer\bin. A successful WebSphere server launch will display the followingmessage in the command window.

WSPL0057I: The server Default Server is open for e-business.

Start WebSphere Console. To start the console, open your favorite browser and typehttp://localhost:9090/admin. The assumption here is that WebSphere Admin is running locally onport 9090.

You can also start Websphere Console from JBuilder. From the JBuilder menu bar, click Tools -> ConfigureTools -> Click Add in the Configure Tools window. The Add Tool window pops up. Enter the followingparameters in the Add Tools window.

Title: WebSphere ConsoleProgram : C:\Program Files\Internet Explorer\IEXPLORE.EXEParameters: http://localhost:9090/admin

Note: For this exercise, Internet Explorer is used. But you can select any browser application and specify itunder Program.

Now an entry called WebSphere Console is added in JBuilder Tools menu. Click Tools -> WebSphereConsole to start the WebSphere Console.

Page 34: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

34

Create a DataSource and DataSource driver in WebSphere®

You will be asked to enter an User ID when the WebSphere console starts. Enter any ID and that should takeyou to the IBM WebSphere Application Server Administrative Console window.

From WebSphere Console, expand Resources -> expand JDBC Drivers->Click New from the right-handwindow.

It should take you to the next screen where you will be asked to select the Resource Provider Type from acombo box. Select Oracle JDBC Driver from the combo box, and click Next.

In the next screen, provide the following values.

Server Class Path: C:\oracle\ora81\jdbc\lib\classes12.zipName: Oracle JDBC DriverDescription: Oracle JDBC DriverImplementation Classname: oracle.jdbc.pool.OracleConnectionPoolDataSource

See Figure 26 for details.

Figure 26: Creating a JDBC driver called Oracle JDBC Driver using WebSphere Console

Note: Some of the values specified above may already have been defaulted. The Implementation Classnamehas to be com.jdbc.pool.OracleConnectionPoolDataSource.

Click OK and the driver called Oracle JDBC Driver will be created.

Page 35: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

35

Note: Each time you make any changes to the console, the console doesn’t save the changes automatically. Ifyou see a link saying configuration needs to be saved in the right-hand window, click the linkand that should take you to Save Configuration window. Make sure to check the radio button SaveConfiguration File: C:\WebSphere\AppServer\config\server-cfg.xml and clickOK.

See Figure 27 for details.

Figure 27: Saving the changes made to the configuration file server-cfg.xml

Create a DataSource

From WebSphere Administrative Console, expand Resources -> expand JDBC Drivers -> expand OracleJDBC Driver. You should find the DataSources folder. Click on the DataSources folder, then click Newfrom the right-hand window.

Now the Properties screen should be displayed at the right-hand window. Enter the following values asproperties for the DataSource.

Name: DemoDataSourceJNDI Name: DemoDataSourceDescription: JBuilder Demo DataSourceCategory :Database Name: ORCLDefault User ID: scottDefault password: tigerMinimum Pool Size: 1Maximum Pool Size: 10Connection Timeout: 50Idle Timeout: 50Orphan Timeout: 50

Page 36: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

36

Statement Cache Size: 100Note: The JNDI Name has to match with the DataSource name provided in the entity bean. A mismatch inthe DataSource name will cause the entity bean Emp to fail while starting.

See Figure 28 for details.

Figure 28: Creating a Data Source DemoDataSource using WebSphere Console

Click Properties, the Resource Properties screen should be displayed. Click New to create a property for theDemoDataSource.

Enter the following values in the Properties screen.

Name: URLType: java.lang.StringValue: jdbc:oracle:thin:@localhost:1521:ORCLDescription: Connection URL

See Figure 29 for details.

Page 37: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

37

Figure 29: Adding a property to the DataSource. Property name is URL, which is nothing but the connection URL to connect toOracle

Click OK. Click the link configuration needs to be saved to save the changes made to WebSphere..Test the DataSource

To make sure that you have created the Driver and DataSource successfully, stop the WebSphere Server. Tostop WebSphere, run stopServer from the Command window. stopServer is available inC:\WebSphere\AppServer\bin.

Now start WebSphere in JBuilder and watch the messages. Make sure that you don’t get any errors aboutDemoDataSource or Oracle Driver.

Deploy entity bean and session bean to WebSphere®

WebSphere allows only EAR files to be deployed.

Start WebSphere within JBuilder. To start WebSphere, click the Run icon from the JBuilder toolbar and clickServer. A tab named WebSphere AES 4.0 http:9080 should be opened in JBuilder message pane.

From JBuilder project pane, right-click on TestEnt.eargrp -> click Deploy Options for TestEnt.ear ->click Deploy.

Now WebSphere Application Server Single Server 4.0 Enterprise Deployer tab should open in JBuildermessage pane showing the deployment status. Close the Deployment window after you see a success message.

Page 38: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

38

Run the test client

From the JBuilder toolbar, click on the Run icon -> Click Client.

Now the EmpSesTestClient will start in the JBuilder message pane. Check the messages from theEmpSesTestClient tab. A successful execution will return the name SMITH from the Emp entity bean.

See Figure 30 for details.

Figure 30: JBuilder message pane showing the execution status of test client EmpTestClient.java

TroubleshootingNote: If you are not finding the troubleshooting tips you need from here, please refer to the tips from previoussections.

Error 6: Test Client is not returning the employee name

Error description

27fe5031 UrlContextHel W NMSV0605E: A Reference object looked up from thecontext "java:" with the name "comp/env/Emp" was sent to the JNDI NamingManager and an exception resulted.Reference data follows:Reference Factory Class Name:com.ibm.ws.naming.util.IndirectJndiLookupObjectFactoryReference Factory Class Location URLs: <null>Reference Class Name: java.lang.ObjectType: JndiLookupInfoContent: com.ibm.ws.naming.util.JndiLookupInfo@45af9031

Page 39: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

39

When did this happen?

I have created my EAR file successfully, deployed the EAR file to WebSphere successfully, then restartedWebSphere within JBuilder and tried to run the test client. The test client runs successfully, except it doesn’treturn the employee name from the database. Then, I checked my server tab and discovered the above error.

Cause

Seems like the property URL has wrong entries.

Solution

Open WebSphere console and check the entries for the URL property of the DataSourceDemoDataSource.

To check the entries of the property URL, go to the WebSphere console. Expand Resources -> expandJDBC Drivers -> expand Oracle JDBC Driver -> click DataSources -> click DemoDataSource from righthand panel -> click Properties from the Driver Specific Settings -> click URL and make sure that you havethe following entries.

Name: URLType: java.lang.StringValue: jdbc:oracle:thin:@localhost:1521:ORCL

Error 7 : Deployment unsuccessful

Error description

CHKW4515W: No JNDI name has been specified for the EJB ref for homecom.borland.demo.ejb.EmpSesHome under EJB ?. JNDI names must bespecified for all EJB refs in the EJB jar before the module may bestarted in the application server.

When did this happen?

I have created my EAR file, started WebSphere in JBuilder, and deployed the EAR file in WebSphere. Themessage from the Enterprise Deployer tab says “Installation Completed Successfully.” But when I scrolled upand checked the messages in Enterprise Deployer tab, I found the above message.

Cause

This is because of unsuccessful deployment. The generated EAR file may be wrong. From the error message, itlooks like the EJB reference from the session bean to the entity bean is not correct.

Solution

Double-click on the EJB module TestMod, double-click on the session bean TestSes, click on EJBReferences. Make sure that the IsLink field is not checked, and you have entered the JNDI name correctly.Refer to the section “Assign entity bean reference to session bean” from this section for more information.

After you change the values, make the project, and make the EAR group, redeploy the EAR file using theJBuilder redeploy utility (right-click on the EAR file, click on Deploy Options for TestEnt.ear and then clickRedeploy). Restart WebSphere and run the test client.

Page 40: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

40

Error 8: Test client failed—NameNotFoundException

Error description

From Test Client tab:

javax.naming.NameNotFoundException: EmpSes

From Server tab

d2729b5 EJBEngine X WSVR0062E: Failed to start EJB,TestEnt#TestEntMod.jar#EmpSes:com.borland.demo.ejb.EJSStatelessEmpSesHomeBean

d2729b5 JDBCPersister W CNTR0031W: Error starting CMP bean:TestEnt#TestEntMod.jar#Emp

d2729b5 JDBCPersister W CNTR0032W: Error creating CMP persister usingdatasource: local:jdbc/DemoDataSource

d2729b5 EJBEngine X WSVR0062E: Failed to start EJB,TestEnt#TestEntMod.jar#Emp:com.borland.demo.ejb.EJSJDBCPersisterCMPEmpBean

When did this happen?

I have created an EAR file, deployed the EAR file to WebSphere, restarted WebSphere. When running the testclient, I got errors from the Test Client tab, then checked the server messages. I got the above error messagesfrom the Server tab, too.

Cause

This is because of an incorrect EAR file. From the error message it looks like the EJB reference from thesession bean to the entity bean is not correct.

Solution

Double-click on the EJB module TestMod, double-click on the session bean TestSes, click on EJBReferences. Make sure that the IsLink field is not checked, and you have entered the JNDI name correctly.Refer to the section “Assign entity bean reference to session bean” from this section for more information.

After you change the values, make the project and make the EAR group, redeploy the EAR file using theJBuilder redeploy utility (right-click on EAR file, click on Deploy Options for TestEnt.ear and then clickRedeploy). Restart WebSphere and run the test client.

Remote debugging JBuilder can remotely debug a process already running in Java, in this case, the WebSphere Server. To remotelydebug an application, the application server has to be started in Debug Mode.

Note: This exercise assumes that you have already worked on “Working with entity beans,” which means youhave created an entity bean called Emp, a session bean called EmpSes, a test client and have deployed toWebSphere. In this section, we will remotely debug the EJBs created previously.

Page 41: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

41

Run WebSphere® Server in Debug Mode outside of JBuilder™

WebLogic Server can be started remotely by providing the options–debugEnable–jdwpPort <Port#> to the startServer.

Start a MS-DOS window. In the command prompt, typeC:\WebSphere\AppServer\bin\startServer –debugEnable –jdwpPort 5555

See Figure 31 for details.

Figure 31: Starting WebSphere in remote mode by providing the–debugEnable and–jdwpPort <port#> option to startServer

Create runtime configuration for remote debugging

From the JBuilder menu bar, click Run -> Configurations. The Project Properties window with Run tabselected should pop up. Click New -> Click Debug tab from Runtime Properties window.

Enter Configuration Name as Remote Debug, Check the Enable Remote Debugging checkbox and clickAttach in the Remote Settings panel. Now the address textbox of transport panel should be active. Enter theAddress as 5555. You can also change the Build Target to <NONE>.

Note: The address specified here must be the same as the port number specified in the server as debugoptions. JBuilder will open a socket connection to the WebSphere server and attach using the port number5555.

Assign breakpoints

Assign breakpoints to the entity bean and session bean to test the remote debugging.

Note: For this exercise, breakpoints are assigned at the following places.

Page 42: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

42

Breakpoint 1

File name: EmpSes.java Line #: 32Line Desc: javax.naming.Context context = newjavax.naming.InitialContext();

Breakpoint 2

File name: Emp.javaLine #: 7Line Desc: public String getEname();

Attach JBuilder™ to WebSphere® remotely

To attach JBuilder to WebSphere server remotely, from the JBuilder toolbar, click Debug Project icon ->click Remote Debug.

Now a tab with the name localhost:5555 is opened in the JBuilder message pane.

Note: There is a green check mark at the first breakpoint (line 32 of EmpSes.java) which shows that thedebugger has detected the breakpoint, and it is valid.

If you check the break point status at line 7 of Emp.java, you will see a cross mark. That means the breakpointis not valid.

See Figure 32 for details.

Figure 32: Remote connection to WebSphere; breakpoint recognized by a green tick mark on the breakpoint

Page 43: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

43

Run the test client to debug the EJBs

From the JBuilder toolbar, click Run icon -> Client. Now you should see the debugger stopping at breakpoint1 which is at line 32 of EmpSesBean.java.

See Figure 33 for details.

Note: The test client is not deployed to the WebSphere Application Server. Only the session bean, entity bean,generated files, and deployment descriptors are deployed. So you have to run the test client to hit thebreakpoints. The test client can’t be debugged with this process.

Figure 33: Run the test Ccient EmpSesTestClient.java, and the debugger stops at the breakpoint. This is recognized by a greenarrow mark on the top of the breakpoint

Now you can follow your normal debugging process like step over, step into, step out etc.

Note: Remote debugging process is slower that the normal run process. This is because the JVM has tooperate in a Debug Mode which is slower than the normal run mode.

TroubleshootingNote: If you are not finding the troubleshooting tips you need from here, please refer to the tips from theprevious sections.

Page 44: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

44

Error 9: JBuilder™ attachment to WebSphere® failed

Error description -IOException attaching Remote Java debug Process –java.net.ConnectException : Conection refused: connect

java.net.ConnectException: Connection refused: connect

When did this happen?

The error occurred when I tried to attach JBuilder with a running WebSphere server.

Cause

The error occurred either because WebSphere is not running properly or the debug parameters provided tostart WebSphere are not correct.

Solution

Check if WebSphere is running. If it is running, then check the debug parameters.

If the debug parameters are also correct, then check JBuilder remote debug configuration. From the JBuildermenu bar, click Run -> Configuration -> Edit the Remote Debug entry. Click Debug tab and check theaddress. Make sure that the port number provided in this address is the same as the address provided inWebSphere debug options.

Page 45: Borland Introduction JBuilder 7 and WebSphere 4.0 Integration · ® WebSphere ® 4.0 Integration ... August 2002 Introduction ... access Oracle using the Oracle JDBC® driver classes12.zip

Borland® JBuilder™

45

Additional informationBorland® JBuilder™

http://www.borland.com/jbuilder/

Borland Optimizeit™ Suitehttp://www.borland.com/optimizeit/index.html

Borland JDataStore™

http://www.borland.com/jdatastore/index.html

Borland® Enterprise Studio for Java™ http://www.borland.com/estudiojava/index.html

Borland® Enterprise Server, AppServer™ Editionhttp://www.borland.com/besappserver/index.html

Sun Microsystems Java™ 2 Platform, Enterprise Editionhttp://java.sun.com/j2ee/

Sun Microsystems Enterprise JavaBeans™

http://java.sun.com/products/ejb/

IBM® WebSphere® Serverhttp://www-3.ibm.com/software/webservers/appserv

JBuilder™ OpenToolshttp://www.borland.com/jbuilder/resources/jbopentools.html

Feedback and suggestionsPlease send your feedback and suggestions to:

Sudhansu Pati, Systems [email protected]

100 Enterprise WayScotts Valley, CA 95066-3249www.borland.com | 831-431-1000 | Fax: 831-431-4142

Made in Borland® Copyright© 2002 Borland Software Corporation. All rights reserved. All Borland brand and product names are trademarks or registeredtrademarks of Borland Software Corporation in the United States and other countries. IBM and WebSphere are registered trademarks of IBM in the UnitedStates. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All other marks are theproperty of their respective owners. Corporate Headquarters: 100 Enterprise Way, Scotts Valley, CA 95066-3249 • 831-431-1000 • www.borland.com • Officesin: Australia, Brazil, Canada, China, Czech Republic, France, Germany, Hong Kong, Hungary, India, Ireland, Italy, Japan, Korea, the Netherlands, NewZealand, Russia, Singapore, Spain, Sweden, Taiwan, the United Kingdom, and the United States. • 13350