Monday, November 12, 2012

Java databse connectivity in weblogic

What is JDBC ?
JDBC is an Java API for accessing Database in a uniform way...

what it providing ?
It's a platform Independent and location transperency its supports 2-tier and 3-tier also

JDBC Archtecture



Look once the Archetecture...

JDBC Architecture
The JDBC Architecture mainly consists of two layers:
First is JDBC API, which provides the application-to-JDBC Manager connection.
Second is JDBC Driver API, which supports the JDBC Manager-to-Driver Connection. This has to provide by the vendor of database, you must have notice that one external jar file has to be there in class path for forth type of driver.
The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct driver is used to access each data source. The driver manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases.
The top level layer in this model is the Java application. Java applications are portable. You can run a Java application without modification on any system that has a Java runtime environment installed. A Java application that uses JDBC can talk to many databases with some modifications. Like ODBC, JDBC provides a consistent way to connect to a database, execute commands, and retrieve the results. Also like ODBC, JDBC does not enforce a common command language. You can use Oracle-specific syntax when connected to an Oracle server and My SQL specific syntax when connected to a My SQL database.
The JDBC DriverManager
The JDBC DriverManager class is responsible for locating a JDBC driver needed by the application. When a client application requests a database connection, the request is expressed in the form of a URL and username and password if required.
The JDBC Driver
When driver is loaded into a JVM, it registers itself with the JDBC DriverManager. When a java application requests for a database connection, the DriverManager asks each Driver whether it can connect to the database specified in the given URL with provide username and password if required. As soon as it finds an appropriate Driver, the driver attempts to make a connection to the database. If the driver fails to get the connection, the Driver will throw a SQLException to the java application. If the driver gets the connection successfully, the Driver creates a Connection object and returns it to the java application.
The javax.sql.DataSource introduce in JDBC 2.0 , which is another method for establishing database connections. The DataSource is a named collection of connection properties that can be used to load a Driver and create a Connection
The JDBC Compliant Database
The lower bottom layer of the JDBC model is the database


You need a JDBC driver to connect to a database. There are four types of JDBC drivers.

Type 1 JDBC Driver(JDBC-ODBC Bridge):

The Type 1 driver translates all JDBC calls into ODBC calls and sends them to the ODBC driver. ODBC is a generic API. The JDBC-ODBC Bridge driver is recommended only for experimental use or when no other alternative is available.This driver is readily available as it comes with java version.Need to configure only.It is described in the end of this post.

Type 2 JDBC Driver(Native API driver):

The distinctive characteristic of type 2 jdbc drivers are that Type 2 drivers convert JDBC calls into database-specific calls i.e. this driver is specific to a particular database. Some distinctive characteristic of type 2 jdbc drivers are shown below. Example: Oracle will have oracle native api.Requires installation/configuration on client machines.

Type 3 JDBC Driver(All Java/Net-protocol driver):

Type 3 database requests are passed through the network to the middle-tier server. The middle-tier then translates the request to the database. If the middle-tier server can in turn use Type1, Type 2 or Type 4 drivers.

Type 4 JDBC Driver(Native-protocol/all-Java driver):


The Type 4 uses java networking libraries to communicate directly with the database server.The major benefit of using a type 4 jdbc drivers are that they are completely written in Java to achieve platform independence and eliminate deployment administration issues. It is most suitable for the web.We don’t need to do anything special to install a type 4 pure java driver. Download and put the driver JAR file in classpath.Thats it.








Friday, November 9, 2012

ANT Deployment


Hi Guys

This post is information about the Ant Deployment

ant  - Another Neat Tool
ant – is  a build and deploy tool that is used to create and deploy archive files.
Welogic internally provides an ant task “wldeploy” that can be used in ant scripts to automate deployment.
This wldeploy internally calls weblogic.Deployer
ant deployment depends on the configuration file called build.xml
the structure of build.xml file

Project  -à

            Properties  -- > Each property has a name & a value for that property.

            These properties can be defined as per the requirements and values need to assigned.

            taskdef  à the ant task “wldeploy” classfile will be defined in the build.xml file

            targets à targets are blocks of code that take certain action. For Eg. Deploy

Build.xml file sample:

