Friday, January 20, 2017

How To Improve WebLogic Server Start Up & Login Performance?

==> You may be noticed that the WebLogic Server start up performance is considerably very poor due to linux server Entropy issue

==> There are so many situation like WebLogic Console hanging after entering credentials an clicking on Login button & Slow Server Start up etc.

==> Entropy is the measure of the random numbers available from /dev/urandom, and if you run out,you can’t make SSL connections.


Step 1) Check the linux server Entropy using below command

         
             cat /proc/sys/kernel/random/entropy_avail

             If the o/p is between 100 to 200 in that case problem exist

             Example:



Step 2) set the JAVA_OPTION "-Djava.security.egd=file:/dev/./urandom" in setDomainEnv.sh file





Step 3) Restart the AdminServer 


cd /oracle/Middleware/user_projects/domains/base_domain/bin
./stopWebLogic.sh
nohup ./startWebLogic.sh &

Completed............

Wednesday, January 18, 2017

SQLAuthenticator Provider Configuration Demo With Weblogic

By default Users & Groups information's are managed using weblogic DefaultAuthenticator ie. Embedded LDAP. To manage application specific Users and Groups in efficient manner these information's will be stored in external LDAP like SQLAuthenticator, Active Directory, OID etc.


Step 1) Create Data Source sqlds which will used for while configuring SQLAuthenticator


Login to wls console ==> Click on Services ==> Click on Data Sources ==> Click on New ==>Click on Generic Data sources ==> Create sqlds datasource



Step 2) Create the following Tables "USERS", "GROUPS" and "GROUPMEMBERS" by running below sql queries



CREATE TABLE USERS (
    U_NAME VARCHAR(200) NOT NULL,
    U_PASSWORD VARCHAR(50) NOT NULL,
    U_DESCRIPTION VARCHAR(1000));
ALTER TABLE USERS
   ADD CONSTRAINT PK_USERS
   PRIMARY KEY (U_NAME);
   
CREATE TABLE GROUPS (
    G_NAME VARCHAR(200) NOT NULL,
    G_DESCRIPTION VARCHAR(1000) NULL);
ALTER TABLE GROUPS
   ADD CONSTRAINT PK_GROUPS
   PRIMARY KEY (G_NAME);
   
CREATE TABLE GROUPMEMBERS (
    G_NAME VARCHAR(200) NOT NULL,
    G_MEMBER VARCHAR(200) NOT NULL);
ALTER TABLE GROUPMEMBERS
   ADD CONSTRAINT PK_GROUPMEMS
   PRIMARY KEY (
      G_NAME,
      G_MEMBER
   );
   
ALTER TABLE GROUPMEMBERS
   ADD CONSTRAINT FK1_GROUPMEMBERS
   FOREIGN KEY ( G_NAME )
   REFERENCES GROUPS (G_NAME)
   ON DELETE CASCADE;

Step 3) Insert the following records in the Above Tables.


insert into USERS  values('jagan','welcome1','username is jagan stored in sqlauthenticator');

insert into GROUPS values('Administrators','This is an Administrators Group');

insert into GROUPMEMBERS values('Administrators','jagan');


Step 4) Create SQLAuthenticator authentication provider


Login to wls console ==> click on "Security Realms" ==> Click on "myrealm" ==> Click on Providers ==> Click on New ==> Enter Name "TestSQLAuthenticator" ==> Select Type SQLAuthenticator ==> Click on OK


Step 5) Configure SQLAuthenticator  provider


Click on newly created SQLAuthenticator ==> Click Configuration ==> Click on Provider Specific ==> Check the check box "Plaintext Passwords Enabled" ==> Enter data source name sqlds ==> Click on Save



Step 6) Setting Control Flag for SQLAuthenticator 


Click on newly created SQLAuthenticator ==> Click Configuration  ==> Click on Common ==> Control Flag OPTIONAL ==> Save



Step 7) Setting Control Flag for DefaultAuthenticator 


Go to Providers table ==> Click on DefaultAuthenticator ==> Click Configuration  ==> Click on Common ==> Control Flag OPTIONAL ==> Save




Step 8) Reorder providers


Go back to providers table ==> Click on Reorder ==> Select TestSQLAuthenticator ==> By using up arrows keep this provider at the Top ==> Click on OK





Step 9) Restart AdminServer


cd /oracle/Middleware/user_projects/domains/base_domain/bin
 ./stopWebLogic.sh

nohup ./startWebLogic.sh &

Step 10) Now login to Weblogic console using SQLAuthenticator user  jagan







How To Troubleshoot JDBC Connectivity issue Between Weblogic and Database Using dbping Utility

dbping is very useful utility for troubleshooting weblogic and database connectivity issue in comparison with telnet because telnet utility does not determines whether the database is up and running it only determines whether the listener is listening or not.


Step 1) Login to the server in which weblogic domain is configured


