Archive

Archive for February, 2014

How to start Weblogic Server when any one of the Data Source is down

February 25, 2014 Leave a comment

Recently we came across an issue with Weblogic start up, we configured Weblogic server with multiple DataSources and one of our Database is down due to some network issue. Weblogic server is unable to start as one of the DataSource is down, but to delete the DataSource (not working one) we need to have Weblogic server started, To start the server every DataSource should work fine. It’s  a deadlock.

Solution : All the DataSources related configuration files located in (beahome)\user_projects\domains\Your_Domain\config\jdbc, Copy the working DataSource details jdbc_url,username,pwd(it will be in encrypted format) and paste it in another DataSource configuration xml file which database is down.

Suppose we have two DataSources

  1. DATASOURCE_1
  2. DATASOURCE_2

If DATASOURCE_1 is not working, we can copy the jdbc-url, username,pwd from DATASOURCE_2 and paste it in DATSOURCE_1 configuration file.

And start weblogic server now, it will start normally.

What we did here is just manipulated weblogic with the same jdbc details with multiple DataSources, internally it will treat as multiple DataSources, but it will connect to only working database as we gave the jdbc details of this working database.

Though we have two DataSources named with DATSOURCE_1 and DATASOURCE_2, both are pointing to same database DATSOURCE_2.

Thanks for reading, hope it helps.

Advertisements
Categories: Java, Weblogic

How to execute method with JSP EL tag?

February 20, 2014 Leave a comment

Till JSP 2.1 by using property name on bean <c:out value=”${beanName.property}”/> we used to display the values, internally it will call getter method of that property and value will be printed to browser. But to execute a normal method which doesn’t have getter method or setter method is not possible till JSP 2.1.

if we write <c:out value=”${beanName.methodName}”/> it will throw an error saying : getMethodName is not existing in type beanName.

But from JSP 2.2 on wards we can write <c:out value=”${beanName.methodName}”/> and it will execute the method internally and outputs the results to browser.

This feature is available in Servlet 3.0 environment, Tomcat 7 implementing Servlet 3.0 so we can run this code in Tomcat 7.

Thanks for reading

Categories: Java Tags:

Javascript : modular pattern

February 16, 2014 Leave a comment

While writing javascript code as a beginner we just write

function hello(){
alert('hello world');
}

but some problems occur with this approach, when we include multiple js files. All the variables which are declared outside any function will be treated as global and can be accessed from any function. And all the functions in all the js files are local to each other that means we can call any function from any js file, there is no concept of private function or we can not hide any function from being called.

With Javascript modular pattern we can avoid all these.

In this pattern we assign an anonymous function to global variable and all the functions declared inside can be called by using the variable name and the function name.

var app = (function (){

})();

Here app is the global variable and an anonymous function is assigned to it.

var app = (function (){
    return {
       publicFun : function(){
              alert('public function');
             }
    };
})();

Declared a function with name publicFun, to access this function we have to call with global variable name app.publicFun(); and it will alert with “public function”.

Private functions: Whatever the functions we returned from the anonymous function can be accessed by using app global variable.

If we declare any function before return function, that will be called as local function and can not accessed with app variable.

var app = (function (){
    function privateFun(){
             alert('private function');
    }
    return {
       publicFun : function(){
              alert('public function');
             }
    };
})();

If we call app.privateFun(); will give an error : TypeError: app.privateFun is not a function

So these private functions can not be accessed out side of the anonymous block. But we can call these in side any other public  function.

var app = (function (){
    function privateFun(){
             alert('private function');
    }
    return {
       publicFun : function(){
              privateFun();
              alert('public function');
             }
    };
})();

Now app.publicFun() will internally call private function and will get private function alert followed by public function. Thanks for reading, hope you enjoyed it.

Categories: javascript