Borland JBuilder 7 and BEA WebLogic Server 7.0 Integration€¦ · Installing WebLogic Server™...

63
Borland ® JBuilder ® 7 and BEA WebLogic Server 7.0 Integration Jump start development, deployment, and debugging of EJBs and JSPs A Borland White Paper by Sudhansu Pati, Systems Engineer Borland Software Corporation November 2002

Transcript of Borland JBuilder 7 and BEA WebLogic Server 7.0 Integration€¦ · Installing WebLogic Server™...

Borland® JBuilder® 7 and BEAWebLogic Server™ 7.0 Integration

Jump start development, deployment,

and debugging of EJBs™ and JSPs™

A Borland White Paper

by Sudhansu Pati, Systems Engineer

Borland Software Corporation

November 2002

Borland® JBuilder® 7 and BEA WebLogic Server™ 7.0 Integration

2

Contents

Introduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Install ing JBuilder® 7 .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Platforms............................................................................................................................... 4System requirements ............................................................................................................. 4Installation ............................................................................................................................ 5Registration ........................................................................................................................... 5Tuning JBuilder® 7................................................................................................................ 5Installing WebLogic Server™ 7.0.......................................................................................... 6

Configuring JBuilder® 7 with WebLogic® 7.0 Single Server .. . . . . 7

Working with JSPs™ and servlets .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Create a project ..................................................................................................................... 9Attach the WebLogic Server™ to current project ................................................................ 10Attach the WebLogic Server™ to all the projects ................................................................ 11Create a Web application .................................................................................................... 11Create a JSP™...................................................................................................................... 12Make the project ................................................................................................................. 12Deploy and run the JSP™ in WebLogic® Single Server ...................................................... 13Debug the JSP™ .................................................................................................................. 15Working with servlets ......................................................................................................... 16Troubleshooting .................................................................................................................. 18

Working with session beans .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Create an EJB™ module ...................................................................................................... 22Create a session bean .......................................................................................................... 22Create deployable JAR file ................................................................................................. 25Create a runtime configuration............................................................................................ 26Run WebLogic Server™ within JBuilder®........................................................................... 27Deploy EJB™ JAR file to WebLogic® ................................................................................ 27Remote deployment ............................................................................................................ 28Create a test client to test the session bean.......................................................................... 29Run the test client................................................................................................................ 30Troubleshooting .................................................................................................................. 31

Working with entity beans .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Import a database schema ................................................................................................... 34Create an entity bean........................................................................................................... 35

Borland® JBuilder® 7 and BEA WebLogic Server™ 7.0 Integration

3

Create a session bean .......................................................................................................... 36Assign entity bean reference to session bean ...................................................................... 38Create a test client ............................................................................................................... 39Save all and make the project.............................................................................................. 40Create runtime configurations............................................................................................. 40Start WebLogic Server™ and JDataStore™ Server .............................................................. 41Create data source entries in WebLogic®............................................................................ 41Deploy entity bean and session bean to WebLogic®........................................................... 47Run the test client................................................................................................................ 47

Troubleshooting .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Error 8: Cannot create connection pool............................................................................... 48Error 9: Cannot create data source ...................................................................................... 51Error 10: Can’t start connection pool in WebLogic ............................................................ 52Error 11: Test client not returning employee name............................................................. 52Error 12: EJB™ JAR deployment failed .............................................................................. 53

Remote debugging .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

Create batch files................................................................................................................. 55Run WebLogic Server™ in debug mode outside of JBuilder® ........................................... 57Create runtime configuration for remote debugging........................................................... 57Assign breakpoints.............................................................................................................. 57Attach JBuilder® to WebLogic® remotely........................................................................... 58Run the test client to debug the EJBs™ ............................................................................... 60

Troubleshooting .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Error 13: WebLogic® remote server failed to start.............................................................. 61Error 14: JBuilder attachment to WebLogic failed ............................................................. 62

Feedback and suggestions .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4

Introduction

Borland® JBuilder® Enterprise is a 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.

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 BEA WebLogic Server™ 7.0.

The platforms and software used to create the exercises are Windows XP,™ JBuilder 7

Enterprise Edition, Borland JDataStore™ database, WebLogic 7.0 Single Server, and

Microsoft® Internet Explorer 6.0.

This paper is not a reference on developing EJBs, JSPs/servlets, or Java. Rather, it provides a

jump-start while using JBuilder 7 with WebLogic Server 7.0, allowing developers to reach

maximum productivity in the minimum amount of time.

Installing JBuilder® 7

Platforms

JBuilder 7 can be installed in Windows,® Solaris,™ Linux,® and Mac® OS X platforms.

System requirements

The minimum system requirement for JBuilder 7 Enterprise is 256MB. Also the

recommended hard disk space is 700MB. Refer to the link

http://www.borland.com/jbuilder/pdf/jb7_sysreqs.pdf for the details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5

Installation

A WebLogic-specific edition of JBuilder, JBuilder® WebLogic® Edition is available. A trial

version can be obtained from the following link.

http://www.borland.com/product/downloads_jbuilder.html

JBuilder can be installed with a trial or licensed CD which can be obtained from Borland

Sales Office. Please see http://www.borland.com/company/borland_worldwide.html for

contact information.

Registration

After JBuilder 7 trial edition installation, obtain the trial license key from the following link

http://www.borland.com/products/downloads/download_jbuilder.html.

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

Tuning JBuilder® 7

The 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 the white paper, the JBuilder 7 installation directory is assumed

as C:\Borland\JBuilder7.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

6

Installing WebLogic Server™ 7.0

Please check with the BEA Web site www.bea.com for installation instructions, system

requirements, and registration process.

Note: For the rest of the white paper, the WebLogic installation directory is assumed

as C:\bea.

Creating WebLogic® Single ServerThe exercises of this white paper are worked out with JBuilder 7 Enterprise, the JDataStore

database, and WebLogic Single Server.

To create a stand-alone single server, click Start-> All Programs -> BEA WebLogic

Platform 7.0 -> Configuration Wizard.

The first screen of the Configuration Wizard will ask you to choose a Domain Type and

Name. Select WLS Domain form the Select a template: panel. The default domain name is

mydomain. The next screen will ask you to choose a server type. Select the Single Server

