Wednesday, June 30, 2010

Starting Admin and Managed Servers using Node Manager and WLST

Node Manager is a WebLogic Server utility, independent of domains, that enables you to start, shut down, and restart Administration Server and Managed Server instances from a remote location. You can further use the Node Manager to control Administration Server and Managed Server from a local location also as I used in my case. Below post explains how you can start your Admin and Managed servers from the Node Manager.


Note : I have used Windows Vista OS and Oracle Database 11.2. All the commands for Linux/Unix will change accordingly.


Please follow the following steps for the same.


1.) Firstly configure the Node Manager
2.) Verify the Node Manager
3.) Once you verify and complete the above steps, I recommend, stop and close everything open till now. Then follow the following steps.
Start your Node Manager using <Middleware_Home>\wlserver_10.3\server\bin\startNodeManager.cmd command from the command prompt.

  • Open a fresh command prompt window and run WLST.cmd from <Middleware_Home>\wlserver_10.3\common\bin\WLST.cmd.
  • Next task is to connect to the Node Manager using nmConnect(). In the WLST console window type nmConnect('weblogic','welcome1','neeraj-pc','5556','soa_domain').
  • Once connected to Node Manager the command prompt will change.
  • Now to start your Admin server type nmStart() e.g. nmStart('AdminServer')
  • To start your managed server type nmStart() e.g. nmStart('soa_server1')
  • If it gives the success notification, you are done. Also, you can verify the same from the Weblogic Console.


    Part 2 : How to start the Node manager and Verify that it is running properly

    After the Node Manager is properly configured, you can start the Node Manager by following the below mentioned steps.

    • Open a new command window and go to <Middleware_Home>\wlserver_10.3\server\bin using cd command. Type startNodeManager and press Enter.
    • It starts your Node Manager and gives the output as shown in below image.

    • To verify if the Node Manager is running successfully, start your Admin Server if it is not Running and go to Weblogic Server Console.
    • Navigate to Environment --> Machines --> LocalMachine --> Monitoring Tab --> Node Manager Status. It should display Reachable. See below image.
    • Hence the Node Manager is running properly.




    Part 1: How to configure the Node Manager to start Admin and Managed Servers

    Before you can use the Node Manager utility, you need to configure/verify the Node Manager. 
    • For this start the Admin Server as usual by running the <Middleware_home>\user_projects\domains\soa_domain\startWebLogic.cmd.
    • Go to Weblogic Console and navigate to Machines-->LocalMachine-->Configuration Tab-->Node Manager Tab. Specify the ListenAddress (where Node Manager will run) and ListenPort as per you installation. By default the port is 5556. Be sure to provide the exact URL/Host name in ListenAddress as localhost will disallow starting the servers from remote location. See below image.

    • Go to <Middleware_home>\wlserver_10.3\common\nodemanager\nodemanager.properties. Set StartScriptEnabled=true.
    • Start WLST from <Middleware_home>\wlserver_10.3\common\bin\wlst.cmd in a separate command prompt window. You can double click on the wlst.cmd also to start WLST.
    • Once WLST starts, connect to Admin Server from the WLST console. To connect type the connect() command on the WLST console and press Enter. Accept defaults or provide inputs as required. Once it connects successfully, the WLST prompt will change to wls:/mydomain/serverConfig>.
    • Now type nmEnroll(<Middleware_home>\user_projects\domains\soa_domain). This command enrolls the current machine with the Node Manager and creates some properties file (nm_password.properties,SerializedSystemIni.dat).
    • If the message displays as "Successfully enrolled this machine with the domain directory at", Enrollment is successful. 
    • Exit from the WLST console using the exit() command and shut down your Admin Server and Close the Browser Console window.
    • Node Manager is configured. Further, to start the Admin and Managed Servers from this Node Manager, refer to this post. 

    Thursday, April 29, 2010

    Client side Error Handling with validateRegExp on Decimal fields

    There are undoubtedly more than one ways of handling the errors gracefully for your ADF inputText component. One of which is at the Model Layer using Validation at the Entity Objects the details of which can be seen here.
    However, in some of the cases where we have an editable table dropped on the page and we need to provide the validation on all its fields, some of which are decimals, the various ways would be to use the various validators and converters as described here. However, this post describes 2 ways to handle the errors on the Decimal fields.

    Note : To demonstrate the use of Decimal fields I've created a column Weight in the Employees table. Further I've created an Employees Entity Object, View Object and Application Module.


    I also created a jspx page to Create/Update an Employee



    Using the Validate Double Range :
    Drag the validateDoubleRange validator from the Component Pallette under the JSF Core Menu and rop it under the inputText component. Remove ConvertNumber if any present. Just specify the range here as shown below.


    At run time whenever an error occurs it shows the result in the following format.


    However, the limitations of using this approach are :

    • You can not customize the message.
    • The Error messages are displayed after Submitting the page which involves a server call.

     Many times customers want client side validation messages in JavaScript alert boxes. The second approach demonstrates the same.

    Using validateRegExp :
    Validate Regular expression is a very efficient means to check for any format of the STRINGS. But unfortunately it can not be used for Numerical or Decimal data types. Even if you try to drop a validateRegExp validator under inputText, it works properly in case of errors but in case of correct value it throws an exception.



    500 Internal Server Error
    java.lang.IllegalArgumentException: 'value' is not of type java.lang.String. at oracle.adf.view.faces.validator.ValidatorUtils.assertIsString(ValidatorUtils.java:36) at oracle.adf.view.faces.validator.RegExpValidator.validate(RegExpValidator.java:103) at oracle.adf.view.faces.component.UIXEditableValue.validateValue(UIXEditableValue.java:378) at oracle.adf.view.faces.component.UIXEditableValue.validate(UIXEditableValue.java:206) at oracle.adf.view.faces.component.UIXEditableValue._executeValidate(UIXEditableValue.java:522) at oracle.adf.view.faces.component.UIXEditableValue.processValidators(UIXEditableValue.java:302) at oracle.adf.view.faces.component.ChildLoop$Validate.process(ChildLoop.java:67) at oracle.adf.view.faces.component.ChildLoop.runAlways(ChildLoop.java:39) at oracle.adf.view.faces.component.ChildLoop.runAlways(ChildLoop.java:30) at oracle.adf.view.faces.component.UIXColumn.processValidators(UIXColumn.java:70) at oracle.adf.view.faces.component.UIXCollection.processComponent(UIXCollection.java:822) at oracle.adf.view.faces.component.TableUtils$3.process(TableUtils.java:256) at ...

    To remove this error, just change the data type of your attribute to String in the Entity Object as shown under. Please note the same Entity Object can be used for other View Objects also. Hence make sure that all the View Objects are in tact.


    So everything is set. Just run the page now and see the output.


    Friday, April 2, 2010

    no cache policy header, USE_APPLICATION_VIEW_CACHE not working properly

    Problem : 
    When I try to open a dialog box from my  page, I get the following error.


    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.config.AFCConfigFactory getConfig
    INFO: ADF Config did not find the AFC config 
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.config.AFCConfigFactory getConfig
    SEVERE: Error in config : Cannot locate config file. Using default values
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.config.AFCConfigFactory getConfig
    SEVERE: Error in config. Using default values
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.filter.PageCachingProcessor getResponseFromCache
    INFO: page (__ADFv__) cache miss
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.filter.PageCachingProcessor isResponseCacheable
    INFO: response not cacheable - no cache policy header
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.filter.PageCachingProcessor getResponseFromCache
    INFO: page (PPAPListDialog.jspx) cache miss
    Apr 2, 2010 12:24:22 PM aam.tooling.managedbeans.LoggedUserInfo
    INFO: In Logged User Info Bean...
    Apr 2, 2010 12:24:22 PM oracle.webcache.adf.filter.PageCachingProcessor isResponseCacheable
    INFO: response not cacheable - no cache policy header


    Due to this error, the following things happen.

    • I keep on getting the Row Currency Error on navigating time and again to my dialog pages.
    • I have an attachment dialog with command link to save the attachment on user's system. It often refers to the firstly clicked attachment always even when I have clicked on the different link this time.
    • It does not update the dialog view properly. Sometimes newly added rows do not get displayed there.

    Solution :
    After a long study it was clear that it has something to do with the cache. But I just wondered where. Finally it was  USE_APPLICATION_VIEW_CACHE in the web.xml file. I set it to false and all the above mentioned errors went.
        <context-param>
            <param-name>oracle.adf.view.faces.USE_APPLICATION_VIEW_CACHE</param-name>
            <param-value>false</param-value>
        </context-param>
    Although more information about USE_APPLICATION_VIEW_CACHE  can be found here but there is no reference that I could make why this be causing problem in my application. But still if you face the same problem (probably when it's a day before the UAT as in my case), you can give a thought to apply this solution.

    Friday, February 26, 2010

    Can not start Jdeveloper : Unable to create instance of Java Virtual Machine

    I had not thought that Jdeveloper 10g may throw some error depending on my disk space even. When I tried to restart my Jdeveloper 10.1.3.3.41.57, it popped up an error message to me as shown below. 


    When Jdeveloper starts it tried to allocate some some heap size from the disk space. If that space is not avilable this error is popped up.

    The same can be easily resolved by changing the AddVMOption parameter value to the desired value.

    Location : JDEV_HOME\jdev\bin\jdev.conf
    Parameter : AddVMOption
    Value : <Any valid disk space value in MB>

    #
    # Set the maximum heap to 512M
    #
    AddVMOption -Xmx1024M

    If you have lot of available disk space it is better to have this heap size around 1024 MB to accelerate the context switching of Jdeveloper.

    Sunday, January 31, 2010

    Setting the current row of a view object with custom key programmatically

    I came across a use-case where I needed to set the key of a View Object manually through the backing bean. Usually setCurrentRowWithKey() or setCurrentRowWithKeyValue() can be used to set the current row of a view object. But What if you don't know the exact key but part of it and you want to create the key yourself and set the current Row programmtically.  Well you can use the following function on click of a command button or customize it happily to put to any specific use...

        public String setNewRowKey() {
            // Get the iterator displayed on the Page
             FacesContext ctx = FacesContext.getCurrentInstance();
             Application app = ctx.getApplication();
             ValueBinding bind = app.createValueBinding("#{bindings}");
             DCIteratorBinding iter = ((DCBindingContainer) bind.getValue(ctx)).findIteratorBinding("DepartmentsEmployeeVOIterator");
             if (iter == null) {
               throw new RuntimeException("Iterator not found");
             }
             
             // Create the key manually. It requires providing all primary keys for all 
             // the Entity Objects included in the View Object
             Object [] keyValues = new Object[2];
             keyValues[0] = null;  // Any Department
             keyValues[1] = "114"; // Employee ID
             
             // find all the rows matching the above criteria using the RowSetIterator. 
             // You can also use the same to find rows matching any key criteria.
             Row [] rows = iter.getRowSetIterator().findByKey(new Key(keyValues), -1);
            
             if (rows.length > 0)  {
                 // get the first row and its key and set current row of iterator with this key string
                 iter.setCurrentRowWithKey(rows[0].getKey().toStringFormat(true));
             }
             
            return "navigation-rule";
        }