Tuesday, October 5, 2010

Loading MySQL Driver in WebLogic 10.3.



I got in an awkward situation when I discovered that after putting the jar file (mysql-connector-java-5.1.5-bin) in the project classpath , my application was able to connect to the database but when I tried to deploy it in WebLogic 10.3 got exceptions . They are as follows-

• weblogic.common.resourcepool.
ResourceSystemException

• weblogic .jdbc.module.JDBCModule.
prepare


I found it difficult as I was working around it for 2 days just biting around the bush . At last i found the way to resolve it which I will be posting now. Figure below describes the stack trace of exceptions.






Prerequisites:

mysql-connector-java-5.1.5-bin.jar (jar file)
Jdeveloper 11g
WebLogic 10.3
MySQL Server 5.0


Steps that needs to followed :-

1. Copy the MySQL jar file specified above and put it inside the integrated WebLogic server i.e wlserver_10.3\server\lib as shown in the figure below.








2. Rename the file to weblogic_sp.jar because it is already present as a default which programmers can make use of it. That’s it , just need to restart your application server after this and you can deploy your application. This holds good for other database like Derby etc.

3. If you are not using the default jar file then paste the jar file as it is in the above specified location . Then add a weblogic classpath setting in the file commEnv.cmd present in the wlserver_10.3\common\bin. The changes are specified in the code snippet below.


Code Snippet:



@rem set up WebLogic Server's class path and config tools classpath
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;
%WL_HOME%\server\lib\weblogic_sp.jar;
%WL_HOME%\server\lib\weblogic.jar;
%WL_HOME%\server\lib\mysql-connector-java-5.1.5-bin.jar;




Creating a JNDI Name for MySQL :

My application will require the JNDI name for connecting to the database of MySQL. Fulfilling the same I need to create a JDBC Data Source. I have jotted down the steps for doing that too. They are stated as under.


Steps:

1. Goto the WebLogic console screen i.e http://localhost:7101/console and login with your userid and password.





2. Choose the Data Sources under JDBC as shown in the picture below.







3. Supply the connection name and JNDI name along with database type as shown under.







4. Select the driver you wish to use which is com.mysql.jdbc.Driver in my case.








5. Click Next with the default selection.






6. Provide the necessary information that is required for establishing connection to the MySQL. Below is the pictorial representation.






7. Click on the Test Configuration for testing the connection.







8. At the end success message is displayed , if the connection test is successful.






9. As indicated in the below picture a connection named MySQLConn and JNDI name MySQLConnDS is created in the Application Server which we can use it in the application.







10. Creating Database connections from the application end with the values shown below.






11. Then tried to deploy in the application server and the result I got was worth watching after all the troublesome i.e SUCCESS.







Right now there was some light thrown by one of my colleague (Pino) for another possible way or work around which could be an easiest way to deal with Jar complexities. So I am overburdened as I need to figure that out too.

Have a Good Day !!!

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Ayushman

    Thanks a lot .
    that works...

    ReplyDelete
  3. Thank youuuu bro, i was trying to work around it for 1 complete day !

    ReplyDelete
  4. Thank you very much, you saved my day, it took about 2 hours till now,

    thank you again

    ReplyDelete