Tuesday, August 25, 2009

Significance of ConnectionlOTimeOut parameter in WebSphere Application Server

When hosting the Enterprise Application on WebSphere Application Server, sometimes its possible to receive the following exception:

java.net.SocketTimeOutException: Read Timed Out. (in SystemOut.log or activity.log).

Possible Root Cause:

A slow network connection between the client and the server causes this problem. In such cases, the HTTP socket might time out before the server completely reads the SOAP request. Sudden increase in overall network activity can also cause this problem The problem can also occur when the client is accessing the service from the server in a slow network connection and in situations where the amount of data in the SOAP request is large.

Possible solution:

Setting an appropriate value in the ConnectionlOTimeOut parameter might help to resolve the above issue. This parameter is configured under Web Container HTTP Transport (e.g 9080).
The default value is 5 seconds for the ConnectionlOTimeOut parameter for your Web container HTTP transport .

Thanks
A.T.J

Sunday, August 23, 2009

Type safe collections in J2SE5.0

Arrays in Java have always been type safe—an array declared as type String (Stringfl) can't accept Integers (or ints). or anything other than Strings. But before Java 5 there was no syntax for declaring a type safe collection.

To make an ArrayList of Strings, we use
ArrayList myList = new ArrayList();

Or, the polymorphic equivalent:
List myList = new ArrayList();

There was no syntax that let you specify that myList will take Strings and only Strings. And with no way to specify a type for the ArrayList, the compiler couldn't enforce that you put only things of the specified type into the list.

The Legacy Way to Do Collections

Here's a review of a pre-Java 5 ArrayList intended to hold Strings.
List myList = new ArrayList(); // can't declare a type
myList.add("Fred"); // OK. it will hold Strings
myList. add(new Customer()); // and it will hold other objects too
myList.add(new lnteger(42)); //and Integers....

A non-generic collection can hold any kind of object; it also holds anything that is NOT a primitive. And since a pre-Java 5 collection could hold anything, the methods that get objects out of the collection could have only one kind of return type—java.lang.Object. That meant that getting a String back out of our only-Strings-intended list required a cast:

String s = (String) myList.get(0);

And since you couldn't guarantee that what was coming out really was a String (since you were allowed to put anything in the list), the cast could fail at runtime.

Java 5 Generics

Java 5 generics takes care of both ends (the putting in and getting out) by enforcing the type of your collections. Let's update the String list:

List myList = new ArrayList();
myList.add("Fred"); // OK. it will hold Strings
myList.add(new Customer()); // compiler error!'.

By using generics syntax—which means putting the type in angle brackets , we're telling the compiler that this collection can hold only String objects. So, now that what you put IN is guaranteed, you can also guarantee what comes OUT, and that means you can gel rid of the cast when you get something from the collection. Instead of

String s = (String) myList.get(0); //pre-generics. when a String wasn't guaranteed
We can now just say
String s = myList.get(0);

Advantages of Generics
  • Type casting is automatic. The user can now get the object from a collection without bothering to type cast the object into the target class.
  • Since the validation of the types happen at compile time, run lime exceptions like Class cast exceptions are avoided.
Thanks
A.T.J

Key Difference Between STRUTS 1 & STRUTS 2

The following table will differentiate the struts 1 & 2 clearly:


Pls click the above image and see it fully.......

Thanks
A.T.J

Some J2EE Rules / Best Practices

Do Not Call System Exit: Web applications should not call System.exitQ, since only the web container or the application server should stop the JVM.

Static EJB Field Should Be Final: According to the J2EE specification, an EJB should not have any static fields with write access. However, static read only fields are allowed. This ensures proper behavior especially when instances are distributed by the container on several JREs.

Do Not Use Threads: The J2EE specification explicitly forbid use of threads.

Use Proper Class Loader: In J2EE getClassLoader() might not work as expected. Use Thread.currentThread().getContextClassloader() instead.

Close connections: Most Java programmers close a connection with the database directly—without closing the ResultSet or Statement. But not all JDBC drivers clean themselves up. To be safe, remember to close everything explicitly in reverse order, i.e. in the order of ResultSet, PreparedStatement, Connection.

Use appropriate transaction attribute: Avoid transaction overhead for non-transactional methods of session beans by declaring 'NotSupported' or 'Never' transaction attributes that avoid further propagation of transactions.