<project name="webservices-hello_world" default="deploy">
<property name="wls.username" value="wlsadmin" />
<property name="wls.password" value="wlsadmin" />
<property name="wls.hostname" value="192.168.128.9" />
<property name="wls.port" value="20001" />
<property name="admin.server.name" value="Admin" />
<property name="deploy.target" value="softCluster1" />

<!-- Here you can specify Either ClusterName, IndividualServerName Like "ManagedOne" or comma Seperated List of Managed/AdminServer -->
<property name="deploy.name" value="jsf" />
<property name="deploy.source" value="deploy/jsf-1.2.war" />


<!-- Setting TaskDefinition -->
<taskdef name="wldeploy" classname="weblogic.ant.taskdefs.management.WLDeploy">
<classpath>
<pathelement location="/home/durgasoft/bea10.3.0/wlserver_10.0/server/lib/weblogic.jar"/>
</classpath>
</taskdef>


<!-- Deploying Applications  -->
<target name="deploy">
<wldeploy action="deploy"
          name="${deploy.name}"
          source="${deploy.source}"
          user="${wls.username}"
          nostage="true"
          password="${wls.password}"
          verbose="true"
              library="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>



<!-- Redeploying Applications  -->
<target name="redeploy">
<wldeploy action="redeploy"
          name="${deploy.name}"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
</target>


<!-- Uneploying Applications  -->
<target name="undeploy">
<wldeploy action="undeploy"
          name="${deploy.name}"
          failonerror="false"
          user="${wls.username}"
          password="${wls.password}"
          verbose="true"
          adminurl="t3://${wls.hostname}:${wls.port}" targets="${deploy.target}" />
            </target>
            </project>
After the build file is configured properly, the individual targets can be invoked.

Invoking the ant targets:

1)      ant  ( with out any arguments , will invoke the default target on the first line of build.xml)
2)      ant deploy  -- will invoke the “deploy” task
3)      ant undeploy  -- will invoke the “undeploy” task
4)      ant redeploy   -- will invoke the “redeploy “ task



if you have to invoke the ant deploy with a different configuration file , other than build.xml , then

            ant –f <config-file-name> b.xml

Deploy using weblogic.Deployer utility

Hi Guys

This post gives the information about  deploy an  application using weblogic.Deployer utility


Deployment Operations

The deployment tools provide support for performing these common deployment operations:

  • Deploy—making deployment source files available to target servers and loading classes into classloaders so that applications are available to clients.
  • Distribute—for stage mode deployments, only copy the deployment files to the target servers (but do not start the deployment).
  • Redeploy—updating an deployment unit or part of a deployment unit (for example, an EAR, a module within an EAR, or a static file in a Web Application) that is currently deployed and available to clients. When redeploying an entire application, all of the application's modules must redeploy successfully or the entire application is stopped.
Note: An application becomes unavailable to clients during redeployment. WebLogic Server doesn't guarantee the operation of the application and deployment task if there is an access from the client at this time. For this reason, redeployment is not recommended for use in a production environment.
  • Stop—unloading an application's classes and making an application unavailable to clients. Stopping still leaves the deployment files and deployment name available to target servers for subsequent redeployment or starting.
  • Start—reloading an application's classes into classloaders and making the application available to clients. Starting requires that the deployment files be available on target servers as a result of an earlier deployment.
  • Undeploy—stopping a deployment unit and then removing its deployment files and deployment name from target servers
  • various modes of deployment : 
    stage    : admin copies the files to managed servers
    no-stage   : manged servers copy their own files
    external-stage  : weblogic Administrator has to manually copy the files to the staging                      area 


    Syntax of Deploy

    Java weblogic.Deployer -adminurl <AdminserverIP:port>
                                   - username <admin username>
                                   -password <admin password>
                                   -Deploy/undeploy/redeploy/listapps/stop/start
                                   -source <location of Deployble file>
                                   -library/application
                                   -name <name of the application>
                                   -stage/no-stage/External-stage
                                   -target <standlone server or cluster>


    Example:

    Deploy

    java weblogic.Deployer -adminurl 192.168.128.7:7001 -username weblogicsh -password weblogicsh -deploy -source /home/subha/desktop/Deploy-files/jsf-1.2.war -stage -targets mngserver_1,mngserver_2,mngserver_3,mngserver4  -library

    Undeploy

     java weblogic.Deployer -adminurl 192.168.128.7:7001 -username weblogic -password weblogic -undeploy  jsf-1.2.war -targets mngserver_1,mngserver_2,mngserver_3,mngserver4  -library

    ........like that
                                   