(Stand-alone Server ) and click Next. The next screen will ask you to choose a Domain

location. The default location for domain mydomain is C:\bea\user_projects\. Hit

Next, and a Single Server will be created and configured for you.

Note: For the rest of the white paper, the WebLogic Single Server installation

directory is assumed as C:\bea\user_projects\mydomain.

JBuilder does not require WebLogic Server 7.0 to be installed in the same machine where

JBuilder 7 is installed. WebLogic can be installed anywhere in the network. If WebLogic is

installed in UNIX, the drives must be available via NFS, SAMBA etc.

SAMBA is available from www.samba.org or ftp://ftp.samba.org/pub/samba/ Select samba-

latest.tar.gz. Note that JBuilder 7 does not include any software or licenses for WebLogic.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

7

Note: If you have installed WebLogic 7.0 SP1, the JSP/Servlet integration with

JBuilder 7 is broken because of certain changes in the SP1. You can follow either of

the two options to work with JBuilder 7 and WebLogic 7.0 SP1.

Option 1: Download JBuilder, WebLogic Edition (JBWE) from the Borland or BEA Web

sites and follow the configuration steps mentioned in next section to configure JBWE with

WebLogic 7.0.

Option 2: If you rather use JBuilder 7, download JBWE from the Borland or BEA Web sites

and find the file webserverglue.jar from JBWE Edition. Then save the file to

<Jbuilder7_Installed_Dir>/patch.

After applying the patch you may see the following error when you try to start WebLogic

within JBuilder 7.

Error Descriptionjavax.servlet.UnavailableException:

ServletContext(id=3909729,name=JBuilder_DefaultWebApp,context-path=):

The server myserver is temporarily suspended

Solution