Thanks
A.T.J

When to use Ajax and Flex?

Use AJAX:
  • To make incremental usability enhancements to an existing Web site
  • For building "widgets" that require the work of a small team of developers
  • When you have existing, internal JavaScript and HTML expertise
Some examples of AJAX-appropriate uses could be navigational elements, simple calculators and client-side validated forms.

Use Flex:
  • When you need to develop applications that require a robust, scalable rich Internet application
  • Where you require sophisticated and interactive data visualization
  • When video and audio playback or Web camera and/or a microphone capture is a requirement
  • Where you require complex animation or bitmap manipulation
  • When the graphic design is core critical to your business needs
Flex would be the right choice for product configurations, workflow/process/inventory management applications, video conferencing, playback and editing, immersive or entertaining experiences, data visualizations and management dashboards. Additionally, in real-world use. Flex typically requires less coding to build the same or better functionality. The learning curve is somewhat steeper, but the development times are significantly lower.

Thanks
A.T.J

NFS Tips & Tricks

  • The usual issue found with the NFS mount points is the performance issue faced when a NFS mount is used. The system stalls even when a 'Is' command is issued inside the NFS mount point. This is because, the NFS is hard mounted, which is usually done with the default settings.
  • NFS, by default, does not permit the files owned by root user/group to be owned by root user/group in the NFS client mount. This can be fixed by using the no_root_squash option in the /etc/exports file in the NFS server.
Considering the above two cases, a better situation can be arrived at if it is soft mounted using the below options.

NFS Server side configurations:

In the file /etc/exports use the below entry format

In the file /etc/sysconfig/nfs provide the below entry RPCNFSDCOUNT=64

"The above value 64 can be decreased for a lower Hardware and network bandwidth. It can be changed based on the project requirements.

NFS Client side configurations:

: nfs soft,intr,proto=tcp,timeo=14,retry=3,bg,rsize=65536,wsize=65536 0 0
  • NFS usually maps the uids/gids owned by the files or folders in the NFS server to a user or a group that has the same uid or gid in the client box. Hence whenever NFS mount points are used, the user using the files or folders that are created in the NFS share, should have the same uid in all the boxes [the NFS client boxes and NFS server] that share the files or folders through NFS.
Similarly, the group too must have the same gid, in all the boxes.
  • In NFS4, when starting the NFS service in the NFS server, if you face an error saying RPC.IDMAPD not found, add the below entries in the /etc/fstab in the NFS server to avoid such error and improve performance and run the command mount -a as root.


nfsd /proc/fs/nfsd nfsd defaults,noatime 1 1
rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0

Thanks
A.T.J

Some tips for MQSeries using MQSC commands in troubleshooting

Here i m going to explain with the two Q managers A & B

Assume two Queue Managers A and B which are having communication problems

Stepl: Check the dead letter Queue

dis q(Dead letter Qname) curdepth

Step 2: Check the transmit Queue

dis ql(transmition Qname) curdepth

If the curdepth is 0 then, check the date and time of the last msg sent by the sender channel

dis chs(A.B) Istmsgda Istmsgti

where A.B is the Sender channel from Queue Manager A to B

1)If the date/time is recent then it means, messages are being transmitted.

2)If the transmit queue depth is 0 and your channel does not show a recent send date & time, and your messages are not in the dead letter queue, you most likely have an application problem.

3)If the depth is greater than 0, you most likely have a problem with the sender channel.

Step 3: Check the status of your sender channel

dis chs(A.B)

If the status is STOPPED, try to determine why it is stopped.
If the status is RETRYING, then identify the reason for Retrying.

- The reason can be found by examining the Queue Manager Error Logs for that specific Channel in question.

Thanks
A.T.J

Saturday, August 22, 2009

ASPECT ORIENTED PROGRAMMING

Try the New Tech.....:
AOP is a new technology for separating crosscutting concerns into single units called aspects. An aspect is a modular unit of crosscutting implementation. It encapsulates behaviors that affect multiple classes into reusable modules. With AOP. we start by implementing our project using our OO language (for example, Java), and then we deal separately with crosscutting concerns in our code by implementing aspects. Finally, both the code and aspects are combined into a final executable form using an aspect weaver. As a result, a single aspect can contribute to the implementation of a number of methods, modules, or objects, increasing both reusability and maintainability of the code.



