Sunday, April 25, 2010

Deploying MySQL based ADF application to Weblogic Server

Hi,
I will continue my last post here and we will simply deploy that application which is based on MySQL  database to weblogic server. You can follow the same steps to deploy any ADF application like ADF application based on Oracle database (for Oracle based applications we dont have to provide any external Jar files to Weblogic server)

This post you might feel lengthy but it hardly takes 10-15 minutes to complete all steps


Pre-requisites:
- Weblogic server Domain is created (in my case name it is "adf_test" on local host and port 7001)
Check the Oracle fusion developer guide to know how to create domain
- Connection to Weblogic server named as TestingServer in the resource palette 
- My SQL Connect/J Driver is in Domain/lib folder for example
C:\oracle\Middleware\user_projects\domains\adf_test\lib folder

Steps summary:
a) Creating database source for MySQL database in Weblogic server.
b) Setting Application properties for deployment
c) Creating deployment profiles for ADF application.
d) Deploying the application
e) Running the application


a) Creating database source for MySQL database in Weblogic server:

- Start the weblogic server domain and enter the following address in your browser.
http://localhost:7001/console

- Enter user and password (the one you provided while creating domain) default user is "weblogic" and password is "weblogic1"

- Click the Database source under the JDBC heading if activate changes button is appearing click it before
 
- Click New Button on Data source Page
- Enter information as shown in the slide and press Next
Note that the JNDI name is important we will use the same name for our application.
- Leave the defaults press Next
- Enter Database information and Press Next
- Test the Configuration make sure MySQL database is up and running Press Next if Test is successful.
- Click on AdminServer and Click Finish.
- New Data source has been added in JDBC sources as shown in the slide.



b) Setting Application properties for deployment:

- Now we will setup our application to use that Data source we have created in our Weblogic server
- Right click the Application Module in Model project choose Configuration
- Press Edit button and set the JDBC Data source as shown in the slide and Click OK


c) Creating deployment profile for ADF application:
- We will setup the Project properties to give a proper user friendly name to our application and project
- Double ViewController Project goto Project Properties. Choose  JavaEE Application set the name of application as "MySqlDemo"
Note: This name will be use to run our application.

 - Goto Application Properties Click

 - Goto Deployment Press Edit and set the Application name as "MySqlApp"
Note: This name will appear in our deployment section of WLS (Weblogic server)
 - Make sure the Platform is selected as our TargetServer (adf_test domain) OK all buttons.

 d) Deploying the application:

- Click on Application Icon and choose Deploy and MySQL_Application1... (the default name of profile)


- Choose Deploy to Application Server and click Next


- Choose TestingServer and Click Next (if required click Green button to create new connection)

- Click Finish

- Check the deployment log make sure everything goes well

e) Running the application:

- Goto weblogic console click the deployments link

 - As we can see the Application "MySqlApp" in our deployments and Status is OK and ACTIVE

-  Enter in the browser the following address to test the application
Syntax: http://servername:port/context-root/faces/pagename
e.g
http://localhost:7001/MySqlDemo/faces/demo


More Reading at Deploying Fusion Web Applications

Download the workspace

Have a nice day,
Baig

9 comments:

  1. nice blog cool posts. Good great work.

    Rudraksh Pathak

    www.baseoftech.blogspot.com

    checkout my blog and please leave your comments.
    THANKS

    ReplyDelete
  2. Hi,

    I Want to connect to my Demo XE DataBase.

    How I can achieve the same?

    Thanks & Regards,
    Viraj Save
    Sr. Systems Analyst.

    ReplyDelete
  3. Hi Raj,

    These steps are not for Oracle database

    Check the following Link http://baigsorcl.blogspot.com/2010/03/moving-to-jdeveloper11g-your-first-adf.html

    ReplyDelete
  4. Hey,

    I am trying to do the same configuration but for Sybase.

    So I am using jconn3.jar. It is working fine in Admin Server, but when I try to run in another server that I configured it is giving the following exception :

    An error occurred during activation of changes, please see the log for details.
    weblogic.application.ModuleException:
    Cannot load driver class: com.sybase.jdbc3.jdbc.SybDriver

    I added jconn3.jar in classpath of the server. Is there another way to resolve this issue??

    ReplyDelete
    Replies
    1. Hi,

      Probably missing some libs on managed server which are required for JDBC drivers. Check oracle docs for Sybase JDBC configuration.

      Check this link as well http://docs.oracle.com/cd/E15051_01/wls/docs103/jdbc_drivers/usedriver.html

      Zeeshan

      Delete
  5. Hi Zee,

    Excellent Post. I had a problem, where in an existing Project with existing Oracle Datasource, I need to create MY SQL datasource.

    I followed below step but facing issue. Can you please suggest me how to resolve this.

    1. Run the existing project. Open weblogic console and create new MY SQL datasource with. Datasource connection is Successful and got created.

    2. Created a new Model Project, RVO, AM and provided this datasource in AM Configuration.

    3. Now I created a test.jspx page and invoked AMImpl method. But on page load, I am getting below exception.

    java.lang.NoClassDefFoundError: com/mysql/jdbc/MySQLConnection

    Not sure where I am missing. I tried adding classpath in WLS (C:\Oracle\Middleware\wlserver_10.3\common\bin\commEnv) but still facing same issue.

    Any pointer how to resolve this.

    Thanks
    Ankur

    ReplyDelete
    Replies
    1. Hi,

      The very first step is to put your driver in Domain's Lib folder. Make sure you have done this..

      Pre-requisites:
      - Weblogic server Domain is created (in my case name it is "adf_test" on local host and port 7001)
      Check the Oracle fusion developer guide to know how to create domain
      - Connection to Weblogic server named as TestingServer in the resource palette
      - My SQL Connect/J Driver is in Domain/lib folder for example
      C:\oracle\Middleware\user_projects\domains\adf_test\lib folder

      Hope it helps,
      Zee

      Delete
  6. Hi Zee,

    Thanks for reply, I already have driver jar in Domain lib folder.
    C:\Users\anpradhan\AppData\Roaming\JDeveloper\system11.1.1.6.38.61.92\DefaultDomain\lib

    But still, I am getting same exception, when I am running jspx page.

    Strange thing is, when I created normal MYSQL connection from Jdev as given in your Post 1, it worked fine. But when now I moved to creating Data Source and change my Model Project configuration to point to this datasource, Running jspx page is giving exception.

    Not sure what is going wrong? Please suggest.

    ReplyDelete
    Replies
    1. Hi,

      Try to create separate domain instead of using integrated domain.

      Delete