How to deploy application using weblogic Admin console

Steps to Deploy Application using Administration Console


In this post I’ll cover steps to deploy application using Administration Console

Download Sample Application on Internet or otherwise use sample apllication like medrec and deploy on WebLogic Server.

1. Start Administration Server...

2. access the Admin console using Admin IP:port/console
            http://127.0.0.1:7001/console

3. Login using User (with admin or deployer role)  weblogic in my case

4. First step is to acquire Lock as shown in screen


5) Click on deployments 

6) Click on Install button

7) Select Application (war, jar, ear) File . You should get this application (war, ear, jar) file from development team.

Select Install this deployment as Application and click Next


9) Activate Canges by clicking on button on left as shown in screen




10) Start Application by clicking on Start Button






How many ways to deploy a java application in weblogic server

Hi Guys 


To day post very usefull to the Admins

Deploying the application to Weblogic Application  Server


Things good to know before deploying application on Oracle WLS  

i) User with Admin or Deployer role can deploy application
ii) Weblogic supports following type of deployment unit
a) EAR file (Enterprise Archive) -----> java -cvf myapp.ear myappp( this is the commad to create a EAR file)
b) WAR file (Web Archive) ----->java -cvf myapp.war myappp( this is the commad to create a WAR file)
c) JAR files, EJB (Enterprise Java Beans)
d) RAR (Resource Adapter/Connector )
e) Web Services (WAR/JAR)
f) J2EE Library
g) CAR (Client Application Archive)

–  Web Archive configuration file is usually …../WEB-INF/web.xml
–  Enterprise Application (EAR) configuration file is usually …/META-INF/application.xml

iii) Application name can contain only following character (a-z, A-Z, 0-9, underscore, hyphen, . period/dot)
iv) Application name with only period/dot (like . or .. or …) is not valid name, it should contain at least one other character.
v) Application Name should be 215 character or less


Tools used to deploy/configure applications
1) weblogic.Deployer – command line interface
2) Administration Console – Web based interface
3) WLST(WebLogic Scripting Tool) – command line tool to automate deployment configuration and operation
4) Tool for developers (wldeploy, weblogic.PlanGenerator, API, autodeploy)

5)ANT, MAVEN....

These are the Ways to Deploy an Application toweblogic server....k

In Next post How to Deploy using Admin console and using weblogic utilities....

K Njoy 

GUYS








Thursday, November 8, 2012

Cluster Configuration in weblogic



Setting Up, Configuring, and Using an Oracle WebLogic Server Cluster


Learn to take advantage of multiple Oracle WebLogic Server instances grouped into a cluster to maximize scalability and availability.

The key characteristics of a successful online system today include high availability, reliability, and scalability. Put simply, your online system must be ready to process a user request quickly and at any time, even when the number of requests grows abruptly. Strictly speaking, a growing number of user requests is a good thing, because that makes it clear that your online business is booming and opening up new opportunities for you. The ability to act on opportunities is a key characteristic of many successful businesses today.
To meet the requirements for greater availability and scalability, more and more companies are moving toward clustered infrastructures for their online solutions. Oracle WebLogic Server supports clustering, allowing an Oracle WebLogic Server cluster to be composed of multiple Oracle WebLogic Server instances running on different servers at the same time, so that application deployed to the cluster can take advantage of the combined processing power of multiple servers, failover, and load balancing.
To end users and applications, multiple Oracle WebLogic Server instances grouped into a cluster appear as a single Oracle WebLogic Server instance. But beneath the surface, the cluster uses an infrastructure that enables interconnecting clustered Oracle WebLogic Server instances to make them work as a single unit. It's important to realize, though, that setting up and using that infrastructure involves some configuration work on the part of a cluster administrator.

Key Benefits of Clustering

