Wednesday, July 3, 2013

Websphere - increasing wait time when uploading an application via admin console

Default time for application install (upload) in websphere has been set to 60 seconds.


To increase this you have to go to


Application servers > server1 > Web container > Web container transport chains



There are several handler chains defined for various purposes. Since in this post i m going to describe the scenario of uploading app via admin console, i l skip the rest. (though the procedure is same)




Select WCInboundAdminSecure from the above lists (since admin console use SSL).


Increase the “Read timeout" . Click Apply and save.


Monday, June 3, 2013

Using XQuery to get values from set of XPaths and return null if node is not presented.

I have been stuck for few days due to that i can not return anything from querying XPath if that specific XPath is not presented in my XML file. The scenario is that we have nodes in our XML file that may be or may not be present in XML file arbitrarily.

Yes you can do it programmatically if you only use one XPath at a time. But my need is different. I want to get values of several XPaths at once and at the same time i need it to give me something pre-defined ( let's say "null"), if one of XPaths i am querying for is not presented.

So i basically had two problems to overcome. One is how to get values of several XPaths at once.
And the other is getting per-defined value if that specific node is not presented in my XML document.

First i tried using purely XPaths. In this way i have been able to overcome my first problem, that is querying several XPaths at once. That is by using XPath Union operation. XPath union operator can be use as follows

 /A/B/C/text() | /A/D/C/text() | /A/E/C/text()  

or

 /A/B/C/text() union /A/D/C/text() union /A/E/C/text()  

Here by using "|"  or "union" you  can join as much as XPaths you want. And i have seen that this improves performance since you can use to get several values you want through out the system at one call without calling the same function (which you use to execute your XPaths) several times.

Also order of the values return by using XPath union preserve the order of the elements appear in XML document.

Problem in this method come with this order. If you join an element that will not present in the XML file always, it will destroy the order of the values return. Which is lets say if all the "C" elements present in above example, then the returning order values should be,

 1. value of /A/B/C/text()   
 2. value of /A/D/C/text()   
 3. value of /A/E/C/text()   

But, lets say that Node /A/D/C is not presented in XML file.Then the order will be,

 1. value of /A/B/C/text()   
 2. value of /A/E/C/text()   

Yes you get it right!!! Nothing in the middle saying that we have no /A/D/C node. So the order of the return values have been changed.

Because of this I have find an alternative and XQuery came to rescue. Yes XPath is to do complicate stuff like querying and modifying results. That is the job of XQuery. XPath is there to show the way to XQuery ("hey dude the node you are looking for is this way")

So by using XQuery FLOWER statement i have been able to write following query to evaluate set of XPaths and get their values at the same time and also if there is some node missing in the middle to return "null" which help to preserve the order of the return values.

 let $i1:=/A/B/C/text()   
 let $i2:=/A/D/C/text()   
 let $i2:=/A/E/C/text()  
 return string-join((if($i1) then ($i1) else ('null') , if($i2) then ($i2) else ('null') ) , ';')  

Here i have used string-join(string1, string2 ... stringN, 'delemeter') function of XQuery to join the results and ';' as the delimiter.

We can use if(condition or XPath) then (statement or XPath) else (statement or XPath)to check the availability of node and send a per-defined value if node is missing.






Monday, April 29, 2013

jQuery - when to use attr() ?? when to use prop() ???

with effect from jQuery 1.6 a new method has been introduced to change or retrieve values of attributes (or properties).

So what is the big deal here you might ask. the problem is that new comers doesn't understand the difference between the attr() method which has been there and the new method prop() which introduced lately.

In a HTML element there is two kind of  things we can see.
  1. Attributes
  2. Properties
I will explain this by an example. Lets take following HTML input tag for an instance.

 <input id="q" value="" class="button-gray" name="_3_keywords" readonly>  

In the above example  id, value, name are belong to Attribute family while readonly is a property. So when to use attr() method or when to use prop() method is depend on whether you are dealing with an attribute or a property.

For example lets say you want to change the class attribute of above INPUT tag. Here you have to use  attr() method like below.

 $("#q").attr("class", "newclass")  

But lets say if you want to make the above INPUT tag readable (it is readonly originally according to the code above). So here you have to use prop() from  jQuery 1.6 onwards like below.

 $("#q").prop("readonly", false)  

Yeah you might noticed the change. Before jQuery 1.6 you have to use attr() method like below. 

 $("#q").attr("readonly", "readonly")  

But with new  prop() you can save life by just giving a boolean as the second attribute.

 


"ceylon" command throwing "UnsupportedClassVersionError" exception

When i was trying to install and configure classpath for Ceylon programming language to begin coding i was getting this error which does not describe it self.


 Exception in thread "main" java.lang.UnsupportedClassVersionError: com/redhat/ce  
 ylon/launcher/CeylonClassLoader : Unsupported major.minor version 51.0  
     at java.lang.ClassLoader.defineClass1(Native Method)  
     at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)  
     at java.lang.ClassLoader.defineClass(ClassLoader.java:615)  
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14  
 1)  
     at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)  
     at java.net.URLClassLoader.access$000(URLClassLoader.java:58)  
     at java.net.URLClassLoader$1.run(URLClassLoader.java:197)  
     at java.security.AccessController.doPrivileged(Native Method)  
     at java.net.URLClassLoader.findClass(URLClassLoader.java:190)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:306)  
     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)  
     at java.lang.ClassLoader.loadClass(ClassLoader.java:247)  
 Could not find the main class: com.redhat.ceylon.launcher.Launcher. Program will  
  exit.  

