Sunday, July 14, 2013

Starting WebLogic as a Windows Service

WebLogic can be started by different ways and "Windows Service" is one of them.

If you check to create the service during the installation time a Windows service to start a weblogic domain will be created automatically, which we normally miss :)

So by following below steps you can create a Windows Service by which you can start a WebLogic server.

Install a weblogic instance (from 8.1 or above).

Now the script that help us do this process is "installSvc.cmd" which will be present under WL_Home\server\bin

We need to make a explicit script say "services.cmd" and it should contain the below configuration.

************************
echo off
SETLOCAL
call "\bin\setDomainEnv.cmd"
set DOMAIN_NAME=
set USERDOMAIN_HOME=
set SERVER_NAME=
set WLS_USER=
set WLS_PW=
set JAVA_OPTIONS=-Dweblogic.Stdout="\stdout.out"
-Dweblogic.Stderr="\stderr.txt" %JAVA_OPTIONS%
call "\server\bin\installSvc.cmd"
ENDLOCAL
************************

Description of the above script line by line.

First we call the setDomainEnv.cmd file which will set the environment.
Then we set the Domain name, domain location, which server we want to start via service, the username and password respectively.

Option "Dweblogic.Stdout" and "Dweblogic.Stderr" and not mandatory but is recommended to have it so that we will understand if there is any issue while executing the script or starting the server.
In the end we ill call "installSvc.cmd" and which will be creating a windows service.

Save the above file as a ".cmd" file and run it.

A new service called "bea__Domain__ServerNmae" will get created.And start the service.


That's it you service has been created successfully.

If you make the service run "Automatically" then the server will startup when ever you start your Operating System.

Friday, July 12, 2013

Apache WebLogic Integration

Apache- Weblogic integration

Recently I had a chance integrate Apache and WebLogic by following below steps you too can do it :)

For this I am using weblogic 10.3.4(Doesn't really matter which WLS version you ar using) and Apache 2.0.

WebLogic server setting

1) Make sure you are 1 Admin and 1 or more managed server.
2) Deploy a sample application in Managed Server which we will     be connecting via Apache WebServer.
3) Make sure you have a valid entry in "Listen Address:" for the managed server.(You can validate the same from Admin Console--> Server-->Managed Server-->Configuration-->General)


Configure a Admin and a Managed Server and make sure its running

Make sure you have a valid entry in "Listen Address" tab of Managed Server like below.




Now deploy a sample application and try to hit the same.

I have uploaded a sample application which will give you the server and host IP address

You will get below page


Sinne you have already installed apache we are going to configure the Apache so that when you hit a request to Apache it should redirect the same to respective WebLogic server

For that we need to go to below location.

C:\Apache2\conf

Where Apache2 is where w have installed the apache.

There we should see a file called httpd.

Take a backup of the existing one and open the file.

If you go to bottom you should see a entry for "Location" and IfModule, which we need to edit it as below

<Location />
 SetHandler weblogic-handler
</Location>


<IfModule mod_weblogic.c>
 WebLogicCluster <CLuster IP address>
 Debug ON
 WLLogFile C:\Apache\logs\wlproxy.log
 WLTempDir C:\Apache\logs
</IfModule>


Now if you having one IP address then inside IFModule you should enter like below

WebLogicHost myweblogic.server.com
WebLogicPort 7001

If you have multple server in a cluster then the entry should be like

WebLogicCluster myweblogic1.server.com:7001,myweblogic2.server.com:7003,myweblogic3.server.com:7003

Keep the Debug ON and route the wlproxy logs to a location, so that incase of any issue or failure you should get the logs which shows the reason of failure.

Also for testing purpose you can add below parameter inside the IfModule

"DebugConfigInfo ON"

By which you can hit below url

 http://myWebServerServerIP:WebServerPort/myApp/index.jsp?__WebLogicBridgeConfig

But this is not recommended on production.

Also we need to load the WebLogic module in the Apache by adding below entry.

LoadModule weblogic_module modules/mod_wl_20.so

"mod_wl_20.so" file can be found unders WLS_Home\server\plugin\<Your_OS>\<Whether 32 or 64 bit>


By hitting above url we will come to know that, to waht all servers Apache is able to lookup and other tcp level parameters.

That's it , restart the Apache and try to access the application via Apache.

Now you will be able to access the application via Apache

Wednesday, July 10, 2013

JMS Bridge Creation and configuration

JMS Bridge Creation and configuration

In this chapter I will be giving a basic idea about JMS bridge creation and configuration.

What is a JMS bridge and why JMS bridge?

JMS bridge enables you to connect between to Messaging server.

