moving on…

Donaldson Company has been around since 1915. Although you’ve probably never heard of it, it’s been quietly dominating the filter industry. With over about 14,000 employees worldwide, and hitting the 2 billion dollar revenue mark last month, it’s clearly a force to be reckoned with. It was a great opportunity to work there. Alas, I’m moving on…

Once I settle in, I’ll talk about the new firm. It’s actually about time. My concentration (technical passion) in college was distributed computing, grid and cloud-based solutions. However, after school Akkam’s Razor lead me in another direction – gainful employment. Anyway, years later, it seems like I might get that chance to work on a reasonably large, scalable, truly distributed solution. I’m definitely looking forward to that, and it doesn’t hurt that my commute will stay under 30 minutes a day (with traffic). 🙂

Posted in General | 3 Comments

httpsessionlistener resolved my session persistence issue

I’ve moved from Resin-3.0 to Tomcat-5.5 for a while now. So far, it’s actually been easier to deploy and run my web applications. However, I started to see some NotSerializableExceptions during shutdowns, and subsequent startups. After some research, it became clear that I was inadvertently storing Spring-proxied items into http sessions. If they still existed during serialization of the current session, Tomcat would complain, being that Tomcat actually expects truly serializable items in its sessions – how dare they 🙂

I knew the item being placed in the http session held a reference to a spring-wrapped DAO (the item’s a data view helper). So, after some cups of coffee it finally came to me: have my custom listener defined in the web.xml, which currently only implements ServletContextListener, also implement HttpSessionListener. With that, I was able clear out the culprit on sessionDestroyed(…). I wish all my technical problems were this straight forward.

Update: Anjan, in response to your question, I’m embedding the web.xml declaration and the actual Listener code. Hope this helps.

web.xml listener declaration


   <!--    Our custom system initializing listener     -->
   <listener>
      <listener-class>com.some.company.SomeInitListener</listener-class>
   </listener>

Listener Implementations


public class SomeInitListener extends BosenInitListener {

	private static final Logger LOG = Logger.getLogger(SomeInitListener.class);

	@Override
	protected void customInitForServlet(ServletContextEvent event) {
		super.customInitForServlet(event);

		ServletContext servletContext = event.getServletContext();
		SomeResourceInitializer resourceInitializer = (SomeResourceInitializer) getBean(servletContext, "resourceInitializer");

		// Make default menus
		String menuConfig = servletContext.getInitParameter(AppConstants.MENU_CONFIG);
		if (null != menuConfig) {
                    ...
		} else {
			LOG.warn("Could not find a menu configuration.");
		}

		resourceInitializer.init();
	}
}

public abstract class BosenInitListener implements ServletContextListener, HttpSessionListener {

	private static final Logger LOG = Logger.getLogger(BosenInitListener.class);

	public final void contextInitialized(final ServletContextEvent event) {
		String servletContextName = event.getServletContext().getServletContextName();
		if (LOG.isInfoEnabled()) {
			LOG.info("Initializing [ " + servletContextName + " ]");
		}

		customInitForServlet(event);

		if (LOG.isInfoEnabled()) {
			LOG.info("Initialized [ " + servletContextName + " ]\n\n");
		}
	}

	public final void contextDestroyed(final ServletContextEvent event) {
		String servletContextName = event.getServletContext().getServletContextName();
		if (LOG.isInfoEnabled()) {
			LOG.info("Destroying [ " + servletContextName + "]");
		}

		customDestroyForServlet(event);

		if (LOG.isInfoEnabled()) {
			LOG.info("Destroyed [ " + servletContextName + "]\n\n");
		}
	}

	protected void customInitForServlet(final ServletContextEvent event) {
		ServletContext servletContext = event.getServletContext();
		String appContextName = WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
		Object webCtxAttribute = servletContext.getAttribute(appContextName);
		if (null != webCtxAttribute) {
			if (webCtxAttribute instanceof Exception) {
				LOG.error(webCtxAttribute);
			}

		} else {
			throw new IllegalStateException("Could not read applicationContext.xml.");
		}
	}

	protected void customDestroyForServlet(final ServletContextEvent event) {
		//no-op
	}

	public final void sessionCreated(final HttpSessionEvent event) {
		String sessionId = event.getSession().getId();
		if (LOG.isDebugEnabled()) {
			LOG.debug("Initializing a new Session [" + sessionId + "]");
		}

		customInitForSession(event);

		if (LOG.isDebugEnabled()) {
			LOG.debug("Initialized a new Session [" + sessionId + "]");
		}
	}

	public final void sessionDestroyed(final HttpSessionEvent event) {
		String sessionId = event.getSession().getId();
		if (LOG.isDebugEnabled()) {
			LOG.debug("Destroying an existing Session [" + sessionId + "]");
		}

		customDestroyForSession(event);

		if (LOG.isDebugEnabled()) {
			LOG.debug("Destroyed an existing Session [" + sessionId + "]\n\n");
		}
	}

