Saturday, October 24, 2009

Eclipse debugging does not stop at breakpoint

I have been experiencing this issue in many earlier versions of Eclipse (3.3, 3.4) and also in current version (3.5 Galileo). Till a point, the eclipse debugger stops at breakpoint but after that it does not stop. There has been no pattern for this. Earlier I thought that this behaviour was due to certain code that involves creating java classes and jar at runtime or probably running ant script at runtime. However then I noticed that there is no pattern for this and it can happen on any code. However I have seen that this occurs only on debugging large code.

Steps to fix

Open the Debug configuration window for the java class youa re debugging and specify the following in JVM arguments text area

-XX:+UseParallelGC

References:

http://ubuntuforums.org/showthread.php?t=1147960

Thursday, September 17, 2009

How to find which application is using port 80 on Windows

I wanted to install Apache Http Server but after the installation, it gave error that it is not able to run on port 80 as it was already being used by some other application. Using the following procedure, I came to know that Skype is using port 80 and its not IIS that I had initially thought of.

Procedure to find which application is using port 80:

  1. Open command prompt using "cmd" on Run window
  2. Type - netstat -ano findstr '80' - If this command does not yield anything use command - netstat -o
  3. It will give you a list of in which last column would contain the process id that is using the port. Normally you get something like this when you run this command -
    Proto Local Address Foreign Address State PID
    TCP pcx61s:http localhost:3376 ESTABLISHED 5288
  4. Thus now you know that process id - 5288 is using your port 80.
  5. Open windows Task Manager and see which application has the process id. By default, the process id column is not visible in Task manager. You can add the column using Windows Task Manager >> View >> Select Columns and select PID (Process Identifier) checkbox and click OK.

How to change Glassfish server default 8080 port in Windows

Very simple steps
  1. Open (in notepad or other text editor) domain.xml located in /glassfish/domains/domain1/config folder.
  2. Search for 8080 (there should be one occurance only ideally)
  3. Change it to 80 or 8088 or 8090 - whatever port no. you like and start the server.
  4. There is no step 4 :-)

All your calls to glassfish server now do not require 8080 in your url. This should work same on other platforms as well though I have not tested it. This way you should be able to change glassfish server other ports as well.

Thursday, September 10, 2009

Use of right join in Hibernate

Consider the following scenario where Company table has a foreign key pointing to CompanyType table and ContactPerson has a foreign key pointing to Company table.

ContactPerson –> Company –> CompanyType

In this case I want to get list of all companies with their company type name (rather than id) and name of employee. It doesn’t matter if there is any contact person available for the company or not. I at least should get the company details.

Now if you write an sql statement using left join, we would definitely get list of all companies. However with Hibernate, writing the hql statement using left join might not yield you the desired results and hence you need to use the right join as in the following example.

select
company.id as ID,
companytype.type as TYPE,
company.name as COMPNAME,
company.url as URL,
company.address as ADDRESS,
company.phone as PHONE,
contactperson.name as CONTACTPERSONNAME
from
hs.pojo.db.Companytype as companytype,
hs.pojo.db.contactperson as contactperson
right outer join
contactperson.comp as company
where
companytype.id <16 and
companytype.id >4 and
company.closed = 0 and
companytype.id = company.companytype

Monday, August 31, 2009

Create a new SVN project / repository

The steps given worked fine on Mac. However same commands should also work on Windows or other environments.

Step 1: Create a repository using svnadmin by using the following command

svnadmin create /Volumes/DATA/repos/svn/NewProject

where NewProject is the name of new project on svn and /Volumes/DATA/repos/svn/ is the path containing all other SVN projects

Step 2: Give apache user rights for this folder so that new folders / files can be committed to this project. Use the following command

sudo chown -R www /Volumes/DATA/repos/svn/NewProject

where www is apache user name

Note that sudo is used only on Mac and Linux system. You do not require it on Windows.

Alas, your new project is ready to be used. As a good practice, each project should contain three folders – trunk, branches and tags. To know more about them, google them.