Wednesday Jul 23, 2008

Issues while Connecting GlassFish and MySQL (Netbeans 6.1)

I downloaded the Netbeans 6.1 which was bundled with GlassFish v2 UR 2 and MySQL 5.0 
Community Server and was playing around with it. I created a simple JSP with a dropdown. 
This dropdown has values populated from a table.  

When I ran this, I got the following error - 

RAR5038:Unexpected exception while creating resource for pool mysqlPool. Exception 
: No PasswordCredential found
RAR5117 : Failed to obtain/create connection from connection pool [ mysqlPool ]. 
Reason : No PasswordCredential found
RAR5114 : Error allocating connection : [Error in allocating a connection. 
Cause: No PasswordCredential found]
WebModule[/WebApplication1]java.sql.SQLException: Error in allocating a connection. 
Cause: No PasswordCredential found
java.lang.RuntimeException: java.sql.SQLException: Error in allocating a connection. 
Cause: No PasswordCredential found

I opened up the Admin console of the GlassFish and tied to ping 
(Resources -> JDBC ->Connection Pools -> mysqlPool )

It threw a “No passwordCredentials found” error. As expected.

Then, I moved on to the “Additional properties” and tried adding password as a new property. 
I set the “Password” property to have a blank value as during installation of MySQL, I let the default 
password be(which was a blank password). This seemed to be a mistake, because it is not possible to add 
“Password” as a new property and set the value to be blank.

Thus, I logged into MySQL and set the password - 

C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin>mysql -u root mysql
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 18
Server version: 5.0.51a-community-nt MySQL Community Edition (GPL)

Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.

mysql> SET PASSWORD FOR root@localhost=PASSWORD('newpassword');
Query OK, 0 rows affected (0.23 sec)

After this, added the new password in Admin console.I clicked on “Save” both in the “additional properties” 
page and also in the “General” page. 

I tried pinging now, and it worked fine. However, when I ran the application, it threw a 
“NoPasswordCredentials found” exception again.

I logged into “Admin Console” again, but could not find the “Password” property I had set. 
I tried a few times, but the password property kept disappearing. 

I tried a lot of things – restarting GlassFish/creating a new JDBC resources and new connection 
pool/ changing the property files....nothing worked.

I had to create a new web application project to solve this problem.  

Friday Jul 04, 2008

Performance improvements in J2SE 6

One of the principal design centers of J2SE 6(Mustang) was to yield improved performance and scalability. This has been brought about mostly by the improved runtime performance optimization, a better garbage collection and some client side features.

The runtime performance optimization includes implementation of biased locking, lock coarsening, adaptive spinning, larger page heap support, background compilation and the new registry allocation algorithm.

Biased locking is where the expense of obtaining and releasing an objects lock can be avoided when not necessary. This is based on the fact that most of the synchronized blocks are never contested. Also, the synchronized blocks are accessed by only one thread in their entire lifetime. In this scenario, obtaining and releasing a lock by the same thread again and again is simply a waste of resource. Thus the concept of biased locking. The synchronized blocks are made biased towards the thread that accesses the lock first. Any other time the same thread tries the enter the synchronized block, it does not need to acquire the lock again. However, if any other thread accesses the block, a reversal of the biasing needs to be done, which is again expensive. The benefit of the elimination of atomic operations must exceed the penalty of revocation for this optimization to be profitable.

Lock coarsening is applied in a situation where no noticeable operation is performed between a lock release and lock reacquire. For example, consider a piece of code where a few objects are added to a vector consecutively. Here, each statement acquires the vector lock and releases it. This is a waste of resource. The compiler can observe that there is a sequence of adjacent blocks that operate on the same lock, and merge them into a single block. Not only does the locking overhead reduce, but it becomes one single synchronized block.

Adaptive spinning occurs when a thread tries to access a synchronized block, but does not get the lock. In this situation, the thread start spinning instead of going for an expensive context switching. The amount of time for which the thread spins is adaptive. It depends on factors like the recent spin success/failure, the state of current lock owner etc.

Support for large page heaps are also supported in J2SE 6. This helps avoid costly Translation-Lookaside Buffer (TLB) misses to enable memory-intensive applications to perform better. However, on the downside, the large page heaps can significantly slow down the system, or cause excessive paging in other applications that are running in the system.

Also, background compilation is now enabled in the Java SE 6 HotSpot client compiler. Which means, the hyperthreaded and multi-processing systems could take advantage of spare CPU cycles to optimize Java code execution speed.

On the client side, there has been a significant improvement in the Swing performance. The popular “Gray Rect” problem(That is, when a Swing based application is exposed after being hidden by another application, there is a noticeable delay between the background of the window disappearing and the Swing contents being painted.) has been fixed. This problem was fixed by introducing the double buffering support to Swings. That is, an off-screen image is always kept in sync with the on-screen image. When the Swing application is exposed, the copying is done directly from the off-screen image.

Further, the Java Virtual Machine's boot and extension class loaders have been enhanced to improve the cold-start time of Java applications.

