Skip to main content

Bind Exception, Netbeans 6.7.1 and Jetty server running Grails applications

While developing Grails applications on Netbeans IDE 6.7.1, I noticed an issue with the inbuilt servlet container, Jetty that is packaged with Netbeans IDE. Sometimes, Jetty server wouldn't stop even if we stop from the "Services" tab of the Netbeans IDE. It might show that it is already stopped under the "Services" section while it is still running in the background. Any attempts to Run the grails application after this event, will fail. You may get errors saying "Port already in Use" or "Address already in use: bind". The environment is windows/xp/vista. I'm assuming Jetty is using Port 8080 by default. The exception message in the console says "Server failed to start: java.net.BindException"

Run the following command from the command prompt.

netstat -o -n -a | findstr 8080
You may get output as below:

TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 7972

In the above line, the PID(Process Identifier) of the application using this port is 7972.

The second step is to launch the Window Task Manager.
Go To "Processes" tab
If the PID column is not visible - From the menubar of the task manager, Select View -> Select Columns.
We get series of options with checkboxes. Select PID from this list.
Identify the PID matching the process running on Port 8080 and choose "End Process".

On MAC
> lsof -i -P | grep 8080

You may choose to use Kill command to stop the process after identifying the process id using the above command.

Comments

Popular posts from this blog

Grails - cross-field Date validation

Often we run into domain classes with date fields. If the domain class has two datefields, startDate and endDate, and the rule for a valid combination is "endDate to be greater than startDate", how do we handle? I listed below two of the options, either using domain level constraints or using the domain classes. Option 1: Using domain constraints. Let us take a sample Grails Domain class class Student{ String name String school Date startDate Date endDate } Add the following constraints to enforce validation rules where name, school, startDate cannot be blank and endDate if present should be greater than startDate.

Grails - Querying complex associations

Criteria class allows performing complex searches on grails objects. There are number of shortcut methods for performing queries but these methods have limitations in terms of number of conditions used in "where clauses". Traditional sql "joins" are not possible as shown in some of the Grails "Finder" methods shown below. Sample 1: def list = AccountTransaction.findAllByCompanyCodeAndVoucherDateBetween(branch, fromDate, toDate, params) Sample 2: def list = AccountTransaction.findAllByCompanyCodeAndVoucherDateGreaterThanEquals(branch, fromDate, params) Sample 3: def list = AccountTransaction.findAllByCompanyCodeAndTransGroup(branch, group, params) "params" contains attributes related to sorting, paging etc. It is very easy to use finder methods but when you want to filter objects by more conditions we need to look for alternatives. For understanding the relationships used in this sample, I listed the grails domain classes. class TransactionTyp

Implementing advanced sort in Grails

The "list" pages generated by inbuilt scaffolding/template features of grails have pagination and sorting features. However, if the domain object displayed in the list is a nested object having another domain object as a property, you may notice that sort is not enabled for that field. Boiler plate code for the header of the list is shown below. As you would have noticed few columns have sortable columns automatically generated by Grails command, generate-all or generate-views. The properties 'partyAccount' and 'bankAccount' in this sample are domain classes nested in the domain class 'partyTransaction'. We could convert them to sortable columns by using the tag g:sortableColum