The code that is executed when aspect is invoked is called Advice. It contains own set of rules as to when it is to be invoked in the relation to join points. Join points are simply specific point within the application that may or may not call the advice. Pointcuts are encapsulates the decision making logic that is evaluated to decide if particular piece of advice got invoked when joint is encountered.

Output:
before calling method 1
Inside method
Note:
In Example,
Red
: Joinpoint
Pink: Advice
Green: pointcut

Thanks
A.T.J

Wednesday, August 19, 2009

Autoboxing in J2SE5.0

JUST GO THRO' it:
In general, collections can hold Objects but not primitives. Prior to Java 5. a very common use for the wrapper classes was to provide a way to get a primitive into a collection. Prior to Java 5. you had to wrap a primitive by hand before you could put it into a collection. With Java 5, primitives still have to be wrapped, but autoboxing takes care of it for you.
here i m going to show this technique with three examples..........

Example1:
List mylnts = new ArrayList(); // pre Java 5 declaration
mylnts.add(new lnteger(42)); // had to wrap an int

in this example, we are still adding an Integer object to mylnts(not an int primitive) at autoboxing handles the wrapping for us.

As of Java 5 we can say
mylnts.add(42); //autoboxinghandles it!

Example2:
Integer var1=10; // pre Java 5 equivalent is int var1=10;
Integer var2=var1+15; // pre Java 5 equivalent is int var2=var1+15:
System.out.println(var2); //prints 25

Example3:
import java.util.*;
public class WordCounl {
public static void main(String[] args) {
Map m = new TreeMap();
for (String word : args) {
Integer wordCnt = m.get(word);
m.put(word. (wordCnt == null ? 1 : wordCnt + 1));
}
System.out.println(m);
}
}

What is really happening is this: In order to add 1 to wordCnt, it is automatically unboxed, resulting in an expression of type int Since both of the alternative expressions in the conditional expression are of type int, so too is the conditional expression itself. In order to put this int value into the map. it is automatically boxed into an Integer.

Thanks
A.T.J

Tuesday, August 18, 2009

Using CSS sprites: Improve Web Performance

JUST GO THRO'it:

CSS sprites group multiple images into one composite image and display them using CSS background positioning. You can save a significant amount of HTTP requests by consolidating your images into one or more composite sprites and using CSS to selectively display parts of the sprite within your web page. Some of the busiest sites on the Web use CSS sprites to save HTTP requests.

Brief HowTo:
The idea behind CSS sprites is to consolidate multiple images into one sprite and then selectively display portions of this sprite with positioning.
The steps are as follows:


1. Group multiple images together (usually icons) into one sprite


2. Evenly space these images, aligned into one or more lines


3. Set this sprite to the background image of an element (usually a list)


4. Position the sprite to display the appropriate image by shifting the X or Y position by a multiple of the spacing


Case in Point: Yahoo!
Yahoo uses CSS sprites on its home page to improve performance. The first set of icons is displayed in the "Check your mail status" section on the right of Yahoo!

The #patabs li .icon rule loads the composite background sprite.
#patabs li .icon{
display:block;
z-index:10;
padding:8px 0 9px 40px;
background:url(pa-icons.gif) 5px 3px no-repeat;
}
The background position is changed to show only the icon that matches the tab ID (in this case #messenger).
#patabs #messenger .icon{
padding-left:31px;
background-position:Xpx Ypx;
}

Thanks
A.T.J

Sunday, August 16, 2009

Crystal Report - Tips

TIPS HERE :

  • Don't use tables directly in Database Expert instead use 'Add Command' Option in Database Expert since it will improve the performance of the report.
  • To pass a parameter in a query, use '{?parameterName}' and add the same parameter in "insert parameter" dialog box.
  • When exporting a report that contains strings encoded in a particular character set (for example, German) to Text format on a system using a different code page than that set (for example, Japanese, or simplified Chinese), the export can enter into an infinite loop. The cause was that some characters were misinterpreted as the lead byte of a double byte character. This would result in the export to loop on the character following the misinterpreted one. Hence to avoid this, enable UNICODE instead of ASCII during the installation of Database and Crystal Reports server.
Thanks
A.T.J