One key feature added to the Java SE 6 HotSpot VM is the integration of DTrace provider.

DTrace is a dynamic troubleshooting and analysis tool first introduced in Solaris 10 and Open Solaris. It can be used to debug software bugs, observe devices (like network or disk activity), observe applications and capture profiling data for performance analysis.

The DTrace provider makes available numerous probes that can be used to monitor JVM internal state and activities as well as the Java application that is running. A few of the probes are the VM Life Cycle probe, Thread Life Cycle probe, Garbage collection probe and the Class Loading probe.

Another key features of J2SE 6 is the implementation of StAX(Streaming API for XML) – a bi-directional API for reading and writing XML. It is based on the mechanism of “pull parsing”, which combines the ease of use of DOM parser with the efficiency of the SAX parser. In Java SE 6, SJSXP(Sun Java Streaming XML Parser) is the default implementation of StAX.

Wednesday Jun 11, 2008

Analyzing data with dim_STAT

dim_STAT is a tool used for monitoring and performing a detailed performance analysis of Solaris/Linux systems .

Overview of dim_STAT :

Let us suppose a number of Solaris and Linux machines need to be monitored in a multi host environment. dim_STAT is a good utility which could be used in this situation.

dim_STAT contains various components like MySQL database, Webserver, WebX tool, STAT-service etc. The working of the various components are described below -

The STAT-service daemon(client) need to run on all the hosts. This daemon will gather data by running various services like vmstat, iostat and netstat on the hosts. Collectors could be started via a Web browser to communicate with the clients.

These collectors will then feed the collected data into the MySQL database. This data will then be analyzed using the WebX tool. The WebX tool can give its analysis in various forms like table, text, graphs etc.

The WebX tool is actually a CGI which is hosted on top of a webserver. The MySQL database, the webserver and the WebX will be installed during the installation of dim_STAT. Further, the MySQL and the webserver will be started when dim_STAT is started.

The data loaded in the MySQL could either be the data collected during an online monitoring or could be the data which was previously collected. Previously collected data could be stored in the form of a tar.Z file and can be used later for data analysis.

dim_STAT installation

The latest dim_STAT could be downloaded from (dim_STAT.tar)

After an untar, go into the dim_STAT-INSTALL directory and run as the root. Enter the various parameters asked. These parameters are used for installing WebServer and MySQL. The default parameters should work.

The /apps is the default dim_STAT home directory and /apps/ADMIN contains all the administration scripts.

You can then start the dim_STAT by using the following commands -

# cd /apps/ADMIN 
# dim_STAT-Server start

To stop servers:

# cd /apps/ADMIN 
# dim_STAT-Server stop
Loading data

Just after installation, dim_STAT will provide a link in the output to access the “Home Page” of dim_STAT.

The “Home Page” looks like this -

Now, click on the “Welcome” link. Note that a link to a complete user guide is given just below the “Welcome” link.

The “Welcome Page” looks like this -

If you want to do online monitoring of the data, click on the “Start New Collect” link. Enter the information to start a new collect on the host named localhost. Click the “Continue” button to move to the next screen. Select the monitoring options of your choice (for example: vmstat, iostat, netstat). Finally click the “Start STAT(s) Collect Now!!!” button to start monitoring.

If you need to analyze a previously collected data, in the “Welcome Page”, click on “Restore Collects from tar.Z”.

Upload the tar.Z file and click on “Restore”. dim_STAT will unzip/untar the file supplied. It will also logically group the files according to the various runs and display them. The runs that need to be analyzed should be chosen and restored. This will load the corresponding data into MySQL.

Changing the database

By default, the database created for storing the data is dim. If you want to create another database for storing the data, click on “Preferences” link on the “Welcome Page”.

In this page, you can create a new database and set any existing database as the default.

The current (working) database name is always present in every dim_STAT window as “Database : [db-name]”.

Analyzing the data:

To start analyzing the data loaded, click on the “Analyze” button on the “Welcome Page”.

You could either do a “Multi-Host Analyze” or a “Single Host Analyze”. The single host is described below

Select “Single-Host Analyze” and click on the “Analyze” button to proceed to the next screen.

Choose the log file you want to analyze and click on the monitoring option of your choice. Eg : let us suppose we click on psSTAT.

Click on the corresponding user and the process name. The “Interval” section gives a choice to select the exact time period that we need to be monitored. In the “Graphics” section, you can choose if you want an applet or a PNG image as the output. The background color and the size of the image could also be modified as needed.

Then, click on the various values that need to be analyzed (eg : CPU%, MEM%) and click on “Start”.

A sample graph is given below -

Thursday Sep 13, 2007

Saigon - A treat to your senses!!

Friday night and we were still driving around. We just could not seem to find a place to eat!! Either the parking was full or we dint have reservations.

As we were near Church Street, we remembered a friend of us suggesting a place called as “Saigon”.

So we thought we could give it a try! But as we approached it(it is right in the middle of Church Street), I was not so sure about our decision. I was kind of sceptical about it – it dint look much from the outside. As my husband was on the phone and carried on the conversation while walking into the restaurant, I had no means to stop him.