Step 2) Navigate to the $DOMAIN_HOME/bin directory


cd /oracle/Middleware/user_projects/domains/base_domain/bin

Step 3) Source the environment variable by using setDomainEnv.sh


. ./setDomainEnv.sh



Step 4) Run below command for checking database connectivity


Syntax:
 java utils.dbping DBMS [-d dynamicSections] user password DB

Example:

 java utils.dbping ORACLE_THIN dbtestuser welcomepasswd test1.abs.com:1521/xe




For More Details Please Visit : https://docs.oracle.com/cd/E13222_01/wls/docs81/admin_ref/utils11.html

How To Install Oracle XE Database 11g Release 2 on Cent OS Linux 7

Step 1) Download the Oracle Database Express Edition 11g Release 2


http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html

Step 2) Copy the file oracle-xe-11.2.0-1.0.x86_64.rpm.zip to the remote machine using WinSCP




Step 3) Unzip the file  oracle-xe-11.2.0-1.0.x86_64.rpm.zip 




Step 4) Navigate to Disk1 directory




Step 5) Execute below command with root user for installation


     rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm


Step 6) Execute '/etc/init.d/oracle-xe configure' as the root user to configure the database





Step 7) Login to oracle user and Export ORACLE_HOME & ORACLE_SID


[oracle@test1 ~]$ cat /etc/oratab
XE:/u01/app/oracle/product/11.2.0/xe:N
[oracle@test1 ~]$
[oracle@test1 ~]$ ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
[oracle@test1 ~]$ export ORACLE_HOME
[oracle@test1 ~]$ export PATH=$ORACLE_HOME/bin:PATH
[oracle@test1 ~]$ export ORACLE_SID=XE
[oracle@test1 ~]$


Step 8) Check Listener Status


lsnrctl status



Conclusion: Listener is up and running
Note: If not running in that case run the command 'lsnrctl start'


Step 9) Check the database status




Conclusion: Database is up and running & it can accept read write requests
Note: If not running execute sql command 'SQL> startup'

Wednesday, January 11, 2017

JMS Example for Using WebLogic Queue

Summary
=======

Step 1) Start the AdminServer and NodeManager
Step 2) Login to weblogic admin console and start the managed server JMSTestMS
Step 3) Create persistence store
Step 4) Create a JMS Server
Step 5) Configuring JMS Module
Step 6) Creating Connection Factory
Step 7) Creating JMS Queue
Step 8) Create java file QueueSend.java
Step 9) Create java file QueueReceive.java
Step 10) Compile both files QueueSend.java and QueueReceive.java
Step 11) Send messages using QueueSend.java
Step 12) Receive messages using QueueReceive.java

Step 1) Start the AdminServer and NodeManager using below commands


cd /oracle/Middleware/user_projects/domains/prod_domain/bin
nohup ./startWebLogic.sh &
nohup ./startNodeManager.sh &



Step 2) Login to weblogic admin console and start the managed server JMSTestMS





Step 3) Create persistence store


Click on Services ?Click on Persistent Stores ?Click on New ? Select “Crete File Store”

Click on Services Ã  Click on Persistent Stores Ã  Click on New Ã  Select “Crete File Store”



Name*: JMSFileStore
Target*:JMSTestMS
Directory: /oracle/Middleware/user_projects/domains/prod_domain



Click on OK



Step 4) Create a JMS Server


Click on Services Ã  Click on Messaging  Ã Click on JMS server




 Click on New and Enter below details and click on Next
*Name:JMSServer
 Persistent Store: select JMSFileStore




Select targets:JMSTestMS  Ã  Click on Finish





Step 5) Configuring JMS Module 


Click on Services Ã  Click on Messaging Ã  Click on JMS Modules



Click on New and Enter below details Ã  Click on Next
*Name: JMSSystemModule



Select Targets:JMSTestMS Ã   Click on Next



Click on Finish





Step 6) Creating Connection Factory


Click on Services Ã   Click on Messaging Ã   Click on JMS Modules Ã   Click on JMSSystemModule



Click on New



Select Connection Factory Ã   Click on Next




Enter Below details Ã   Click on Next
*Name: JMSConnectionFactory
 JNDI: QJMSConnectionFactory



*Targets: JMSTestMS Ã   Click on Finish







Step 7) Creating JMS Queue


Click on Services Ã   Click on Messaging Ã   Click on JMS Modules Ã   Click on JMSSystemModule


Click on New



Select Queue Ã   Click on Next



Enter below details and click on Next
Name: JMSQueue
JNDI Name: JMSQueue



Click on “Create New Subdeployment”


Enter Subdeployment name: JMSSubdeployment Ã   Click on OK



Select Target : JMSServer Ã   Click on Finish



Click on Finish

Step 8) Create java file QueueSend.java with following program


cd /oracle/Middleware/wlserver/server/bin
vi QueueSend.java

