Sergeonclear

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, October 31, 2007

The art of debugging

Posted on 2:08 AM by Unknown


Software debugging is used to troubleshoot a problem in code.

So what is the best way of debugging?
1. Run through the log statements
2. Start a debug session in your favourite IDE. The session can be remote(for a web app) or local.
3. Narrow down to the problem by reducing the dependencies. Is it because of the framework or your own code, to know that reduce the code and test piece by piece.

Option 2, Debugger is the best arsenal for troubleshooting issues in code. Mixing 1,2 and 3 would be the ultimate way to fix the worst problem.
For details of remote debugging in eclipse please refer to my earlier posts.

In eclipse I find the below things very useful in debugging session:
1. Breakpoints:
1.Put a breakpoint in eclipse. You can also edit the breakpoint properties by right clicking on the breakpoints properties. Here you can put a condition and put S.o.p for quickly identifying the problem
2. Exception breakpoint is a cool feature which will catch the exception which you specify. This will help you find the control flow(especially with nasty Null pointer exceptions). You can specify this by clicking on the "Add Java Exceptions" breakpoint of breakpoints view.

2.If you're running in debug code, you can actually just edit
the method and re-invoke it. None of this resetting variables on the
fly; just save the new method and do 'drop to stack' to get it to
re-run the code.
You can't do this if you're not running your application in eclipse, but are rather joined to it as a remore debugger.

3. Variables can be reset in debugging session through expressions or variables view.

4. Short cuts:
CTRL+SHIFT +I -- to check a variable after selection.
F5, F6, F8

Useful links
Jacoozi - Remote Debugging with Eclipse



Read More
Posted in debugging eclipse tips, The art of debugging | No comments

Monday, October 29, 2007

JNDI test JSP page

Posted on 12:23 AM by Unknown

<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8" import="javax.naming.*" %>
<% InitialContext initialContext = new InitialContext();
Object obj=initialContext.lookup("java:comp/env/jdbc/xmpPubPool");
out.print(obj);
%>
Read More
Posted in JNDI test JSP page | No comments

Thursday, October 25, 2007

Useful Eclipse Plugins + shortcut keys

Posted on 10:19 PM by Unknown
Here is a list of plugins and their usefulness:

  • MyEclipse -- Is a heavy wieght champion among plugins.Has lot of good features that makes it good as well as bulky. It sucks lot of memory.

Swing Tools

  • jigloo -- Very good, clean and free Swing code generator. Makes swing development like VB.

Code Analysis:
  • pmd

Javascript:

  • jsEclipse
  • Teniga_Javascript_Editor

Miscellaneous
  • Mylyn --- Connects to task repository and eases task managemnt.Also standalone support
  • JadClipse --Uses Jad to decompile class

  • jautodoc -- Very useful for quick API documentation.

  • junitBuilder -- Generate Junit automatically for classes..Saves time
  • moreunit - a must have for junit. http://moreunit.sourceforge.net/org.moreunit.updatesite/

  • phpeclipse -- Good for PHP developers.

  • VelocityWebEdit -- Cool velocity template validation and edit tool

  • patternbox -- very useful for building regular expressions quickly.

  • xmlbuddy -- neat small and simple xml editing tool.

  • subclipse --SVN plugin
  • NTail - tail for eclipse http://www.certiv.net/

  • Eclipse HttpClient -- is a Rich HttpClient Plugin with stunning user
    interface and build on top of the famous Apache HttpClient
  • Jar class finder - give a class , it will find the jar where it belongs to.
http://www.alphaworks.ibm.com/tech/jarclassfinder/download
MDA tools/plugins ---These have the ability to generate j2ee code automatically based on model driven architecture
  • andromda

AJAX Plugins

  • aptana

DB Modelling


  • Clay modelling tool DB_Modelling_jp.azzurri.clay

Short Cut keys :
CTRL+E for switching editors.Ctrl + F6 to navigate between the open editors,

