Posts Tagged ‘JDBC Driver’

WebSphere 3.5 – Frequently Asked Questions

Wednesday, March 25th, 2009

Table of Contents

1. How do I install WebSphere Application Server when logged on to a Windows NT domain?
2. While starting WS Admin Server from control panel, the error comes which says “Service Code 10 error, unable to start the service”. What is it and how to solve it?

 

3. For Developing Beans and Servlets what changes should I make in my System Classpath?

 

4. While Deploying a bean, WebSphere provide 2 options “Deploy only” and “Deploy and Workload Manage”. What are these and which one should I use?

 

5. My class gets compiled perfectly but when I try to deploy it on WebSphere it gives NoClassDefFoundError? Whats the reason?

 

6. Where can I find my System.out.println() or System.err.println() statements written in my bean?

 

7. I want to connect to Oracle Database. How to do that?

 

8. How to install a JDBC Driver and configure a DataSource with a SINGLE GUI?

 

9. How to look up DataSource?

 

10. What care should I take while running a java client to access the beans?

 

11. I am getting ClassCastException while running a java client. What is the reason?

 

12. I have changed the business logic in my Bean. Does this mean that I have to redeploy the bean?

 

13. Deployment of my bean fails. In the stack trace, the last line it shows is “Veriying EJBs……”?

 

14. Is it possible to precompile JSPs for WebSphere Application Server?

 

15. How to monitor the performance of the WebSphere?

 

 

1. How do I install WebSphere Application Server when logged on to a Windows NT domain?

If you log on with a domain user account and try to install WAS, make sure:

 

Ø You are added into the local administrator group (YOURDOMAIN/YOURUSERNAME must be in the member list of the local administrator group). If not, the installation will stop and say you are not allowed to install.

Ø Your username is also a local user account on the computer you are using.

Ø Your local user account is a member of the administrator group.

Ø Your local account password matches the domain account password.

 

If you do not have a local account, installation continues but you might not see any services. If your passwords don’t match, you can still install but your services might fail, because each service uses the domain password to start the service and validate the password against the local machine.
2. While starting WS Admin Server from control panel, the error comes which says “Service Code 10 error, unable to start the service”. What is it and how to solve it?

 

This error implies that Windows is unable to start this particular service, may be because there is some configuration failure in the internal files that windows read while starting the service or there can be many more reasons.

To debug the reason of the error see the “tracefile” which the server creates. Its in <WAS_HOME>/logs/tracefile. (Where WAS_HOME is the path where your bin, logs and other such folders lie, Ex. C:/WebSphere/AppServer)

 

Moreover, one can try to start the server from command prompt.

Go to <WAS_HOME>/bin/debug and start adminserver.bat. This internally sets all the paths required for running the server and then starts the server and hence the chances of failure are less. It also provides messages on command prompt and one can find the reason for failure.

 

From my practical experience I have noticed that whenever there are some changes made in “admin.config” file which lies in <WAS_HOME>/bin directory, this error crops up. Presently there is absolutely no need of changing your admin.config file. Without changing it we can meet our objective. Its explained in detail in the fifth question.
3. For Developing Beans and Servlets what changes should I make in my System Classpath?

Make sure that you are using JDK given by the WebSphere.

For developing beans and servlets , apart from adding jars that are provided with JDK of WebSphere , add

<WAS_HOME>/lib/ujc.jar; <WAS_HOME>/lib/ejs.jar; <WAS_HOME>/lib/servlet.jar;<WAS_HOME>/jdk/jre/lib/ext/iioprt.jar

 

4. While Deploying a bean, WebSphere provide 2 options “Deploy only” and “Deploy and Workload Manage”. What are these and which one should I use?
As far as deploying is concerned both are same.

Workload Management is used when you are using multiple servers and are expecting a huge load on your server. In this scenario it becomes important that your request gets distributed between different servers so that the load can be balanced and resources of the server can be properly utilized.

 

5. My class gets compiled perfectly but when I try to deploy it on WebSphere it gives NoClassDefFoundError? What’s the reason?

WebSphere manages its OWN CLASSPATH. So it will not look into your system classpath to find out for a particular class.

In the Administrator console, when you click on Default_server, then on right hand side you can see a text box with subject as “Command Line Arguments”. This is where you can set your classpath.

Type

-classpath <path of your jar>

If more than 1 jar is there, then use “;(semi-colon)” as a separator.

Ex. -classpath c:/MyJars/ABC.jar;c:/MyJars/BCD.jar
Click Apply and then restart the default server. The changes will be reflected soon after.

Make sure that there is no space after semi-colon.

This is the path that will be searched first by the Application server for a particular class.

Make sure that you keep jars of only helper classes in this path.

Doing this you can avoid changing admin.config every time and hence would not need to restart the AdminServer.
6. Where can I find my System.out.println() or System.err.println() statements written in my bean?

 

