How to run IBatis in GlassFish

IBatis runs just fine in Sun Java System Application Server however
GlassFish has a new feature: on-demand initialization.
This is a good feature however since I create IBatis SqlMapClient in
static constructor IBatis throws exception. Resources class
that I use can’t find IBatis configuration in classpath.

Finally I learn the change needed to run IBatis in GlassFish.
Create Ibatis SqlMapClient in your servlet class.
You also need to set the default class loader of IBatis Resources
class to your servlet class.

Resources.setDefaultClassLoader(this.getClass().getClassLoader());

After this small change IBatis runs just fine in GlassFish

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s