CTRL+ F11 for executing last command.
Refactoring
ALT +SHIFT+R --rename variable
ALT + SHIFT + M -- extract method


Indentation

CTRL + I -- correct indentation individually.
CTRL + SHIFT + F -- whole page format.

Creation:
CTRL+ N. I found it much easier to press ALT + E (extend) to add extended class
and ALT + A (add interface) to add interfaces in the new class wizard.
My class will then come out with empty overridden methods and correct
imports.

Search
CTRL+Shift+G, which searches the workspace for references to the selected method or variable. 5 stars.

Agility
F3
Go to a type declaration
CTRL + SHIFT + UP(DOWN) -- move up or down to the next member
CTRL+T on an interface name...This list the implementation of the interface. Very useful. 5 stars
CTRL+. and CTRL+, Move to one problem (i.e.: error, warning) to the next (or previous).

Ctrl-F6 is a great way to jump around between open
editors.
CTRL+F7 to switch views...Verrrry useful
CTRL+F8 to switch perspectives.

Ctrl-O in a class definition brings up Quick Outline.
Start typing a member name and hit return once it’s unambiguous.
Combined with Open Type this is a lightning fast way to go to any
method in any class.ctrl-o ctrl-o to show inherited members too!

Less typing

I think of Quick Fix as a tool for writing code,
not something that just corrects accidental errors. Instead of trying
to type perfect code and using Quick Fix only when you make a mistake,
try intentionally leaving out code, then using Quick Fix to add it in.
For example, call a function that isn’t defined, passing in all
the arguments you want to to take. Use Ctrl-1, Enter to create an empty
version of the function with all the right parameter types. I also like
Quick Fix for creating casts. I assign an expression to a variable
without a cast, then use Quick Fix to add it in.


Instead of declaring a variable and then assiging the value of an expression to it, try just writing the expression, then use Quick Assist – Assign to Field
(Ctrl-2 L) to generate the declaration. The variable name will be
highlighted and the drop down gives you several reasonable alternatives
to use for the variable name. Tab again to get to the type to choose an
alternative. For example if you had new ArrayList<String&gt;() and used Assign to Field you might choose List<String&gt; from the list of type alternatives.

More here : http://eclipse.dzone.com/news/effective-eclipse-shortcut-key

More here : http://rayfd.wordpress.com/2007/05/20/10-eclipse-navigation-shortcuts-every-java-programmer-should-know/

Powered by ScribeFire.

Read More
Posted in Useful Eclipse Plugins eclipse shortcuts keys | No comments

Monday, October 22, 2007

linux tips

Posted on 2:22 AM by Unknown

Tomcat Remote debugging in linux
Put the below in catalina.sh

JPDA_TRANSPORT=dt_socket
JPDA_ADDRESS=5005
$./catalina.sh jpda start
Startup script with logging:
Create a file with the following and change the mode to executable under $catalina_home/bin
./startup.sh;tail -f ../logs/catalina.out

For shutdown create as below:
./shutdown.sh;tail -f ../logs/catalina.out

Restart script for linux:

./shutdown.sh
echo "shutdown.sh executed"
echo "Sleeping for 5 seconds after shutdown"
sleep 5
./startup.sh
echo "starting up"
echo "Sleeping for 1 second"
tail -f ../logs/catalina.out


Jar usage
$cd portal-impl
$jar xvf portal-impl.jar :extracts the jar file into portal-impl dir.
$jar cvf portal-impl-patched.jar portal-impl/ :make jar file from portal-impl dir contents the jar will be having portal-impl as the root dir.

To change ownership:
$chown tomcat:tomcat FILE_NAME

To change group:
$chgrp tomcat FILE_NAME

To Switch user:
$su USER_NAME

Clear all unwanted .SVN files
find . -name ".svn"-exec rm -rf {} \;

Read More
Posted in Tomcat on linux tips commands | No comments

Friday, October 12, 2007

JProfiler - A J2ee profiling tool

Posted on 5:16 AM by Unknown
This is one of the best profiling tools i have seen.
They give a 10 day free evaluation with all feature's enabled.