	protected void customInitForSession(final HttpSessionEvent event) {
		//no-op
	}

	protected void customDestroyForSession(final HttpSessionEvent event) {
		HttpSession session = event.getSession();
		session.removeValue(BosenConstants.SESSION_PAGINATED_SEARCH_RESULTS);
		session.removeAttribute(BosenConstants.SESSION_PAGINATED_SEARCH_RESULTS);
	}

	protected static ApplicationContext getApplicationContext(ServletContext servletContext) {
		String appContextName = WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;
		return (ApplicationContext) servletContext.getAttribute(appContextName);
	}

	protected static Object getBean(ServletContext servletContext, String name) {
		return getApplicationContext(servletContext).getBean(name);
	}

Posted in Technical stuff | 2 Comments

new york cares…

If you know me, you know I love NYC. Anyway, there’s this song I keep hearing when I listen to the Radiohead radio station on Yahoo’s music engine: Interpol’s NYC (New York Cares). The lyrics are simple, but like a Beth Orton, it leaves a strong image in your mind. Maybe because I’ve taken the subway for majority of my early youth, who knows. Thought I’d share their video with you.

Posted in General | Leave a comment

greatest generation…

So, wait, what? Julia Child was a spy?! Outrageous, but true. This spy organization was the predecessor to the CIA, formed by president FDR. The spy list includes over 24,000 Americans. Like Mrs. Child, there are a ton who you’d never guess. Well, true patriotism requires that kind of spirit. I’m not calling her Patrick Henry, but she did something.

In contrast, today you have celebrities wearing vote or die t-shirts, but forgetting (?) to actually vote. Disgusting. In comparison to my facebooked and youtubed generation, how can you argue with the Greatest Generation title.

Posted in Politics | Leave a comment

yeah, that’s probably it…

Posted in Funny | Leave a comment

wonderflonium…

It’s always good to see something funny; even more so if it’s original. Well, as a result of the writer’s strike not too long ago, Josh Whedon and Neil Patrick Harris teamed up to make this hilarious 3-act story, Dr Horrible’s Sing-Along Blog. Basically it’s about a super villan named Dr. Horrible who wants to be part of the Evil League of Evil. For the most part, he’s smart and could do some real damage if it wasn’t for his love of this real humane woman, and ohh, that fact he blogs his upcoming actions.

Yeah, the video blogging of your future crimes makes it a bit harder to commit them… You also learn some great new chemical elements, like Wonderflonium. It’s just funny.

Posted in Funny | 6 Comments

a great man…

July 18th was Nelson Mandela’s 90th birthday. He’s definitely on the short list of true, living legends. Not because he’s a saint; no, most men aren’t. Rather for his life-long struggle to end apartheid in South Africa. Then to further that goal throughout the world. Sadly, few know of Mandela’s journey from civil rights activist, to leader of his homeland.

For a moment, imagine wanting freedom and equality in your homeland. Yet, because of colonial rule, it being unlawful. Yes, during his leadership of the ANC (which was banned), guerrilla warfare was used. He was tried and imprisoned for almost three decades. Most men would have either given up, but this man persevered.

After years of international pressure, in 1990, de Klerk and the South African government gave in. In 1993, Mandela and de Klerk earned shared Nobel Peace Prize. In 1994, Mandela like his great-grandfather Ngubengcuka, became ruler of South Africa. It should be noted that he made National Party’s de Klerk his first deputy. This was the first truly multiracial South African government.

Admittedly, Mandela stood on the shoulders of giants. But anyone can see, in his own right, he is truly a great man.

Posted in Politics | Leave a comment

Chuck Norris plus Java

James Sugrue submitted a nice “Chuck Norris” list relating to Java, on the DZone. Some of these are pretty funny. Check it out.

Posted in Funny | Leave a comment

hey google, what is that?

So, as usual checking my Gmail account waiting on a few responses, and I see this odd thing in the top left corner. I can’t figure it out; it makes no sense. At first I think it’s a phantom, or lazy bit. I refresh a few the page times – look at the page’s source – still nothing jumps out me.

Looks like the bent corner of a page… Anyway, I decided to take a snapshot and simply ask if anyone else has noticed this? Better yet, do you know what it is?

gmail artifact

Update: Someone on Digg brought it up, and as it turns out Google is aware of it, and is fixing it. I was under the impression that they purposefully did this. Oh well. Thanks Brian M.

TechCrunhIT speaks on it too. – Thanks Jason C.

Posted in General | 1 Comment

cream of the crop…

William C. Taylor gives and interview that talks about Zappos.com. On interesting item is how they find the true cream of the crop… I think I really like it.

Posted in General | Leave a comment