Monthly Archive: December 2013

Configuring Datasource on Weblogic Server

Precondition: We will create a Data Source using PostgresSQL. In order to test it you will have to install Postgres  and keep and instance running on port-5460. We also need to keep the Postgres-driver in the domain/lib folder.

Steps to Create a Data Source:

Step 1: Expand Services link Domain Structure, the Data Sources link will be displayed as given below:

Step1

 

Step 2: Click on the Data Sources link. the Summary for JDBC Data Sources page will be displayed. Click on new button, it will list down the different options. Select Generic Data Source from the dropdown menu as given below:

Step2

 

 

 

Step 3:  Create a new JDBC Data Source page is displayed. Enter the following details:

Name: DS1
JNDI Name: DS1
Database Type: PostgresSQL

Step3

 

 

 

 

Click on next button.

Step 4:   Select Database Driver: Other.

Step4

Click on next button.

Step 5:  The following page is displayed:

Step5

Click on next button.

Step 6: Enter the following details:

Database Name: postgres
Host Name: localhost
port: 5460
Database User Name: postgres
Password: saky
Confirm Password: saky

Step6

Click on next button.

Step 7:  Enter the following details:

Driver Class Name: org.postgresql.Driver
URL: jdbc:postgresql://postgres:5460/postgres
Database User Name: postgres
Password: saky
Confirm Password:saky
Properties: user=postgres
Step7

Click on next button.

Step 8:  Click on Test Configuration button. The following message should be displayed:

“Connection test succeeded.”

Click on next button.

Step 9: Select AdminServer as given below:

Step8

 

Step 10:  The Data source DS1 created appears in the Summary of JDBC Data Sources page as given below:

Step9

Step 11: Click on DS1 on the the Summary of JDBC Data Sources page. Click on Connection Pool link.

Step12

Expand Advanced section and check the field Test Connections On Reserve as given below:

Step13

 

Click on Save button.

Step 12: To test the connection:

Click on  Monitoring -> Testing

Step10

Step 13: Select the AdminServer .

Step11

Step 14: Click on Test data source. The following message is displayed:

“Test of DS1 on server AdminServer was successful.”

Note: You can also test by deploying a basic application on Weblogic Server and using the datasource created by the above steps.

 

WLST Script to rotate server log file

You can use the script below to rotate server log files using WLST



connect('weblogic','weblogic123','t3://localhost:7001')
serverRuntime()
cd('LogRuntime/AdminServer')
cmo.forceLogRotation()
print 'Log file rotated'

WLST Script to start and stop Datasource

 

Script to start Datasource

connect('weblogic','weblogic123','t3://localhost:7001')
domainRuntime()
cd('ServerRuntimes/AdminServer/JDBCServiceRuntime/AdminServer/JDBCDataSourceRuntimeMBeans/PegaRULES')
objArray = jarray.array([], java.lang.Object)
strArray = jarray.array([], java.lang.String)
invoke('start', objArray, strArray)
exit()

Script to stop Datasource

connect('weblogic','weblogic123','t3://localhost:7001')
domainRuntime()
cd('ServerRuntimes/AdminServer/JDBCServiceRuntime/AdminServer/JDBCDataSourceRuntimeMBeans/PegaRULES')
objArray = jarray.array([], java.lang.Object)
strArray = jarray.array([], java.lang.String)
invoke('shutdown', objArray, strArray)
exit()

steps to create datasource in Jboss eap

You need to create oracle\jdbc\main folder under modules and keep the module.xml and ojdbc6.jar there

one

 

module.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="oracle.jdbc">
    <resources>
        <resource-root path="ojdbc6.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>


In standlone.xml / domain.xml you need to add the datasource and driver entry

<datasource jndi-name="java:jboss/datasources/OracleDS" pool-name="OracleDS" enabled="true" use-java-context="true">
	<connection-url>jdbc:oracle:thin:@localhost:1521:orcl</connection-url>
	<driver>OracleJDBCDriver</driver>
	<security>
		<user-name>SYSTEM</user-name>
		<password>Passw0rd</password>
	</security>
</datasource>
<drivers>
	<driver name="OracleJDBCDriver" module="oracle.jdbc" />
</drivers>

 

You should be able to see your datasource from the console.

 

1

Deploying Tuxedo 12c JCA Adapter rar file in Weblogic server 11g

Step 1: Download JCA adapter rar file from oracle site.

Step2:  Unzip the rar file into a folder.

 

1

 

Step3:  Under extracted folder, we have com.oracle.tuxedo.TuxedoAdapter rar fie is there. Copy that one and place it outside of extracted folder and remove extracted and zip folder.

2

 

Step 4 : Extract the contents in to com.oracle.tuxedo.TuxedoAdapter rar into tuxedoadapter.rar folder and remove the com.oracle.tuxedo.TuxedoAdapter rar file.

 

3

tuxedoadapter.rar folder contains below files (screenshot)

step4image

 

 

Step 5:

Go to META-INF folder, we can find  server.ra.xml and weblogic-ra.xml , remove remaining and change server.ra.xml to ra.xml . Open ra.xml , give dmconfig.xml path to connect /access external system services.

 

5

 

6

Step 6:

Open weblogic-ra.xml and change according to your need. No need to create JNDI Name in Weblogic server.

 

weblogic-ra.xml

Step 7:

Copy the jars in to * .ear/APP-INF/lib folder of your application. These jars are necessary/accessible, when jca rar is deploying in weblogic server.

 

8

 

9

 

Step 8:  Override com.bea.core.jatmi_2.0.1.0.jar of Weblogic server.
Note : For Weblogic Server, this jar file must be exported using CLASSPATH to replace the one included with WebLogic Server installation. This environmental variable must be set before starting WebLogic Server.
set in classpath above com.bea.core.jatmi_2.0.1.0.jar in Weblogic server at

C:\Oracle\Middleware\user_projects\domains\billingagent_domain\bin\startWeblogic.cmd or .sh
set SAVE_CLASSPATH=D:/tuxedoclient/billingagent.ear/APP-INF/lib/com.bea.core.jatmi_2.0.1.0.jar;%CLASSPATH%
Next copy tuxedoadapter.rar file into your ear file and it is ready to deploy into Weblogic server.