Setting up the Jprofiler was a little tedious until I came to know how it works.
I was expecting that the Jprofiler would put some custom code in tomcat(like profiler4j) but actually it runs the tomcat in it's own session.

On windows, setup the application with downloaded exe.
Go to New -- Start center -- New Server integraion and you are done.
The app server gets started and log console is available through Jprofiler itself.

Another nice feature of jProfiler is remote connectivity. We can connect to server running in linux from windows.
To do that, install jProfiler on linux as below
rpm -i http://download.ej-technologies.com/jprofiler/jprofiler_linux_5_0_1.rpm
Get the catalina.sh(for tomcat) and give to the start center wizard. Copy back this(jprofiler_startup.sh) to tomcat on linux. Now start the server using jprofiler_startup.sh.

Connect from windows GUI and you are ready for profiling..


The real thing :
Profiling can be done for memory or CPU load. The hot spots are the best ones to quickly find out the problem areas.
Also J2ee components can be easily profiled for JDBC calls, JMS calls,etc.





Powered by ScribeFire.


Read More
Posted in JProfiler setup jprofiler on linux | No comments

Thursday, October 4, 2007

Apache 2.x setup Quick guide for Linux

Posted on 9:20 PM by Unknown

I am herewith trying to log all the issues faced during apache web server setup.
Download apache from http://httpd.apache.org/download.cgi

There you can find either a source or binary.

Normally it is good to compile the source to a OS platform. But it is little extra effort. Setting up using a apache binary is faster but may not be reliable.

Here are basic and advanced steps for apache setup:

To setup , follow these very basic steps to setup apache in it's default location
Extract the apache bundle

1. tar xvf apache.x.tar
2. cd apache.x
3. ./configure
4. make
5. make install
6. cd ./apache/bin
7. ./httpd -k start[stop] # run's on port 80 which is default

Open browser..Go to http://localhost/ #....This should open a page ...It Works!!

To make an advanced setup like configuring additional modules, setup destination,etc , do the following:

1. tar xvf apache.x.tar
2. cd apache.x
3. ./configure --prefix=/path/to/apache --enable-[auth]=shared
4. make
5. make install
6. cd ./apache/bin
7. ./httpd -k start[stop]


Go to ./apache/conf/httpd.conf to change the port or any other setting. Will blog later on httpd.conf .

To have apache use a custom httpd.conf on startup do this :
./httpd -k start -f /custom/conf/httpd-custom.conf

To chek if apache supports DSO, run
./httpd -l # this lists all the modules setup in apache

I have listed a set of modules which were enabled for apache 2.0.59 to run a website on production:

--enable-authn_file=shared --enable-authn_anon=shared --enable-authz_host=shared --enable-log_config=shared --enable-logio=shared --enable-expires=shared --enable-headers=shared --enable-setenvif=shared --enable-mime=shared --enable-status=shared --enable-vhost_alias=shared --enable-dir=shared --enable-alias=shared --enable-rewrite=shared --enable-access=shared --enable-auth=shared --enable-userdir=shared --enable-autoindex=shared --enable-negotiation=shared

There are thousands of directives to be configured in httpd.conf .Refer http://httpd.apache.org/docs/2.2/mod/directives.html for apache 2.2

To change the server port by changing in ./apache/conf/httpd.conf the Listen 80 directive

Virtual host directive : A single apache server can have multiple virtual hosts and can server different sites.

To set this, open ./apache/conf/httpd.conf and enter the directive as below:


<VirtualHost 172.20.41.39:80>
ServerName xyz.com
ServerAlias www.v2.xyz.com v2.xyz.com www.eetonline.com www.xyz.com eetonline.com

DocumentRoot /web/docs/electronics/v3.xyz.com
DirectoryIndex index.html index.htm
ErrorDocument 403 /nopagefound.jhtml
Redirect /uk/motorola http://www.xyznet.com/

