Archive for the ‘j2ee’ Category

This is one of these notes to self that I keep writing on the blog…

Add the following java options when launching an application (or application server) to get a dump if the application throws an OutOfMemoryException

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/where/to/write/the/dump

We are using this on out local and development servers at work, and then using Eclipse MAT to diagnose the cause.

So far, it is been a pleasure working with MAT. We are maintaining some legacy web application which occasionally crashes due to OOM, so we took a dump and fed it to MAT.

Despite of my attempts to look at the wrong places (since we got OOM) on a webservice, MAT kept showing me our real memory problem until I understood it. The exception on the webservice was only collateral damage… most of the memory was being used in the tests run before the actual crash.

Now we save more than 2.5Mb on each http session, since it turned out that the application was caching too much, too many times (on every session, instead of sharing the data at the application level).

I’m happy :-)

If you need to configure a server-managed datasource for testing your webapp, and you happen to be using Eclipse WTP, this is what you need to do.

  1. Have your server definitions on the workspace.
  2. Deploy your app to the server.
  3. Open server.xml and find the application’s <Context>
  4. Nest your datasource definition inside the <Context>

If you need any other kind of <Resource> configured in your tomcat, you can proceed in the same way.

Buying books

I’ve just received my books from Amazon. Given the discount they make and the current exchange rate between dollars and euros, I find it more comfortable and cheaper (even including the shipment fees) to buy them online. There is also a very good bookstore in Madrid which usually has the books I’m looking for, but they are more expensive, so I rarely buy there unless I want the book “now”.

My new books, with the mac.

My new books!

I already own a copy of the previous editions of Spring in Action and Hibernate in Action (er… Java Persistence with Hibernate) so I’ll probably just keep them near for reference (although the chapters on JPA and WebFlow look promising).

Then there is Design Patterns… my all-time favorite book since I used it during my faculty years. It’s not only the excellent content. The book itself is elegantly designed and it is just nice to browse. I always wanted a copy of this book and now I have it.

I also bought a couple of books about J2EE architecture: The study guide for the sun certification exam and the Architect’s Handbook.

After going through the self-evaluation questions, I find sun’s certification quite easy to pass after more than four years trolling with Java and other technologies. But I think it would have been easy even without so much experience, because almost all of the subjects where covered during my last year at the Computer Science Faculty in the University of A Coruña (thanks to my teacher Fernando Bellas, who also mentored my final year dissertation… we even published a couple of papers, one of them on the ACM Proceedings of the Thirteenth International World Wide Web Conference 2004).

By the way… someone at FIC should explain the students the huge difference it makes studying there compared to other faculties. I’ve recently taught an introduction to J2EE development for web applications (nothing fancy, only the basics on html/css/javascript, JSP/JSTL/Struts and JDBC) for people who have just graduated on Computer Science, and I was surprised by the little background students have on these technologies or anything related (like .NET).

But I digress… back to the books.

The last one, J2EE Architect’s Handbook looks promising. It begins with an explanation of the different roles in software development which spans several pages. This is great because with my background working on a small startup (where roles are fuzzy in the best case) and now in a consulting firm where your role is mostly a function of what your salary is, and not of what you do, I have all those roles a bit mixed up. The author is also quite pragmatic, explaining both the Rational Unified Process and Agile Development… and making a choice somewhere in between.

That’s what I’ve got after quickly browsing the first chapter, but I’ll write back once I finish the book.

By the way, if you’re interesting on those books… here is a link to my library.

The new release of Eclipse has been out for a couple of days. The changes included in the release look great!

However, the default install comes with an error in the configuration which will prevent the installation of new plug-ins through the update manager.

The message I’m seeing is:

Java Persistence API Tools (1.0.0.v200706250000-77–CYQCCz-CoRPCCCH) requires feature “org.eclipse.datatools.enablement.feature”.

To fix that, go to the update manager and grab from the Europa Discovery Site the features:

  • Database Development / Data Tools Platform Documentation
  • Database Development / Data Tools Platform Enablement

I’m clueless about why the documentation is needed to resolve this issue but…

Once these features are checked, the error message will disappear and you will be free to install whichever plugins you’d like.

I’m a bit surprised by the small number of results I’ve got when googling for the error message: two! Credit for the solution goes to Bradley Wagner and the great folks at Nabble.

Transparent database encryption

Jasypt logoA co-worker and friend of mine recently released a new open-source project. It is called Jasypt (Java Simplified Encryption).

It is focused on simplying the most usual cryptographic tasks (like encryption and hashing) with a plus: it is designed with easy integration in mind.

If using Hibernate, you can declaratively configure encryption for your persistent entities, and it is also easy to manage through spring.

For more information, read the announcement on The Server Side or check the project site.





Follow

Get every new post delivered to your Inbox.