Open the WebLogic Console ( http://localhost:7001/console). Expand mydomain |

Servers | myserver . Click on myserver. Click on Logging tab. Change the Stdout

severity threshold from Error to Notice.

Configuring JBuilder® 7 withWebLogic® 7.0 Single Server

To configure JBuilder 7 with WebLogic Server 7.0, start JBuilder 7 from the JBuilder menu

bar. Click Tools -> Configure Servers. Select WebLogic Application Server 6.x+ from the

left-hand pane. Click the Enable Server checkbox. Enter C:/bea/weblogic700/server

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

8

under the Home Directory (if your BEA WebLogic installation directory is something other

than C:\bea, change the entry accordingly). The Main Class, VM parameters, and Working

Directory fields should be automatically populated.

Click the Class tab from right hand pane. Hit the Add button and add jdsserver.jar from

C:\Borland\JBuilder7\lib. Note that this JAR file is required only if you want to test Entity

Beans with the JDataStore database.

Similarly, if you like to work with Oracle® database, add classes12.zip, for DB2® add

db2java.zip; for Sybase® add Jconn2.jar or Jconnect.jar; and for SQL Server add

mssqlserver4v65.jar.

Note that classes12.zip, mssqlserver4v65.jar , Jconn2.jar and Jconnect.jar are available under

<BEA_Installed_Dir>/weblogic700/server/lib. Also note that these JDBC® drivers are for

specific database versions, and you may want to check with the database vendor for the

latest versions.

See Figure 1 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

9

Figure 1: Configure Servers window showing parameters for WebLogic integration

Working with JSPs™ and servlets

Create a project

Start JBuilder. Click File -> New -> Select Project tab from the Object Gallery. Click

Project. Click OK. In the Project Wizard—Step 1 of 3 specify a Directory Name and a

Project Name. Leave the Template as (Default Project). Hit Finish.

Note: The WebLogic ejbc compiler may not accept spaces in the working directory

and classpath. So specify a directory which does not have spaces.

For this exercise, the project directory is C:/JBWLS and Project Name is TestWeb

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 0

Attach the WebLogic Server™ to current project

You can attach the WebLogic Server to the current project. From the JBuilder menu bar, click

Project -> Project Properties. Click Server tab.

See Figure 2 for details.

Figure 2: Project Properties window allowing users to select application server of choice

Note: JBuilder provides users with the option of choosing one server for all services

in the project or multiple servers providing different servers. When choosing

Modular Services provided by different servers, the users can configure different

services to be run by different servers.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 1

For example: users can select Tomcat for JSP/server, Borland® Enterprise Server for EJB and

another server for Connector.

For simplicity, select WebLogic Application Server 6.x+ from the combo box and select

Single server for all services in the project.

Note: JBuilder is intuitive and automatically discovers the services provided by a

selected server. In our case, all services other than Connector, Deployment, EJB, and

JSP/servlet are grayed out because those services can’t be provided by WebLogic

Single Server.

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

Attach the WebLogic Server™ to all the projects

If you decide to use WebLogic Server for all of your projects, you can assign WebLogic to

Default Project Properties. From JBuilder menu bar click Project -> Default Project

Properties. Click Server tab. Select WebLogic Application Server 6.x+ from the combo

box and choose Single server for all 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. Click the checkbox saying Generate WAR.

Enter a name and directory for the Web application. For this exercise, the Web application

name is TestWebApp and directory is TestWebApp.

Note: JBuilder has recognized that the target server is WebLogic, so it automatically

created web.xml and weblogic.xml as the deployment descriptors for this Web

application.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 2

Create a JSP™

From the JBuilder menu bar, click File -> New -> Web tab in Object Gallery -> JavaServer

Page. Enter a JSP name. For this exercise, the JSP name is TestJSP. Click Next and enter a

package name in JSP Wizard—Step 2 of 4. For this exercise, the package name is

borland.demo.web. Click Next and then Finish.

This wizard creates a sample JSP and sample JSP bean in the specified package.

Note: The JSP wizard provides many options to users, like creation of a Sample

Bean, creation of an Error Page, 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 may show 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 this exercise is TestWebApp.war.

See Figure 3 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 3

Figure 3: JBuilder showing the generated sources, WAR file, and DDs for WebLogic

Deploy and run the JSP™ in WebLogic® Single Server

To deploy and run the JSP, simply right-click TestJsp.jsp from the JBuilder Project Pane and

click Web Run using TestJsp. This single click, starts the WebLogic Server within JBuilder,

deploys TestWebApp.war to WebLogic, runs the JSP in WebLogic, and shows the output

content of the JSP in JBuilder AppBrowser.™

Note: By default, when you right-click on a JSP/servlet/html and select Web Run, or

startup a server in a project which includes Web components, the Web application is

deployed in exploded format from the project directory. In this case, the WAR file is

not used for deployment. This is the preferred option if you work with JSPs, since

you do not need to redeploy to activate any JSP changes.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 4

To turn off this behavior and use WARs or EARs containing WARs, click on Project ->

Project Properties. Click on the Server tab. Click on the JSP/servlet service in the services

list. On the right, de-select the option Map project webapps at runtime.

Enter any value in the Text Box next to Enter New Value in the AppBrowser, and the value

should be displayed next to Value of Bean Property is.

See Figure 4 for details.

Figure 4: WebLogic is running in JBuilder, and AppBrowser displaying running JSP in

WebLogic

Note: This JSP is a simple JSP, created with JBuilder JSP Wizard which accepts a

string in the Text Box and displays it.Check the source code TestJSP.jsp and

TestJSpBean.java for details of the source code.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 5

Debug the JSP™

To debug the JSP, assign breakpoints in the source code whereever necessary. To assign a

breakpoint, simply open the source file and click the mouse on that line.

Note: For this exercise, the breakpoints are assigned at seventh line of the

TestJSP.jsp and 16th and 21st lines of TestJSPBean.java.

Stop the WebLogic server. Press Shift+F9 or just click on the Debug Project icon. Click

TestJSP to start WebLogic in debug mode within JBuilder.

See Figure 5 for details.

Figure 5: JBuilder debugger stopped at a breakpoint in JSP. The JSP is running in WebLogic

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 6

Note: When you click Debug Project, JBuilder starts WebLogic Server in debug

mode. You can now click the debug 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

debug operations.

Working with servlets

Create another Web application in the same Project TestWeb. To get help on how to create a

Web application, refer to the section Create a Web Application.

Note: For this exercise the name of the other Web application is ServletTest.

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 entered is borland.demo.web 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 generate an SHTML file with the servlet. Click Next.

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

SHTML file is checked.

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

defaults and click Next.

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 checkbox Create a Runtime Configuration and leave the default configuration

name as TestServlet. Hit Finish.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 7

Make the project. To get help on how to make a project, refer to the Make the Project section.

To deploy and run the servlet, stop the WebLogic Server. Right-click on the

TestServlet.shtml from Project Pane, then click Web Run -> Use TestServlet.

See figure 6 for details.

Note: You can also deploy and run the TestServlet by clicking the run icon from the

JBuilder toolbar and selecting TestServlet.

You don’t have to stop the WebLogic Server to deploy and run another application. You can

just right-click on ServletTest.war. Click Deploy Options for ServletTest.jar and hit Deploy.

After deployment, run the link http://localhost:7001/ServletTest/TestServlet.shtml from any

browser, and the servlet should be responding.

Figure 6: A servlet is running in WebLogic and displaying the results in JBuilder

AppBrowser

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 8

Troubleshooting

Error 1: WebLogic Server cannot start: config.xml not found

Error description<Info> <Management> <140013> <C:\bea\user_projects\.\config.xml not

found>

C:\bea\user_projects\.\config.xml not found

Since no config.xml was found, the fileRealm.properties file will not be used.

Would you like the server to create a default configuration and boot? (y/n):

When did this happen

I tried to run WebLogic Server from JBuilder and got this error from WebLogic 6.x+

http:7001 tab.

Cause

The Domain Directory provided in JBuilder Server Configuration may not be correct.

Solution

From the JBuilder menu bar, click Tools -> Configure Servers. Click WebLogic

Application Server 6.x+ from the left, and click Custom tab from the right. Check the

Domain Directory. An example of this entry is C:\bea\user_projects\mydomain.

Error 2: Authentication for user <username> denied

Error description<Critical> <WebLogicServer> <000364> <Server failed during

initialization. Exception:java.lang.SecurityException: Authentication

for user username denied

java.lang.SecurityException: Authentication for user username denied.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

1 9

When did this happen

I tried to start WebLogic Server within JBuilder and got this error from WebLogic 6.x+

http:7001 tab.

Cause

The username or password provided in JBuilder to configure with WebLogic Server may not

be correct.

Solution

From the JBuilder menu bar, click Tools -> Configure Servers. Click WebLogic

Application Server 6.x+ from the left, and click Custom tab from the right. Re-enter the

correct user ID and password.

Error 3: Document not found on server in AppBrowser

Error description

Unable to open location: Document not found on server.

When did this happen

I tried to run a JSP/servlet from JBuilder, and the AppBrowser shows this error.

Cause

The error confirms that the WebLogic Server is running properly, but the document

JSP/servlet that you are trying to access is not found in the WebLogic server.

Solution

Redeploy the Web application and try to run the JSP/servlet again.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 0

Error 4: Deployment of Web application failed

Error descriptionException:weblogic.management.ApplicationException: Prepare failed.

Task Id = 0

Module: TestWebApp Error: weblogic.j2ee.DeploymentException:

Cannot deploy ServletContext(id=2545674,name=TestWebApp,context-

path=/TestWebApp) from

C:\bea\user_projects\mydomain\myserver\upload\TestWebApp\TestWebApp.w

ar on myserver because there is already a webapp named

ServletContext(id=5684736,name=TestWebApp,context-path=/TestWebApp)

loaded from C:\Documents and

Settings\spati\jbproject\TestWebApp\TestWebApp, which is using the

context path /TestWebApp.

When did this happen

I tried to deploy my Web archive from JBuilder to WebLogic by right-clicking the WAR file -> Deploy Options -> Deploy.

Cause

Seems like you have already deployed a Web application with the same name to WebLogic

Server.

Solution

Turn off the exploded format deployment behavior to use WARs or EARs containing WARs

for deployment. Click on Project -> Project Properties. Click on the Server tab. Click on

the JSP/servlet service in the services list.. On the right, de-select the option Map project

webapps at runtime. Now you can deploy your WAR/EAR without any deployment

conflicts.

If the above solution does not work, try to create another Web application and add the

JSP/servlets you have created to the new Web application and deploy again.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 1

Error 5: build/compilation failed

Error description :"TestJsp.jsp": java.lang.NoSuchMethodException:

com.borland.jbuilder.webserverglue.weblogic.jsp.NadaJavac does not

define 'public static void compile(String[])'

"TestJsp.jsp": Error: compilation of jsp file /Jsp1.jsp (java file

C:\Documents and Settings\Sudhansu

Pati\jbproject\untitled11\classes\Temporary_Files\.jsp\testweb\jsp_se

rvlet\__jsp1.java failed):

null

"Jsp1.jsp": java.io.IOException: Compiler failed

executable.exec(java.lang.String[-classpath,])

Exception in thread "main"

Cause:

Seems like you have installed WebLogic Server 7.0 sp1. WebLogic 7.0 sp1 got released after

JBuilder 7 and because of some changes in the sp1, the JSP/Servlet integration is broken.

Solution:

Download JBWE from the Borland or BEA Web sites and find the file webserverglue.jar

from JBWE. Then save the file to <Jbuilder7_Installed_Dir>/patch .

Warning 1: deprecation warnings

Warning description :"Jsp1.jsp": Warning #: 368 : method putValue(java.lang.String,

java.lang.Object) in interface javax.servlet.http.HttpSession has