<Location "/globalSpec"> # to specifiy the mounted directory to be used
ExpiresActive on
ExpiresDefault "access"
Header append Cache-Control "no-cache"
Header append Expires "Thu, 4 Jan 1990 10:00:01 GMT"
Header append Last-Modified "Tue, Jan 27 2099 23:59:59 GMT"
Header append Pragma "no-cache"
Options FollowSymLinks MultiViews
satisfy any
Order deny,allow
Deny from all
AuthType Basic
AuthName "xyz login"
AuthUserFile /web/admin/apache/etc/auth/xyz.com-globalSpec
require valid-user
</Location>
<VirtualHost>




Read More
Posted in Apache 2.x setup Quick guide for Linux | No comments
Newer Posts Older Posts Home
Subscribe to: Comments (Atom)

Popular Posts

  • LinuxPerformance Tuning(apache,tomcat,linux) and related
    Web profiling -- HTTPAnalyzer -- -- YSlow --CSS,Javascript report , time/size measurement for individual component is good. -- F...
  • (no title)
    Hardware/Software stack:  iPhone 3Gs having iOS 5.1.1(latest as of today).  The Xcdode 4.2 failed to detect this iphone as it has support on...
  • Spring interceptor ordering
    SimpleUrlHandlerMapping uses a hashMap to hold the interceptors. Ordering can only be guaranteed by setting  order property.. By default it ...
  • SVN/ Subversion Tips and traps
    SVN could be tricky and waste a hell lot of time. Case Issue : Normally we run SVN server in linux. Our dev env will be in windows NT. Windo...
  • Liferay CMS/ web content management/ workflow/ staging
    Liferay out of the box has a web content management system. The web pages can mostly have these web content (articles) as web pages. The web...
  • Cobertura- junit coverage tool
    First, you need to add a task definition to the build.xml file. This top-level taskdef element specifies that the cobertura.jar file is i...
  • XSLT caching Transformers
     The usage of cached transformer objects is recommended here A sample implementation of CachingTransformerFactory is here The above code abs...
  • Rewrite rules in apache and IIS
    Well we can control how the server serves stuff to clients by defining rewrite rules. As servers are dumb, its important to explain well abo...
  • Real-Time Tracking and Tuning for Busy Tomcat Servers
    A very nice article which details on possible options for tomcat server monitoring to tweak its performance. http://www.devx.com/Java/Articl...
  • External Javascript from Java Servlets
    Copied from http://myappsecurity.blogspot.com/2007/01 Like to thank anurag for the content. /breaking-same-origin-barrier-of.html External ...