The mistake i did at the beginning seems to be avoid reading the "README.md" file in ceylon package. In there it clearly stated that "Ceylon execute on any Java 7 compatible JVM ... "

So the above error gives because of the incompatible JVM version. (as it says in the line "Unsupported major.minor version 51.0" ).

So to fix this what you need to do is simply install the JDK 7 and add it to the classpath, JAVA_HOME and JRE_HOME. That will fix this.

HAPPY CEYLON CODING !!!


Monday, April 22, 2013

tools.jar can not be found in JRE folder

I came across this error other day i was trying to configure ant in my new machine. The reason for this is that the relevant jar file is not in the <JRE location>lib folder but in <JDK location>lib folder.

The most simplest fix for this is to just copy the "tools.jar" file from the <JDK location>lib to  
<JRE location>lib folder.
 
Good luck.
:)

Saturday, March 9, 2013

jQuery - checking for "null" objects...

In day to day Object Oriented programming we used to check whether an object is null by comparing it with the null keyword supplied by the programming language. For an example in Java or javascripts we can use

1:  object == null  

So what we use to do with jQuery  is like below,

1:  $("#id") == null  

This is wrong. The reason is that even there is no any HTML elements that has id of "id", $("#id")  will return an empty object. (or empty array object,). So this will always make the above expression to evaluate to false.

So how we get to know whether above object (element) exist before using that object in complicate logic ???

You can use the following code.

1:  $("#id").length > 0  

Now where does this length property come to HTML element. The reason is jQuery objects wrap around DOM objects and they are having their own methods and attributes. When we accessing HTML elements using jQuery, it will return an array of such elements. So if there is only one object returned we can directly access that object. If there are more than one object we can use normal array indexes to access them. But if there is no object or 0 object for what we asked, what jQuery does is return an empty array object. So what we can do to check if there is no object relevant what we have asked is to check the length of the array return by jQuery. If length of the array is not greater than 0 means there is no object to be return (only the empty array object is there).



Tuesday, February 19, 2013

When jQuery form submission not works , Work arounds.

Let us consider the below form and various ways to do a form submission in client side programming.

1:    
2:  <form id="formId" name="formName" class="form-class" action="" method="post">  
3:  </form>  

Before introducing jquery, the famous but harshful way to access DOM is using the popular getElementByID() method in javascript so accomplish a form submission we can use it like below,

1:    
2:  document.getElementById("formId").submit();  
3:    

Also if there is no id for the form we can still use the form name to do a form submission as below,

1:    
2:  document.getElementsByName("formName")[0].submit();  
3:    

But with jQuery life has become much easier and we can use either form ID in the way we use them to decorate using CSS or either CSS classes to pick elements. Below is how we can do a form submit using form ID

1:    
2:  $("#formID").submit();  
3:    

And we can use the class selectors to access forms as well. This method returns an array of elements which has the same style class. (In our example we have only one element, and it is our form.)

1:    
2:  $(".form-class")[0].submit();  
3:    

Finally we can use elements itself to access themselves. This method will return an array of same elements. (According to our example we only have one element of type "form".)

1:    
2:  $("form")[0].submit();  
3: