Thursday, September 2, 2010

HELIOS with GlassFish3 and JEE6

Helios is the lastest version (3.6) of Java IDE from Eclipse, the opensource Java Integrated Development Environment.

By default Helios is packaged with many Enterprise Application Servers and Web Servlet Container servers, such as Apache Tomcat, but not yet with GlassFish V3 server.

To install Glassfishv3 support in the IDE, just do the following:

1) Add a Repository by going to Help\Install New Software
2) In the Available Software, Workwith text box, click the Add button
3) On the popup Add Repository dialog box, enter a name 'GlassFish Plugin Repo' and for the location url: http://download.java.net/glassfish/eclipse/helios


4) In the next screen, select a location in your local, where to install the GlassFish server.

Saturday, June 19, 2010

What other sports I am interested in doing ?

Currnet Rank(most1, least 10)
Sports/Activities
Running 1
Biking 2
Swimming 3
Soccer 4
Fishing 5
Camping 6

Sports
Interested: Rank(most1, least 10)
Scuba 1
Sailing 2
Golf 3
Flying 4

Second Injury

June 8, 2010: It is my first biking day after my hamstring pop recovery. The Thursday before this, I took a spinning class session to make sure I can do atleast 80% of my usual level of spinning and biking. And I realised that I am good to go an this Tuesday. So I pickup a time after my work, and the Washington Old Domenion Trail near Ashburn. The first 15 minutes, I take it very slow and decided to go next 15 minutes a little faster but under 10 miles an hr. Then the weard thing happened. I was not feeling sure of myself, weather I am doing it right or wrong. I was in almost the center of the trail. Ans I realised a runner running towards me in the next 100 years and so I slowed my bike then suddenly someone from behing the runner on a bike, trying to get passt the runner, on his process got into my way. And my muscle memory applied the brakes. But the problem is that the memory is from very very long time ago, where the driving is on the left side, and the left handle breake was the back brake and right handle brake was the front wheel.


You would have immagined correctly, I applied the front brakes more than the back and it send me over my handles. I realised I am air borne going over the habdle bars in slow motion while I am trying to stay back in my saddle. In a fraction of seconds I am on my both knees and right shoulder meeting the ashpault paved trail. My helmet took a secondary hit and my cheek in a mirracle missed a scrape, but I can feel the burn sensation. Luckiely its not a crash. My bike was still ridable after this. After about 45 minutes with my doctor office, I am cleared to go home with bandages on my knees and shoulder after checking with my records that my last letanus shot in 2008 is still good.

On my way home, I was checking my equipments and found my left hand glove missing a dime size of its materials. And my both shoes showed some type of scrapes and fabric tear, showing that without these equipments I would have received more scrapes in my arm and legs.

Even though this would have delayed my training towards the annual running competion, I am happy that the injury is minor and recoverable in time. And no fractures.

Wednesday, May 19, 2010

Sports Injury (Calf muscle)

I coach a youth Soccer team. We practice on Monday and Wednesdays. Today during my practice session, I was tackling a soccer ball in the mid full back position and dribbled fast moving the ball away from the penalty kick area towards right wing. Then I felt a pop in the calf muscle and first thought I was hit by a stone or rock in my calf and next thing I could n't move my right leg. I realized then that I have injured my calf muscle. I was able to move my toe so I managed to limp to my car and then started driving home. I could fee a numb pain in the calf but not bad as before. As soon as I get home, I had some banana, and a glass of milk and took a mild hot shower and then I began to settled down in front of the computer to search about the calf muscle injury. Since its already past 9 pm I decided to get a doctor appointment first thing in the morning if the condition worsens. Mean while I will take rest and continue applying the ice and compression if necessary. So far I have not taken any pain killer or antihistamine tablets.

During my search, I come across these useful link of Chadwick torn calf muscle page http://www.wachs.org/node/24 and the link in his page to http://sportsmedicine.about.com/od/legpainandinjuries/a/calf-strain.htm also helpful.

And I wish I need not to go to this procedure described in this page http://www.conquestchronicles.com/pages/The_Achilles_Tendon_Injury. And I hope I need not to call my manager tomorrow to tell her that I stay home due to the injury. I hate to take day off unless its absolutely necessary.

Sunday, November 15, 2009

Solution to SunTechDays Java Persisitence problem

I am a fan of Arun Gupta's technical screencast on various J2EE subjects and API. Recently I was looking for a Ajax wiring to a mashup and I turned to Arun Gupta's Screencast #Web7: Creating Mashups with jMaki - A real-life RIA using jMaki (Sun Tech Days Event Map) at http://blogs.sun.com/arungupta/entry/sun_tech_days_event_map. Which very well describe about how to setup widgets from various toolkits in jMaki in NetBeans IDE. Well I was very much sure thats what I am looking for and I started to setup a test environment quickly to test out the tutorial. Unfortunately that didn't fly well and was keep getting issue with JPA issues. I tried various tests everyting points to the JPA (Java Persistence API). So I dwell deeper in to JPA and learned quickly that Netbeans by default ship with TopLink JPA for Derby database.

So I realised that we need a Servlet to complete the JPA. And I put up this simple servlet and vol ah, that resolve the issue. Like a silver bullet. So I present her the missing part in the tutorial. Hope this helps you..

I create a servlet in the SunTechDays project under a package suntech.servlet. I named my servlet servletdata.java. Once the IDE create the servlet and open it in the editor, right mouse click and select persistence and click Use Entity Manager. This will inject the PersistenceContext in the class.
@PersistenceContext(name = "persistence/LogicalName", unitName = "SunTechDaysPU")

and it will add this annotation resource for managing transaction boundaries:

@Resource
private javax.transaction.UserTransaction utx;

If you look little down, you will find that a default persist method has also been added, which looks like this...

private void persist(Object object) {
try {
Context ctx = (Context) new javax.naming.InitialContext().lookup("java:comp/env");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("persistence/LogicalName");
em.persist(object);
utx.commit();
} catch(Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE,"exception caught", e);
throw new RuntimeException(e);
}
}


just modify the above code to look like this:
public TechdaysSchedule findByMonth(Date startDate) {
TechdaysSchedule schedule = null;
try {
Context ctx = (Context) new InitialContext().lookup("java:comp/env");
utx.begin();
EntityManager em = (EntityManager) ctx.lookup("persistence/LogicalName");
schedule = em.find(TechdaysSchedule.class, startDate);
utx.commit();
} catch (Exception e) {
Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", e);
throw new RuntimeException(e);
}
return schedule;
}


And make sure you import java.util.Date; in the beginning of the servlet.
What I have done here is replaced the scope from private to public and replaced void with TechdaysSchedule. Replaced default persist method with the findByMonth and the parameter object with Date startDate. Then I initialize a schedule variable to TechdaysSchedule and set a value to schedule using this em.find(TechdaysSchedule.class, startDate) and I return the value of schedule. Thats it.

Hope this works for you and if any issue please post a response to this blogg...