been deprecated at line 8

Warning #: 369: There have been deprecation warnings. Please consult the documentation for

a better alternative.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 2

When did this happen:

Whenever I compile/build my project I get a separate build tab in JBuilder 7 message pane

and these warning messages shows there. Also this happens when I start my WebLogic Server

within JBuilder and deploy my archives to WebLogic.

Cause:

Some of the methods created by JBuilder Wizard are deprecated.

Solution:

From JBuilder main menu bar click Project | Project Properties |Build tab and uncheck

Show Warnings and Show Deprecations.

Working with session beans

Create a project and assign WebLogic Server as the target server for the project. If you need

help on this, refer to the sections “Create a project” and “Attach WebLogic Server to current

project.” Note: For this exercise the name of the project created 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: You can select EJB 1.0 or EJB 2.0 specification for your EJB development. For this

exercise, the module name is TestSesMod and the version is EJB 2.0 compliant.

Create a session bean

With JBuilder, EJBs can be created visually. Right-click on the Editor Pane. Click Create

EJB. Click Session Bean. See Figure 7 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 3

Figure 7: JBuilder creating a session bean visually

Note: A visual session bean is created. You can change the name of the session bean

in the Bean Properties window. Click out, and the session bean with the specified

name is created. For this exercise, the name of the session bean is TestSes.

To add a method in the session bean, right-click on TestSes. Click Add. Click Method. See

Figure 8 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 4

Figure 8: JBuilder adding a business method to an EJB visually

Note: For this exercise, the method name is getName(), return type as string and

interfaces as remote.

Now double-click on the TestSesBean.java which automatically brings the source code for

TestSesBean.java in editor pane. Change the getName() method as follows.

public String getName() {

return "Testing Successful"; //change null to “Testing

Successful”

}

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 5

Create deployable JAR file

To run the session bean, first make the project. To get help on how to make the project, refer

to the section “Make the project”.

Note: After the make, the WebLogic specific container generated files and

deployment descriptors are created in JBuilder. Expand TestSesBean.java to view

the container-generated files and double-click TestSesMod.jar to view the

deployment descriptors in the structure pane. See Figure 9 for details.

Figure 9: JBuilder has created a ready-to-deploy JAR file for WebLogic with the required

container generated files

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 6

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

should show up with Run tab selected. Hit New to create a new runtime configuration.

In the Runtime Properties window, click the Server tab and enter a Configuration Name.

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

Figure 10 for details.

Figure 10: Creating a runtime configuration to start WebLogic in JBuilder

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 7

Run WebLogic Server™ within JBuilder®

Click on the run icon from the JBuilder menu bar and click Server. Now WebLogic Server

will run within JBuilder.

Deploy EJB™ JAR file to WebLogic®

Right-click on TestSesMod.jar Click Deploy options of TestSesMod.jar. Click Deploy.

JBuilder starts another tab called WebLogic Application Server 6.x+ Enterprise Deployer in

the message window to show the deployment status. See Figure 11 for details.

Figure 11: JBuilder displaying the deployment status in a separate tab

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 8

Remote deployment

This section is an optional step and provides tips how to deploy an archive to a remote

WebLogic Application Server.

Note: For deployment of archives (JAR, WAR, and EAR) to a remote WebLogic

Server, a local installation of the application server is needed because the

deployment tool needs local WebLogic utilities for remote deployment.

If you are deploying to WebLogic 7, from JBuilder menubar click Tools -> Enterprise

Deployment. A window called WebLogic 6.x+ Deploy Setting pops up. Modify the Admin

url field to point to the remote server with the remote WebLogic server’s host name and port

number (http://<servername>:<port number>).

If you are deploying to WebLogic 6.x, modify the options field to include the parameters, -

host <host name> -port <port number> to deploy to a remote WebLogic server. In this case,

please ensure that the server name (Server name field in the deployment wizard) is correct

with respect to the remote server. The default provided in JBuilder is 'myserver'. Note that this

is a logical server name and does not correspond to the host name.

Refer to Figure 12 for details on remote deployment options.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

2 9

Figure 12: WebLogic 6.x+ Deploy Setting window. You can deploy to a remote WebLogic

Server using this feature.

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. Hit OK.

Note: For this exercise, enter the class name as TestSesTestClient.

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) { }

}

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 0

