Tuesday, November 10, 2015

Solving SQL Developer Missing Cursor

When you are working with SQL developer version 4 and working for some long duration, sometimes the cursor is missing and you can't find the cursor from anywhere. You may thinking of restarting the SQL developer and working again. But it gives more headache as it happens very often.

I am not kidding and solution is click minimize/maximize twice and then you can see the cursor is appearing :)

Small issue and small answer, but will save your time than restarting and starting to work again :)

Thursday, October 8, 2015

Solving the issue of not loading OneToMany eager fetch entities

When you have Hibernate as the JPA provider,sometimes when your JPA entity classes have multiple OneToMany eager fetches, it doesn't load all the entities it has related to in some entity relations. Instead it only loads one entity on some of the relations. I had this problem multiple times during the development of the JPA entity classes.

Even though my preference is to continue according to the pure JPA specification, I couldn't find a fix for the issue using JPA. Finally found a fix by using a Hibernate specific annotation and it didn't arise anymore after putting it along with the JPA annotations. The Hibernate annotation is @Fetch(FetchMode.SELECT) annotation along with JPA @OneToMany annotation.

I found the solution in below link and it has the relevant explanation how it is working.

http://stackoverflow.com/questions/17566304/multiple-fetches-with-eager-type-in-hibernate-with-jpa

Sometimes, you need to bare with these fixes even though you don't like to mix up Hibernate and JPA annotations together.

Fixing Maven Out of Memory issue

When your are issuing maven builds for your projects, it might gives you out of memory issues. Then putting below command on your terminal will keep the headache away from you.
 export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=256m"  


If this is frequently happening, add this setting to your environment variables.

Friday, July 10, 2015

Simple way of sharing a file over HTTP in your local network

During you are working in your office, you might need to share some files with your friends temporarily. You don't need to find a pen drive or scp the files by asking passwords...etc. Below describes a simple way of sharing them over HTTP.

1. Open your terminal

2. Go to the directory you want to share the files

3. Execute the below command

python -m SimpleHTTPServer 8000

4. Then access the files using a browser http://[your_ip_address]:8000

Once the file sharing finished, simply exit the console.

Tuesday, July 7, 2015

Checking out and tracking a remote branch

When you work with GIT, you might have multiple remote branches for various reasons such as to distinguish releases, new feature developments...etc. So, you need to checkout those remote branches and need to track on those.

After pulling from master branch the execute the below command with your remote branch name.


 git checkout --track -b remote_branch_name origin/remote_branch_name  

Push a new local branch to remote and tracking in GIT

This is an easier way of creating a remote feature branch. First you need to create a local branch from master and then push it to the remote and tracking also will get enabled on that.

git checkout master

git pull

git checkout -b feature_branch_name

git push -u origin feature_branch_name

Monday, July 6, 2015

Rolling back Transactions for checked exceptions

If you are a developer of enterprise applications with Java related technologies, then transaction management is a critical area for your enterprise applications. In transaction management, we have container managed transactions(CMT) and bean managed transactions(BMT).

Most of the scenarios, we would like to go ahead with container managed transactions where you need demarcate the methods of your service layer with the transaction attributes. When using container managed transactions, it rollbacks the transactions only for run time exceptions either you used EJB or Spring transactions.

But, there might be some requirements to rollback your transactions for specific checked exceptions as well. Here if you are using EJB CMT, then your specific checked exception class needs to be applied with @ApplicationException(rollback=true) annotation.

But in Spring, the approach is more flexible as you don't need to apply any annotations for exception class. You have more options with the below attributes with roll backing transaction along with the @Transactional annotation.


  1. rollbackForOptional array of exception classes that must cause rollback.
  2. rollbackForClassNameOptional array of names of exception classes that must cause rollback.
  3. noRollbackForOptional array of exception classes that must not cause rollback
  4. noRollbackForClassNameOptional array of names of exception classes that must notcause rollback 

Fixing incorrect HTTPS Port re-direction in Wildfly 8.0 with a Spring secured web application

Due to an operational issue, I had to downgrade the Wildfly 8.2 deployment into a Wildfly 8.0 deployment. Then a strange issue occurred as despite all the correct configurations in place for enabling the Spring security and HTTPS.

Problem was, when incorrect login details entered, redirection URL comes with an incorrect port where it goes with the AWS load balancer's actual port. But with the Wildfly 8.2 it is working correctly as expected.

When searching for a solution, found the below discussion

https://github.com/undertow-io/undertow/pull/125

This where the beauty of Wildfly modules comes into play. Simply I replaced the existing undertow 1.0 (Web implementation of wildfly) to the undertow 1.0.3 in Wildlfy modules and changed it's module xml. So the solution worked perfectly.

Solving 'ORA-01882: timezone region not found' in SQL Developer

Recently I installed latest version of Oracle SQL Developer and got an error when I was trying to connect to a remote database as 'ORA-01882: timezone region not found'. 

Here is the way to fix it. 

  1. Go to the installation directory of Oracle SQL Developer.
  2. Open the file located at: sqldeveloper/bin/sqldeveloper.conf
  3. At the end of file, add the following line: AddVMOption -Duser.timezone=GMT+5.30.