The main advantage of bridge over SAF(Store and Forward which is a WebLogic implemented Messaging Implementation) is that its server independent.

That is you can have the JMS bridge configured to connect between, WebLogic and MQ or Weblogic and JBoss etc. Although SAF can used to connect between two WebLogic servers.

HOW JMS BRIDGE CONFIGURED AND HOW IT IS ABLE TO CONNECT TO OTHER MESSAGING SERVER.

Configuring a JMS bridge is very easy, provided you have proper destination.

In a JMS bridge mainly two connections are made,
   
1) To the Source
2) To the Destination.


We can make the connection XA or non-XA, depending on the requirement and respective resource adaptor with respect to weblogic will be installed.

There are two types of adaptor

jms-xa-adp.rar     :--or which the jndi name will be "eis.jms.WLSConnectionFactoryJNDIXA"

jms-notran-adp.rar :--- for which the jndi name will be "eis.jms.WLSConnectionFactoryJNDINoTX"

Below are the steps for creating the JMS bridge

When you click Bridge from the Admin console you willget below menu

As the above picture shows a Bridge needs a Name, Source Bridge Destination and Target Bridge Destination.
Source bridge destination is from where the messages are picked up and target bridge destination is where the messages are posted to.
**One main feature of bridge is that the communication is uni-directional, i.e. On a single bridge you can’t have source bridge to receive messages from a target bridge.
If you want bi-directional communication you need to configure 2 bridges.(One for sending and other for receiving).
This is the main difference between SAF and Bridge as in SAF you can send and receive messages with one SAF agent.
Now let’s start the configuration.

When you try the create a JMS bridge below screen will appear.
Where you need to give a bridge name and Quality of Service(QOS).




QOS will determine service quality of messaging bridge.
When you are using XA transaction’s, it is always recommended to use Exactly once, which will envelops a received message and sends it within a user transaction (XA/JTA).
When you use Exactly_once mode then it ensures that the message is send only once and will rollback if there is any issue occurs during the message flow. This ensures that message will reach if the client is up and will roll back if there is any issue. Either way the message is secure are can’t be lost.
The other two QOS state are Atmost-once and Duplicate-okay. These are mainly recommended for non-XA messages.
Atmost-once :-  the resource adapter uses the AUTO_ACKNOWLEDGE mode(It will be send only once and doesn’t wait for the receiver to send a acknowledgement, which can cause message lost)
Duplicate-okay :- uses CLIENT_ACKNOWLEDGE(where there is a chance of having duplicate messages).





When you click next you see below page where you need to configure/select(if its already there) the Source Destination.
When I click “New Destination” I will get below page.

In the above page you need to add “connection url” ,”connection factory JNDI Name” and “Destination JNDI Name”
Example values
Connection_url :- t3://localhost:7001
Connection factory jndi :-  cf
Destination jndi :- “jndi configured for Queue or Topic”
The first column is the name of the Source bridge(which you give user specific if needed ) and second is the JNDI adaptor name.
As I mentioned in the beginning you can choose two adaptors, XA or non-XA

Similar for Destination

That's it with the Bridge Creation.
Now if you click bridge --> Monitoring you will be able to see the state of both Source and Destination Bridge.

Ideally if all lookup and configuration is correct the you will be seeing "Forwarding Messages".
If you start the bridge from the admin console, can will be seeing "Started by Administrator"

As we all know this will not work at when you are trying first time. So below are the main issue you could encounter.
1) Failed to connect to Source
2) Failed to connect to Destination.

If you see any above error in the "Monitoring tab" of Bridge, then the message flow will not work.
The main reason for the above issue will be the parameter that you have given in anyone of the below
“connection url” ,”connection factory JNDI Name” or “Destination JNDI Name”
Make sure you have given the connection url in the below format
“t3://localhost:7001”.
If you want to connect to multiple IP’s then you can give the url like below
“t3://<First IP Address>:<Port>,<Second IP Address>,<Port>

Also make sure the jndi names of connection factory and Queue or Topic, which you provided in the source and destination are correct.
It’s always recommended to restart the servers if you have changed any above parameters, so that binding will be refreshed.

In the logs if you see any exception with is mentioning  “eis.jms.WLSConnectionFactoryJNDIXA" or "eis.jms.WLSConnectionFactoryJNDINoTX" then it will be a problem with the adaptor.

Whenever you configure a XA or non-XA bridge to a server or a cluster of servers a file called jms-xa-adp.rar (for XA) or jms-notran-adp.rar(for non-XA) will be deployed automatically.

Make sure the files are in Active state in the “Deployment tab” at the Admin Console  and its targeted to correct servers where the bridge resides.