import java.io.*;
import java.util.Hashtable;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class QueueSend
{
public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
public final static String JMS_FACTORY="QJMSConnectionFactory";
public final static String QUEUE="JMSQueue";

private QueueConnectionFactory qconFactory;
private QueueConnection qcon;
private QueueSession qsession;
private QueueSender qsender;
private Queue queue;
private TextMessage msg;

public void init(Context ctx, String queueName)
throws NamingException, JMSException
{
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
qcon = qconFactory.createQueueConnection();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue = (Queue) ctx.lookup(queueName);
qsender = qsession.createSender(queue);
msg = qsession.createTextMessage();
qcon.start();
}

public void send(String message) throws JMSException {
msg.setText(message);
qsender.send(msg);
}

public void close() throws JMSException {
qsender.close();
qsession.close();
qcon.close();
}

public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.out.println("Usage: java QueueSend WebLogicURL");
return;
}
InitialContext ic = getInitialContext(args[0]);
QueueSend qs = new QueueSend();
qs.init(ic, QUEUE);
readAndSend(qs);
qs.close();
}

private static void readAndSend(QueueSend qs) throws IOException, JMSException
{
String line="Test Message Body with counter = ";
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
boolean readFlag=true;
System.out.println("\n\tStart Sending Messages (Enter QUIT to Stop):\n");
while(readFlag)
{
System.out.print("<Msg_Sender> ");
String msg=br.readLine();
if(msg.equals("QUIT") || msg.equals("quit"))
{
qs.send(msg);
System.exit(0);
}
qs.send(msg);
System.out.println();
}
br.close();
}

private static InitialContext getInitialContext(String url) throws NamingException
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}
}

Step 9) Create java file QueueReceive.java with following program


cd /oracle/Middleware/wlserver/server/bin
vi QueueReceive.java


import java.util.Hashtable;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class QueueReceive implements MessageListener
{
public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory";
public final static String JMS_FACTORY="QJMSConnectionFactory";
public final static String QUEUE="JMSQueue";
private QueueConnectionFactory qconFactory;
private QueueConnection qcon;
private QueueSession qsession;
private QueueReceiver qreceiver;
private Queue queue;
private boolean quit = false;

public void onMessage(Message msg)
{
try {
String msgText;
if (msg instanceof TextMessage)
{
msgText = ((TextMessage)msg).getText();
}
else
{
msgText = msg.toString();
}
System.out.println("\n\t<Msg_Receiver> "+ msgText );
if (msgText.equalsIgnoreCase("quit"))
{
synchronized(this)
{
quit = true;
this.notifyAll(); // Notify main thread to quit
}
}
}
catch (JMSException jmse)
{
jmse.printStackTrace();
}
}
public void init(Context ctx, String queueName) throws NamingException, JMSException
{
qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY);
qcon = qconFactory.createQueueConnection();
qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queue = (Queue) ctx.lookup(queueName);
qreceiver = qsession.createReceiver(queue);
qreceiver.setMessageListener(this);
qcon.start();
}

public void close()throws JMSException
{
qreceiver.close();
qsession.close();
qcon.close();
}

public static void main(String[] args) throws Exception
{
if (args.length != 1)
{
System.out.println("Usage: java QueueReceive WebLogicURL");
return;
}
InitialContext ic = getInitialContext(args[0]);
QueueReceive qr = new QueueReceive();
qr.init(ic, QUEUE);
System.out.println("JMS Ready To Receive Messages (To quit, send a \"quit\" message from QueueSender.class).");
// Wait until a "quit" message has been received.
synchronized(qr)
{
while (! qr.quit)
{
try
{
qr.wait();
}
catch (InterruptedException ie)
{}
}
}
qr.close();
}

private static InitialContext getInitialContext(String url) throws NamingException
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY);
env.put(Context.PROVIDER_URL, url);
return new InitialContext(env);
}

}

Step 10) Compile both files QueueSend.java and QueueReceive.java


cd /oracle/Middleware/wlserver/server/bin
. ./setWLSEnv.sh
javac  QueueSend.java
javac QueueReceive.java



Step 11) Use the below URL for sending messages and enter any message for sending

[oracle@jagannathm bin]$cd /oracle/Middleware/wlserver/server/bin
[oracle@jagannathm bin]$. ./setWLSEnv.sh
[oracle@jagannathm bin]$ java QueueSend t3://192.168.145.128:8003

        Start Sending Messages (Enter QUIT to Stop):


<Msg_Sender> Hello World How Are you?



Step 12) Open another Putty session and enter below URL for receiving messages


[oracle@jagannathm bin]$cd /oracle/Middleware/wlserver/server/bin
[oracle@jagannathm bin]$. ./setWLSEnv.sh
[oracle@jagannathm bin]$java QueueReceive t3://192.168.145.128:8003