Make the TestSesTestClient.java. (Right-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 -> Application

tabs, then select Main class as the TestSesTestClient by clicking the ellipses and enter a name

under the configuration name.

You can change the Build Target to <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 13 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 1

Figure 13: Running a test client in JBuilder and showing outputs from EJB

Note: The test client runs within JBuilder by creating another tab in the message

pane. You can see the successful execution of the Test Client from the last line

“Name From the Test Client = Testing Successful”.

Troubleshooting

Error 6: NameNotFoundException from test client

Error descriptionjavax.naming.NameNotFoundException: Unable to resolve 'TestSes'

Resolved: ''Unresolved:'TestSes'; remaining name 'TestSes'

When did this happen

I have deployed my EJB JAR file. Now, I am running my TestClient and it fails.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 2

Cause

The test client is unable to find the JNDI name of the EJB.

Solution

Check the deployment of EJB JAR file again. The deployment may have failed. To check the

deployment, start WebLogic console, find the EJB module name from Deployments ->EJB,

click on the EJB Module name, then click Deploy from the right-side window. If the JAR

file is deployed properly, you will see a deployment status as true in the WebLogic console.

Also click on Monitoring tab, and click the corresponding links to see if your EJB is

running.

See Figure 14 for details of a running EJB.

Figure 14: WebLogic console showing the running status of EJB EmployeeSes

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 3

Error 7: Test client run failed

Error descriptionjavax.naming.CommunicationException. Root exception is

java.net.ConnectException: t3://localhost:7001: Destination

unreachable; nested exception is: java.net.ConnectException:

Connection refused: connect; No available router to destination

When did this happen

I have deployed my EJB JAR file successfully. When I run my test client, I got the above

error message from the Test Client tab of JBuilder message pane.

Cause

The test client is unable to communicate with WebLogic server.

Solution

Note that the PROVIDER_URL to connect to WebLogic server is hardcoded in the test client.

The hardcoded value is t3://localhost:7001. If you have started your WebLogic server

in another hostname or port number, for any reason, change this value to match the new

values.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 4

Working with entity beans

Create a project, assign WebLogic Server as the target application server for the project, and

create an EJB module. To get help on how to create a project, refer to the section “Create a

project.” To get help on how to assign WebLogic Server to current project, refer to the

section “Attach WebLogic Server to current Project.” 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.

Import a database schema

Right-click on the Editor Pane. Click Import Schema from Database. That brings up the

Database Schema Provider window. Enter the Database Driver, URL, Username,

Password, and JNDI name.

Note: for this exercise, JDataStore will be used as database. Enter the following

values in the Database Schema Provider window.

Driver: com.borland.datastore.jdbc.DataStoreDriver

URL:jdbc:borland:dsremote://localhost//C:\Borland\JBuilder7\samples\JData

Store\datastores\employee.jds

JNDI name: DemoDataSource.

See Figure 15 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 5

Figure 15: JBuilder Database Schema Provider

Create an entity bean

Expand DemoDataSource from the JBuilder structure pane to see the list of tables available

in the database. You can create entity beans visually just by right-clicking a table name and

clicking Create CMP 2.0 Entity Bean or Create BMP Entity Bean.

Note: For this exercise, a CMP 2.0 Entity Bean will be created for Employee Table.

Right-click on EMPLOYEE from the structure pane and click Create CMP 2.0 Entity

Bean. This creates a Visual Employee Entity Bean in the editor pane; you can also check the

corresponding source code in the editor pane by expanding the package called testent in

project pane.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 6

Create a session bean

Please refer to the section “Create a session bean” in “Working with session beans” for details

on how to create a session bean.

Note: For this exercise, the name of the session bean is EmployeeSes which is

created under the same package name testent.

Add a method to EmployeeSes and provide the following parameters.

Method name: getEmpName

Return type: String

Input parameters : Short empNo

Interfaces: remote

See Figure 16 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 7

Figure 16: Visual EJBs in JBuilder displaying the fields and methods

Double-click EmployeeSesBean.java from the JBuilder project pane and change the

getEmpName(Short empNo) method as follows.

public String getEmpName(Short empNo) {

String empName = "name not found";

try {

javax.naming.Context context = new

javax.naming.InitialContext();

Object object = context.lookup("java:comp/env/ejb/Employee");

EmployeeHome empHome = (EmployeeHome)

javax.rmi.PortableRemoteObject.narrow(object, EmployeeHome.class);

Employee emp = empHome.findByPrimaryKey(empNo);

empName = emp.getFirstName() + " " + emp.getLastName();

}catch (NamingException ex) {

ex.printStackTrace();

}catch (ClassCastException ex) {

ex.printStackTrace();

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 8

}catch (Exception ex){

ex.printStackTrace();

}

return empName;

}

Assign entity bean reference to session bean

Since the session bean EmployeeSes is calling the entity bean Employee, you have to store

the Employee entity bean reference in the deployment descriptor. The deployment descriptor

tool of JBuilder can be used to create a reference visually.

Double-click EmployeeSes under TestEntMod from JBuilder project pane and click EJB

Local references tab at the bottom of the editor pane.

Click Add and enter the name as ejb/Employee in EJB Local Reference window. Hit OK.

Click the checkbox Islink. The other columns Link, Local Home and Local should be

populated automatically. Just to make sure check the values of the following columns.

Link: Employee

Type: Entity

Local home: testent.EmployeeHome

Local: testent.Employee

See Figure 17 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

3 9

Figure 17: Creating an EJB reference visually using JBuilder Deployment Descriptor

Editor Tool.

Create a test client

Create a test client to call the session bean EmployeeSes which in turn calls the entity bean

Employee. The entity bean Employee gets the data from the database, sends to the session

bean and the session bean sends the data to the test client. Please refer to the section “Create a

test client to test the session bean” in the section “Working with session beans” to get help 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 Test Client EmpSesTestClient.java as follows.

public static void main(String[] args) {

EmployeeSesTestClient client = new EmployeeSesTestClient();

try {

client.create();

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 0

String empName = client.getEmpName(new Short("2"));

System.out.println("Employee Name from the Test Client is = " +

empName);

}

catch (Exception ex) {

ex.printStackTrace();

}

}

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” from “Working with JSPs and servlets.”

Note: You can ignore the warnings because of method deprecations. To avoid seeing

these warnings, click Project -> Project Properties -> Build tab -> uncheck Show

Warnings and Show Deprecations from the Java tab.

Create runtime configurations

For this exercise, we have to create two runtime configurations.

Server type: to run WebLogic Server within JBuilder.

Client 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 our exercise, Enter the Configuration Name as Server. Also you can

change the build target to <NONE> in the Runtime Properties window.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 1

To create a client type runtime configuration, from the JBuilder menu bar, click Run ->

Configurations Click New. Click Application tab. Find the Main Class -> enter a

Configuration Name. Hit OK.

Note: For our exercise, enter the Configuration Name as Client. Click the ellipses

and find the test client testent.EmployeeSesTestClient. Also, you can change build

target to <NONE> in the Runtime Properties window.

Start WebLogic Server™ and JDataStore™ Server

Click on the run icon from the JBuilder toolbar and click Server. WebLogic Server will start

within JBuilder.

To start the JDataStore Server, click Start -> All Programs -> JBuilder 7 Enterprise ->

JDataStore Server.

Note: the JDataStore Server has to be started for this example because the data

source uses a remote connection to the JDataStore database. You can also connect to

the database locally, that way you don’t have to start the JDataStore Server. But the

local connection allows only one connection to the JDataStore database. Make sure

that the JDataStore Server is running all the time during execution of this exercise.

You can certainly use a database other than JDataStore.

Create data source entries in WebLogic®

Start WebLogic console. To start the console, open your favorite browser and type

http://localhost:7001/console. The assumption here is that WebLogic Server is

running locally on port 7001.

You can also start the WebLogic console from JBuilder. From the JBuilder menu bar, click

Tools -> Configure Tools. Click Add in the Configure Tools window. The Add Tool

window pops up. Enter the following parameters in the Add Tools window.

Title: WebLogic Console

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 2

Program: C:\bea\weblogic700\server\bin\beaexec.exe

Parameters: -target:browser -command:http://localhost:7001/console

Now an entry called WebLogic Console is added in JBuilder Tools menu. Click Tools ->

WebLogic Console to start the WebLogic console.

Create a connection poolFrom WebLogic console, expand Services -> expand JDBC®. Click Connection Pools. Click

Configure a New JDBC Connection Pool from the right window. Enter the following

parameters to create a connection pool.

Name: DemoPool

URL:jdbc:borland:dsremote://localhost//C:\Borland\JBuilder7\samples\JData

Store\datastores\employee.jds

Driver Classname: com.borland.datastore.jdbc.DataStoreDriver

Properties (key=value): user=<username>

password=<password>

Note: Enter your own username and password. Hit Apply.

See Figure 18 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 3

Figure 18: WebLogic console to create a connection pool

Click Connections from the right window, which is under Configuration tab. Provide the

values of the following parameters.

Initial Capacity

Maximum Capacity

Capacity Increment

Note: Provide the values according to your needs. For this exercise, the values for

these parameters are 2, 5, and 1 respectively.

See Figure 19 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 4

Figure 19: WebLogic console specifying the connection parameters for the connection pool

Click Targets -> move myserver from Available to Chosen. Hit Apply.

Note: Once you move myserver from Available to Chosen, you can check the

JDataStore Server for open connections. A successful connection pool creation will

create the number of connections in JDataStore, where the number of connections is

the Initial Capacity specified in the Connection tab of the connection pool.

See Figure 20 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 5

Figure 20: JDataStore Server displaying two connections opened by WebLogic

Create a Transactional DataSourceFrom the WebLogic console, expand Services -> expand JDBC. Click Tx Data Sources.

Click Configure new JDBC Tx Data Source from right window.

Enter the following parameters to create a Transactional DataSource.

Name: DemoDataSource

JNDI Name: DemoDataSource

Pool Name: DemoPool

See Figure 21 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 6

Figure 21: WebLogic console window to create a data source

Click Targets -> move myserver from Available to Chosen. Hit Apply.

Test the DatasourceTo make sure that you have created the data source and pool successfully, stop the WebLogic

Server from JBuilder and start it again. If you don’t see any errors in the WebLogic message

window of JBuilder, that means the connection pool and data source are created and running

successfully. Make sure that the JDataStore Server is running.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 7

Deploy entity bean and session bean to WebLogic®

From JBuilder, right-click on TestEntMod.jar from project pane. Click Deploy Options for

TestEntMod.jar. Click Deploy.

Now WebLogic Application Server 6.x+ Enterprise Deployer tab should be opened in

JBuilder message pane showing the deployment status. Close the Deployment window after

you see a “success” message in the WebLogic Application Server 6.x+ Enterprise Deployer

window.

Run the test client

From the JBuilder Toolbar, click on the Run icon. Click Client.

Now the EmployeeSesTestClient will start in the JBuilder message pane. Check the messages

from the EmployeeSesTestClient tab. A successful execution will return the name “George

Nelson” from the Employee entity bean.

See Figure 22 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 8

Figure 22: The test client displaying the outputs from running EJBs in WebLogic

Troubleshooting

Error 8: Cannot create connection pool

Error descriptionjava.lang.NullPointerException

at

weblogic.management.console.utils.MBeans.getMBeanClassNameFor(MBeans.

java:1153)

When did this happen

I tried to create my DemoPool using WebLogic console. I entered the configuration

parameters and then tried to assign this DemoPool to myserver. (To assign to myserver, I

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

4 9

clicked Targets and moved myserver from Available to Chosen.) I see the above error

message in the WebLogic console.

Cause

The URL name, Driver name, user ID or password entered in the DemoPool Configuration

may not be correct. If those entries are right, then the Driver Classes may not have loaded

during the WebLogic Server startup.

Solution

Go back to JBuilder message pane and check to see if the error message from WebLogic

Server window is:

<Error> <JDBC> <001060> <Cannot startup connection pool "DemoPool"

java.sql.SQLException: No suitable driver>

If so, from the WebLogic console, click Targets, move myserver from Chosen to Available.

Click Apply. Click Configurations and correct the URL name. Click Apply. Again,click

Targets, move myserver from Available to Chosen and see if the error message is gone.

If the error message is:

<Error> <JDBC> <001060> <Cannot startup connection pool "DemoPool"

weblogic.common.ResourceException: Cannot load driver class:

om.borland.datastore.jdbc.DataStoreDriver>”

Then, from WebLogic console, click Targets, move myserver from Chosen to Available.

Click Apply. Click Configurations and correct the Driver name, click Apply. Again, click

Targets, move myserver from Available to Chosen and see if the error message is gone.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 0

If the error message is:

<Error> <JDBC> <001060> <Cannot startup connection pool "DemoPool"

weblogic.common.ResourceException: weblogic.common.ResourceException:

Could not create pool connection. The DBMS driver exception was:

java.sql.SQLException: You do not have STARTUP rights for this

JDataStore

The from the WebLogic console, click Targets, move myserver from Chosen to Available.

Click Apply. Click Configurations and correct the username and password, click Apply.

Make sure that you provide the user ID and password information as follows

user=

password=

Click Targets, move myserver from Available to Chosen and see if the error message is

gone.

If the error message is:

<Error> <JDBC> <001060> <Cannot startup connection pool "DemoPool"

weblogic.common.ResourceException: Cannot load driver class:

com.borland.datastore.jdbc.DataStoreDriver>

The from the WebLogic console, click Targets, move myserver from Chosen to Available,

click Apply. Check the WebLogic Server configuration from JBuilder . From the JBuilder

menu bar, click Tools -> Configure Servers. Click WebLogic Application Server 6.x+

from the left panel and check if you have added the JDataStore driver classes user in the Class

tab in the right panel. If you haven’t added them, click Add and add jds.jar,jdsremote.jar and jdsserver.jar from C:\Borland\JBuilder7\lib

directory.

Restart WebLogic Server, click Targets for DemoPool from the WebLogic console, move

myserver from Available to Chosen, and see if the error message is gone.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 1

Error 9: Cannot create data source

Error descriptionjava.lang.NullPointerException at

weblogic.management.console.utils.MBeans.getMBeanClassNameFor(MBeans.

java:1153)

When did this happen

I have created my connection pool called DemoPool successfully using the WebLogic

console. Now trying to create my data source called DemoDataSource, I have entered the

configuration parameters and then tried to assign this DemoDatasource to myserver. (To

assign to myserver, I clicked Targets and moved myserver from Available to Chosen.) I see

the above error message in the WebLogic console.

Cause

The pool name entered may not be correct.

Solution

Go back to the JBuilder message pane and see the error message from the WebLogic Server

window.

If the error message is:

<Error> <JDBC> <001059> <Error during Data Source creation:

weblogic.common.ResourceException: DataSource(DemoDataSource) can't

be created with non-existent Pool (connection or multi) (DemoPoo)

From the WebLogic console, click Targets, move myserver from Chosen to Available, click

Apply. Click configurations and correct pool name, click Apply. Again, click Targets, move

myserver from Available to Chosen and see if the error message is gone.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 2

Error 10: Can’t start connection pool in WebLogic

Error description<Error> <JDBC> <001060> <Cannot startup connection pool "DemoPool"

weblogic.common.ResourceException: weblogic.common.ResourceException:

Could not create pool connection. The DBMS driver exception was:

java.net.ConnectException: Connection refused: connect.

When did this happen

I have created my connection pool and data source successfully. When I started my WebLogic

Server, I got the above error.

Cause

WebLogic Server is trying to connect to the database, and it is failing. Possible reason is the

Database may not be available.

Solution

Start the JDataStore Server. Click Start -> All Programs -> JBuilder 7 Enterprise ->

JDataStore Server to start the Server. After starting JDataStore Server, stop WebLogic

Server and start it again to see if the error is gone.

Error 11: Test client not returning employee name

Error descriptionEmployee Name from the Test Client is = name not found

When did this happen

I have successfully created connection pool and a data source using the WebLogic console. I

have started my WebLogic Server and JDataStore Server and have successfully deployed my

EJB™ JAR file to WebLogic. I ran my test client and the test client got the following

message from the Test Client tab.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 3

Cause

Your test client is communicating properly with the session bean EmployeeSes. But the

session bean EmployeeSes is not connecting to the entity bean Employee.

Solution

Go back to the JBuilder message pane and see the error message from WebLogic Server tab.

If the error message is:

javax.naming.NameNotFoundException: Unable to resolve

'app/ejb/TestEntMod.jar#EmployeeSes/comp/env/ejb/Employee' Resolved:

'app/ejb/TestEntMod.jar#EmployeeSes/comp/env' Unresolved:'ejb' ;

remaining name 'ejb/Employee

Check if your entity bean reference from session bean is correct. Refer to section “Assign

entity bean reference to session bean.”

Error 12: EJB™ JAR deployment failed

Error descriptionException:weblogic.management.ApplicationException: activate failed

for TestEntMod

Module: TestEntMod Error: Exception activating module:

EJBModule(TestEntMod,status=PREPARED)

Unable to deploy EJB: Employee from TestEntMod.jar:

weblogic.ejb20.WLDeploymentException: The DataSource with the JNDI

name: EmpDataSource could not be located. Please ensure that the

DataSource has been deployed successfully and that the JNDI name in

your EJB Deployment descriptor is correct.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 4

When did this happen

I have successfully created a connection pool and a data source using the WebLogic console. I

have started my WebLogic Server and JDataStore Server and when trying to deploy my EJB

JAR file, I got the above error from WebLogic Application Server 6.x+ Enterprise Deployer

tab from JBuilder.

Cause

The data source names created in WebLogic and the data source name specified in the

Database Schema provider window of JBuilder while Importing Schema from Database does

not match.

Solution

Check the data source name from the WebLogic console. Now from the JBuilder Project

pane, double-click entity bean Employee and click WebLogic 6.x+ general tab from the

Editor Pane. Change the data source name to match with the data source name created in

WebLogic.

Save all, make the project, and redeploy the EJB JAR file again.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 5

Remote debugging

JBuilder can remotely debug an already running application in another Java process, in this

case WebLogic Server. To remotely debug an application, the application server has to be

started in debug mode.

Note: This exercise assumes that you have already created an entity bean, session

bean, test client, and deployed to WebLogic. In this section, we will remotely debug

the EJBs created in the previous section.

Create batch files

From Microsoft Internet Explorer, go to C:\bea\user_projects\mydomain. Copy

startWebLogic.cmd to startRemoteWebLogic.cmd in the same directory and make the

following changes to startRemoteWebLogic.cmd.

@rem Call WebLogic Server

call "C:\bea\weblogic700\server\bin\startRemoteWLS.cmd"

Note: startWLS.cmd is changed to startRemoteWLS.cmd. You can also optionally

provide your user name and password at the following two statements.That way you

don’t have to provide the user ID and password at the time of running WebLogic.

set WLS_USER=

set WLS_PW=

From Explorer, go to C:\bea\weblogic700\server\bin. Copy startWLS.cmd to

startRemoteWLS.cmd in the same directory and make the following changes to

startRemoteWLS.cmd.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 6

Change 1set

CLASSPATH=%JAVA_HOME%\lib\tools.jar;C:\Borland\JBuilder7\lib\jaxrpc.j

ar;C:\Borland\JBuilder7\lib\jds.jar;C:\Borland\JBuilder7\lib\jdsremot

e.jar;C:\Borland\JBuilder7\lib\jdsserver.jar;%WL_HOME%\server\lib\web

logic_sp.jar;%WL_HOME%\server\lib\weblogic.jar;%CLASSPATH%

Change 2@rem Start Server

@echo off

if "%ADMIN_URL%" == "" goto runAdmin

@echo on

"%JAVA_HOME%\bin\java" -classic %MEM_ARGS% -Xdebug -Xnoagent -

Djava.compiler=NONE -

Xrunjdwp:transport=dt_socket,server=y,address=5555,suspend=n

%JAVA_OPTIONS% -classpath "%CLASSPATH%" -Dweblogic.Name=%SERVER_NAME%

-Dbea.home="C:\bea" -Dweblogic.management.username=%WLS_USER% -

Dweblogic.management.password=%WLS_PW% -

Dweblogic.management.server=%ADMIN_URL% -

Dweblogic.ProductionModeEnabled=%STARTMODE% -

Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" -

Daxis.enableListQuery=true weblogic.Server

goto finish

:runAdmin

@echo on

"%JAVA_HOME%\bin\java" -classic %MEM_ARGS% -Xdebug -Xnoagent -

Djava.compiler=NONE -

Xrunjdwp:transport=dt_socket,server=y,address=5555,suspend=n

%JAVA_OPTIONS% -classpath "%CLASSPATH%" -Dweblogic.Name=%SERVER_NAME%

-Dbea.home="C:\bea" -Dweblogic.management.username=%WLS_USER% -

Dweblogic.management.password=%WLS_PW% -

Dweblogic.ProductionModeEnabled=%STARTMODE% -

Djava.security.policy="%WL_HOME%\server\lib\weblogic.policy" -

Daxis.enableListQuery=true weblogic.Server

:finish

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 7

Run WebLogic Server™ in debug mode

outside of JBuilder®

Start a MS-DOS window. In the command prompt, typeC:\bea\user_projects\mydomain\startRemoteWebLogic

If WebLogic Server has started successfully, you will see the following message.

<Notice> <WebLogicServer> <000360> <Server started in RUNNING mode>

Create runtime configuration for remote debugging

From the JBuilder menu bar, click Run -> Configurations. The Project Properties window

with Run tab selected 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 click Attach in the Remote Settings panel. Now the address textbox of

Transport panel should be active. Enter the address 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 debug options. JBuilder will open a socket connection to the WebLogic

Server and attach to WebLogic.

Assign breakpoints

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

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

Breakpoint 1

File name: EmployeeSessionBean.java

Line # : 26

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 8

Line Desc: javax.naming.Context context = newjavax.naming.InitialContext();

Breakpoint 2

File name: EmployeeBean.java

Line # : 29

Line Desc: public abstract java.lang.String getFirstName();

Attach JBuilder® to WebLogic® remotely

To attach JBuilder to WebLogic Server remotely, from the JBuilder toolbar, click Debug

Project icon. Click Remote Debug.

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

See Figure 23 for details.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

5 9

Figure 23: JBuilder opened a connection to remote WebLogic Server

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

6 0

Run the test client to debug the EJBs™

From the JBuilder toolbar, click Run icon -> Client. Now you should see the debugger

stopping at breakpoint 1 which is at line 26 of EmployeeSessionBean.java.

See Figure 24 for details.

Figure 24: JBuilder remotely debugging running EJBs. Debugger stopped at the breakpoint.

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

Click on EmployeeBean.java to see the status of breakpoint 2. If you see a red cross mark, it

means that the breakpoint is not valid for that line.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

6 1

Note: Remote debugging process is slower that the normal run process. This is

because the JVM has to operate in a debug mode which is slower than the normal

run mode.

Troubleshooting

Error 13: WebLogic® remote server failed to start

Error description<Server failed during initialization.

Exception:weblogic.management.configuration.ConfigurationException:

undefined mbean reference:

mydomain:Name=JBuilder_DefaultWebApp,Server=myserver,Type=WebAppCompo

nentweblogic.management.configuration.ConfigurationException:

undefined mbean reference:

mydomain:Name=JBuilder_DefaultWebApp,Server=myserver,Type=WebAppCompo

nent

When did this happen

The error occurred when I tried to run startRemoteWebLogic.cmd from the command prompt.

Cause

The error occurred because of the unreferenced Web application JBuilder_DefaultWebApp in

the WebLogic Server. JBuilder creates this application in WebLogic and sometimes doesn’t

delete it properly.

Solution

From the WebLogic console, expand Deployments -> expand Web Applications. Delete

JBuilder_DefaultWebApp from the right window.

Also check the config.xml from C:\bea\weblogic700\server\bin and delete the following

lines.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

6 2

<WebServer DefaultWebApp="JBuilder_DefaultWebApp"

LogFileName=".\myserver\access.log" LoggingEnabled="true"

Name="myserver"/>

Error 14: JBuilder attachment to WebLogic 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 WebLogic Server.

Cause

The error occurred because either WebLogic is not running properly, or the debug parameters

provided to start WebLogic are not correct.

Solution

Check if WebLogic 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

JBuilder menu bar, click Run -> Configuration. Edit the Remote Debug entry. Click Debug

tab and check the address. Make sure that the port number provided in this address is the same

as the address provided in WebLogic debug options.

Borland® JBuilder® 7 and BEA® WebLogic Server™ 7.0 Integration

6 3

Additional informationBorland JBuilder

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

Borland Optimizeit™ Suite

http://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™ Edition

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

Sun® Microsystems Java 2 Platform Enterprise Edition

http://java.sun.com/j2ee/

Sun Microsystems Enterprise JavaBeans™

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

BEA® WebLogic Server™

http://www.bea.com/products/weblogic/server/index.shtml

JBuilder OpenTools

http://www.borland.com/jbuilder/resources/jbopentools.html

Feedback and suggestions

Please send your feedback and suggestions to :

Sudhansu Pati , Systems Engineer

[email protected]

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