If you are using Default Server, then

System.out.println() statements can be found out in <WAS_HOME>/logs/default_server_stdout.log file

System.err.println()statements can be found out in <WAS_HOME>/logs/default_server_stderr.log file.

 

7. I want to connect to Oracle Database. How to do that?
To connect to oracle database first you include “Classes12.zip” in your Application Classpath(how to add a jar/zip to application classpath has been discussed in question 5) as it provides the thin driver “oracle.jdbc.driver.OracleDriver” which is used by java to connect to Oracle. Now Restart the server.

 

Add the following code in your java program-

 

import oracle.jdbc.driver.OracleDriver;

 

public Connection getConnection();

{

try

{

DriverManager.registerDriver(new OracleDriver());

String url = “jdbc:oracle:thin:@<hostname>:<portno>:<sid>”;

 

//where

//hostname is the name where the Oracle Server is installed.

//portno is the port no on which oracle listens, (by default Oracle listens on 1521)

//sid is the database name

 

Connection con = DriverManager.getConnection(url,<user_name>,<password>);

}

catch (Exception e)

{

System.out.println(e.getMessage());

}

return con;

}

 

8. How to install a JDBC Driver and configure a DataSource with a SINGLE GUI?

Click the “Console” on the Menu bar , then click “Tasks”, then click “Create Data Source”.

It will give you 2 options. Choose the option that says “Create and Install new JDBC Driver”.

Follow the steps that are similar to creating a JDBC driver and after that it will give the GUI that asks for the DataSource name and the Database name.

Complete it and click the finish button.

Hence installing a driver and configuring a DataSource will be done in a single procedure.

 

9. How to look up DataSource?
Suppose the name of the Datasource given by you is “mysource”.

Then while looking it up use “jdbc/mysource”;

 

E.g.

InitialContext ic = new InitialContext();

DataSource ds = (DataSource)ic.lookup(”jdbc/mysource”);

 

The Java object retrieved is a DataSource object stored in the “jdbc” context with the logical name of “mysource.”

 

10. What care should I take while running a java client to access the beans?

Make sure you are using the jdk that’s shipped with WebSphere. Set the path parameter of your System to <WAS_HOME>/jdk/bin.

Make your Classpath settings for jars in <WAS_HOME>/jdk/jre/lib and for

Jars in <WAS_HOME>/jdk/jre/lib/ext directory.

Make sure that you have added the DeployedJar in your System Classpath as it contains Stubs which the client will be using to communicate with beans else you will get ClassCastException.

Even after doing this if you get any NoClassDefFoundError then try setting the System classpath for the jars that are present in the <WAS_HOME>/lib directory.

 

11. I am getting ClassCastException while running a java client. What is the reason?
Refer to previous question.

 

12. I have changed the business logic in my Bean. Does this mean that I have to redeploy the bean?
NO. Deployment in no manner is concerned with the business logic of your bean.

 

Hence if you want the new changes to get reflected in the bean do the following steps -

 

v Recompile your bean with the changes.

v Copy the compiled class and paste it into a folder which represents its package hierarchy under the C:\ drive(or any other drive)

E.g. Suppose your class name is com.bgc.nps.ABC.class.

And this class when seen in the explorer lies in c:\MyFolder\Project\com\bgc\nps\ABC.class
If this is the case then make a hierarchy in your “C:\” drive and place the ABC.class in this package.

So your new class when seen in explorer will lie in

C:\com\bgc\nps\ABC.class.

v Stop the default server

v Open DeployedJar of your bean in the WinZip.

v Check the checkbox which says “Save extra folder info”

v Click on “Add” and browse for your bean class (i.e. ABC.class) under new path.

v Add it to the zip

v Restart the Default Server.
13. Deployment of my bean fails. In the stack trace, the last line it shows is “Verifying EJBs……”?
Failure at this step means that the method signature in the REMOTE interface DOES NOT match with that in your implementation (i.e. Bean) class.

 

E.g. If in Remote interface you declare a function as

public String myString(String a) throws RemoteException, SQLException;

And in your Implementation Class you write this function as

Public String myString(String a) throws RemoteException

As the declaration and implementation are not identical, hence Deployment will fail.

 

14. Is it possible to precompile JSPs for WebSphere Application Server?

Use the jspbatchcompiler.bat file that ships with WebSphere Application Server. It is located in the <WAS_HOME>\bin directory, and uses a configuration file (batchcompiler.config) to pass in the parameters it needs.

In evaluation copy this facility may NOT be available but its available for licensed copy.

 

15. How to monitor the performance of the WebSphere?
There is a stand-alone tool known as Resource Analyzer. It can monitor performance related issues, such as number of threads spawn, number of connection available in the pool etc. To get the detailed information see the Red Handbook provided by WebSphere.