But as soon I entered this place, I was impressed. The awesome décor combined with the perfect lighting and the pleasing music immediately put me at ease.

As soon as we sat down, we were served with an appetizer (this was on the house!!). The plate contained a few lettuce leaves, red chillis, peanuts, ginger, small orange pieces, finely cut coconut and a semi solid sweet mix. We were supposed to coat the leaf with the sweet mix, put all the ingredients on top of it, roll it like a pan and have it!! It was amazing!! A perfect beginning....

Moving on the main course, I dont want to say much except that it was excellent!!

They had this novel idea of putting the items in a glass tray and displaying it to the guest. One glass tray has lobster, fish, crab etc. We could choose what we wanted cooked for our meal. And another glass tray contained the desserts. Maybe this was just to lure sweet tooths!!

Another point worth mentioning was the service. It was par excellence!! I never have experienced such a service ever before. The waiter answered all our questions with a smile and even made suggestions when we asked for them.

At one point, the waiter who served us, asked me to try out a few grams which came along with the noodles. It tasted too bland!! When I told him so, he just smiled and left. Later, while ordering dessert, I thought I will skip it as I was already full. However, the waiter presented me with a dessert, a dish made of coconut syrup, saying “I hope you like this, ma'am. It is on the house! ” I tasted it and it was a real treat!! I suddenly found more room in my stomach...:-)

On the whole, it was great food and a great experience!! A bit expensive, but it was worth every cent!!

Wednesday Apr 25, 2007

Review of "Tuesdays with Morrie"

I got this book as a bday gift. I was quite skeptical about this one. But I started reading it anyway. The book suprised me. It was such a refreshing read.

It is the true story of a Sesame Street graduate and Brandeis University sociology professor,  Morrie Schwartz and his relationship with student Mitch Albom(the author). The book talks about a few important life lessons that Mitch learns from his professor, who is dying from Amyotrophic Lateral Sclerosis (ALS).

Mitch, though successful, has his priorites all mixed up. The book is about how Morrie(his professor) sets them straight. They talk about love, family, work and so many more important things. It gives us a special insight about how Morrie feels when death stares right in his face.

But the best part lies in the fact that such complex things have been described in such a simple, down-to-earth manner. The beauty lies in its simplicity.

It brings back memories of my college days. I had a prof., Mrs. Angelina Geetha, who guided me not just during my college days, but also after. She has seen me though a lot of my problems with her abundant common sense and her helping tendency. I still remember the lessons she imparted me. (Nope! Not the classroom ones!)

The book as been on the New York Times bestseller list for four years now. If you still have not read the book, you should...

Friday Apr 20, 2007

Sun's Worldwide Volunteer Week - "Inclusion – Children of Spastics Society" event

This week marked the Sun's 13th annual Worldwide Volunteer Week. With over 30 global volunteer projects conducted, employees joined their local communities to contribute time and energy in a company-wide effort to create opportunities that drive participation, economic growth, and social progress.

I took part in a project which was named as "Inclusion – Children of Spastics Society" event. This event had 30 specially-abled children from the spastics society visiting us for a day (19th April, 2007)

The day started with a ice-breaking event - "passing the ball". The idea was to have the kids pass the ball among themselves as long as the music plays. When the music stops, the person with the ball steps forward and introduces himself/herself. They were encouraged to demonstrate any special talent they had. Though a bit shy initially, the kids caught along and expressed themselves more freely. The volunteers cheering in the background helped them come out of their shell more easily.

We then moved on to a painting competition. The kids were split into groups of 4-5. Each group were helped by one or two volunteers. The general theme was "Celebrating 25 years". Coincidentally, both Sun and the Spastics society are celebrating their 25th anniversary this year. The talent displayed by the kids were amazing.

Post lunch, we had a magic show by Magician Satish Kumar. Satish soon became very popular with the kids. Not just the kids, but we volunteers too were totally astounded by the show.

Simultaneously, we also had a person to draw the caricature of all the kids. This was one of the item in the goodies bag along with chocolates and a Sun cap, which was distributed at the end of the day.

The kids had a really lovely time. It was so evident from their happy faces. A few of them got hooked to FoozeBall too. (We played a few games during the lunch session). But it would not be fair to stop with that! We volunteers had such a great time with these kids. A few of us as planning to visit them at their school in the nearby future.

Kudos to Sun and Sun volunteers for organizing this event and making it a grand success.

Thursday Mar 08, 2007

Bitten by the blog bug

Blogs, blogs and blogs, I have been bitten by the blog bug too.....Hoping to stay that way!!

Now for a little intro - Have been working with the Java Enterprise System Integration team for a little over a couple of years now. It has been pretty interesting here....What we do is - take most of Sun's middle ware products, stack it up, build an installer around it and deliver it as a single product. You could download the product from here. For those customers who are not interested in the entire stack and who think a subset would work just fine for them, we have got suites. Suites contain logically grouped subsets of the entire stack.

Ok, leaving Java ES alone for now. I would probably talk more about it in my upcoming entries.



« August 2016