Categories

  • AJAX javascript
  • All about UK Visa HSMP VS H1
  • All about UK Visa HSMP VS H1 hsmp assistance
  • amazon
  • android apps ship control radio hindi
  • Apache 2.x setup Quick guide for Linux
  • apache commons configurator usage
  • apache commons usage
  • arsenals for developers
  • article
  • Batch script to load developer environment
  • Blind folded chess
  • Castor castor convert dtd to xsd
  • cloud comparision price
  • cloud comparison blog
  • cloud computing monthly price
  • cloud usage
  • Cobertura- junit coverage tool
  • Code generators
  • cron jobs expressions
  • cruisecontrol cruise control
  • debugging eclipse tips
  • developer tools
  • document library
  • easy mock jmock vs mocking java tdd
  • External Javascript from Java Servlets
  • fedora 9 lenovo 3000 n200 windows xp dual boot problem
  • Fire fox plugins and tweaks
  • Free PHP hosting
  • gods debris the religion war scott adams dilbert
  • google app engine
  • gwt javascript
  • hibernate second level cache
  • i18n locale localization internationalization spring liferay portlet locale
  • ibatis sybase mapping
  • image gallery
  • iphone apps bri8 apple
  • iphone shsh 3gs ipsw downgrade ifaith tinyumbrella ios5.1.1 to ios5.0
  • java
  • java JDBC
  • javascript junit testing
  • Javascript trouble shooting tool
  • Jboss overview
  • jmeter load testing custom java sampler javasamplerclient xml test
  • JNDI test JSP page
  • Joomla CMS
  • JProfiler setup jprofiler on linux
  • jquery IE AJAX issues
  • jquery spring AJAX
  • keyboard music java typing soothing notes auto suggest
  • liferay kids version
  • liferay web 2.0 java/j2ee
  • linux - the difference between hard and soft links
  • linux mysql
  • linux mysql setup quick start
  • Linux ssh autologin with putty
  • LINUX usefuls
  • linux)
  • LinuxPerformance Tuning(apache
  • log4j setup useful
  • lucene solr
  • mac m701 android skype not working crash
  • maven
  • maven cut reduce build time
  • microsoft ODBC oracle dll connection issues
  • Mobile Ad Services (adwhirl)
  • opsourcecloud
  • oracle connect by hierarchy
  • oracle table previlege
  • Oracle thin vs OCI(type II/thick) drivers
  • pdf 2 text
  • Pega PRPC
  • php
  • rackspacecloud
  • Rewrite rules in apache and IIS
  • scaffold
  • setting up a static ip on SKY broadband
  • setup quick start
  • Single Sign on - OpenSSO with Liferay
  • smart gwt
  • smtp email test mock server james
  • SMTP MAIL telnet windows
  • Software tools mind map freemind j2ee tools
  • Speed typing tips.
  • Spring + Hibernate Usefuls BaseDAOHibernate
  • Spring annotations with spring-mock not working 2.0 2.5.6
  • spring jndi datasource lookup
  • Spring portlet mvc and spring servlet mvc validation
  • Spyware trojan and virus removal tools
  • struts magic
  • SVN/ Subversion Tips and traps
  • tabbed ms dos console cygwin console
  • Texter - An auto text expander autotyper
  • Textpad tricks
  • The art of debugging
  • tomcat
  • Tomcat Exploded war - cut deployment time
  • Tomcat on linux tips
  • Tomcat on linux tips commands
  • TypeIt4Me
  • Typinator
  • Useful Eclipse Plugins
  • Useful Eclipse Plugins eclipse shortcuts keys
  • Useful tools
  • web content
  • xcode cocos2d iphone box2d
  • xpath xml xquery

Blog Archive

  • ►  2013 (19)
    • ►  August (17)
    • ►  July (1)
    • ►  January (1)
  • ►  2012 (7)
    • ►  August (1)
    • ►  June (4)
    • ►  April (2)
  • ►  2011 (20)
    • ►  November (1)
    • ►  October (1)
    • ►  August (1)
    • ►  July (3)
    • ►  June (1)
    • ►  April (2)
    • ►  March (4)
    • ►  February (1)
    • ►  January (6)
  • ►  2010 (27)
    • ►  December (3)
    • ►  July (2)
    • ►  May (3)
    • ►  April (2)
    • ►  March (5)
    • ►  February (10)
    • ►  January (2)
  • ►  2009 (32)
    • ►  December (5)
    • ►  November (2)
    • ►  September (3)
    • ►  August (6)
    • ►  June (4)
    • ►  May (4)
    • ►  April (3)
    • ►  March (2)
    • ►  February (3)
  • ►  2008 (28)
    • ►  December (1)
    • ►  October (2)
    • ►  September (2)
    • ►  August (4)
    • ►  July (7)
    • ►  June (1)
    • ►  April (2)
    • ►  March (2)
    • ►  February (2)
    • ►  January (5)
  • ▼  2007 (24)
    • ►  December (3)
    • ►  November (2)
    • ▼  October (6)
      • The art of debugging
      • JNDI test JSP page
      • Useful Eclipse Plugins + shortcut keys
      • linux tips
      • JProfiler - A J2ee profiling tool
      • Apache 2.x setup Quick guide for Linux
    • ►  September (1)
    • ►  August (3)
    • ►  July (8)
    • ►  June (1)
Powered by Blogger.

About Me

Unknown
View my complete profile