The idea behind clustering is pretty simple: Multiple server instances are grouped to work together to achieve increased scalability and reliability. In particular, the benefits of an Oracle WebLogic Server cluster include the following:
·         High availability—You can deploy your applications on multiple server instances within an Oracle WebLogic Server cluster. In this case, if a server instance that is running your application fails, application processing will continue (transparently to the application users) on another instance.
·         Scalability—New server instances can be dynamically added to a cluster to match consumer demand, without interrupting application processing.
·         Improved performance—Another advantage to deploying on multiple server instances in a cluster is that it provides several alternatives for application processing. The load balancing mechanism that clustering enables can significantly improve performance of your clustered application due to the efficient distribution of jobs and communications across the resources within the cluster.
To provide the benefits above, an Oracle WebLogic Server cluster supports the following features:
·         Load balancing
·         Application failover
·         Migration of a server instance
To grasp how things work in an Oracle WebLogic Server cluster, however, you first need to get at least a cursory understanding of how server instances interact with one another in a cluster and what mechanisms enable the deployment of an application on multiple server instances. The next section covers these topics, providing a brief overview of the Oracle WebLogic Server cluster technology.

How Clustering Works

It's fairly obvious that Oracle WebLogic Server instances have to communicate with one another in order to appear to clients as a single Oracle WebLogic Server instance. Server instances in an Oracle WebLogic Server cluster communicate using the following network technologies:
·         IP multicast or IP unicast for one-to-many communications in the cluster, such as broadcasting heartbeat messages and cluster-wide JNDI updates
·         IP sockets for peer-to-peer communications, such as replicating object states between a primary and secondary server instance
When configuring your cluster, you can select either IP multicast or IP unicast cluster messaging mode for one-to-many communication. The default cluster messaging mode can vary depending on the tool you use to create a cluster. Thus, when creating a cluster with the Configuration Wizard, the default mode is set to unicast. With WSLT, however, multicast is the default. For details on the pros and cons of each messaging mode, consult Using Clusters for Oracle WebLogic Server. It's interesting to note, however, that Oracle recommends unicast for messaging within a cluster when creating new clusters.
As mentioned earlier, IP multicast or unicast is used to, among other things, maintain the cluster-wide JNDI tree, which plays a key role in application deployment. In particular, the JNDI tree used in a clustered environment holds information about the cluster-wide deployed objects and appears to clients as a single, global tree. However, the cluster-wide JNDI tree is replicated across Oracle WebLogic Server instances within a cluster using the cluster-wide JNDI updates mechanism. Thus, each server instance in a cluster maintains its local copy of the cluster-wide JNDI tree, updating that local JNDI tree as the information about new clustered application components comes in through the multicast (or unicast) channel.

How to start Managed Servers in weblogic

Starting Managed Servers

The startup process & the various states of weblogic startup

  1) Weblogic is a java process. It starts up like any other java process and goes through 

      several stage.
 2) You can see the process using ps –ef |grep java
3) The various states of during the startup can be seen in the log file that was generated on 
     console.

 4) The first subsystem that is started is LOGGING. Then Security. Once the authentication 
      is done ( manual or using boot.properties) the other sub-systems will start.

Stages of weblogic startup process
•STARTING
•STANDBY
•STARTING
•ADMIN
•RESUMING
•RUNNING
Until the server comes into RUNNING mode, it can not serve the user requests.

Starting Managed Servers

Managed Server

  $DOMAIN_HOME/bin/startManagedWebLogic.sh <managed-server-name> 
   <ADMIN_URL>
  
Eg.  -$DOMAIN_HOME/bin/startManagedWebLogic.sh DsoftMng1 
           192.168.128.3:20001

Stopping the weblogic servers

Managed Servers ( under $DOMAIN_HOME/bin)
  stopWebLogic.sh <managed-server-name>

•Admin Server
  stopWebLogic.sh 


How to start and stop Admin server



Hi Guys
 This post gives the Information about start/stop the Admin server

After starting u r server
how to chek the server is Running or fail..   


When u starting your server it shows below in command prompt RunningMode (means u r server is started)



Starting the admin server

$DOMAIN_HOME/startWebLogic.sh



Checking “if the server is up” 

            From command prompt log: 


as the above Image like as u got the running mode.....k now u r Admin server is Ready

now u can access the Admin console ...HOW

simple useing ADMIN_IP and Port/console


here 127.0.0.1 is the IP address of system and 10001 is port number of Admin server...
these two things are given in at the time Domain configuration....


Here u give the username of Admin server  and password....
U get the Adminstration console

How to stopAdmin server 

simple navigate perticuler location like below

$DOMAIN_HOME/bin/stopWebLogic.sh 

now u r Admin server is down