Hibernate MultipleHiLoPerTableGenerator deadlock and TableGenerator.allocationSize

The other week I had the pleasure of visiting a former client, which had a problem with the connection pool being completely drained for connections, and as a consequence of that, their system pretty much locking up. A dump of the stacks of all threads when the system locked up, told us the culprit was [...]

August 15, 2011 · polesen · No Comments
Tags: , ,  Â· Posted in: Programming

Springified Servlets, Listeners and Filters

Here are some short, but fully functional, templates for when you have a need for HttpServlet, ContextListener or Filter implementations, that also need spring bean dependencies. You use them by subclassing them and calling the getBean method when a dependency is needed, like this: Okay, here they come.. SpringHttpServlet SpringContextListener SpringFilter

March 5, 2011 · polesen · 2 Comments
Tags: , , , ,  Â· Posted in: Programming

A Non-Blocking Process.waitFor()

When calling java.lang.Process.waitFor() the call will block (wait()) until the process actually exits. The waitFor() call is blocking, which is pretty irritating sometimes, for instance when #&%€! wine decides to hang itself, hereby stealing my tomcat execute threads and database connections in production Well, here’s a quick and dirty solution to creating a non-blocking waitFor() [...]

July 16, 2010 · polesen · One Comment
Tags:  Â· Posted in: Programming

Testing CXF with Autowiring using Spring

Here is how to create a test for a CXF web service implementation class. The test use spring-mock base classes and hereby support stuff like transactions and autowiring through annotations. Neat. I have a base class like this: One thing here: cxf.xml is loaded from classpath by the test code, but it resides in src/main/webapp/WEB-INF [...]

June 20, 2010 · polesen · No Comments
Tags: , , , ,  Â· Posted in: Programming

One Pool to Rule Them All…in tomcat

I am developing a system that gets deployed as a bunch of separate webapps but all in the same tomcat instance. Not long ago, we opened up production for a lot more users, which quickly led to some resource exhaustion-primarily on the database backend. In other words, … we were beating oracle to death. After [...]

June 13, 2010 · polesen · No Comments
Tags: , , ,  Â· Posted in: Programming

How To Acess Target Object Behind a Spring Proxy

When annotating spring managed beans with stuff like @Transactional, spring will behind the scenes produce code, that ensures that transaction logic is applied before and after your code. Depending on the configuration, this is often done using a JDK proxy, which is a dynamically generated class implementing the bean interfaces. This dynamically generated code will [...]

June 5, 2009 · polesen · 10 Comments
Tags: ,  Â· Posted in: Programming

Making a Java WebApp Return Proper SOAP Fault Responses

In several projects I have been co-developing, we had a webapp as part of the system, which exposed a webservice API as integration end-point to the system. The sole content of that webapp is the webservice, and as such, the web.xml contained only the mount of the webservice servlet (like CXF or Axis) and not [...]

August 29, 2008 · polesen · 2 Comments
Tags: , ,  Â· Posted in: Programming

The Need for java.lang.Thread and java.sql is Gone

At least for the application developer. Back in the days of Java1, two cool parts of this new platform was the threading apis and the JDBC apis. These APIs have both had immense success. But I think we, as application developers, should forget about them. I know I mostly have. There are good reasons, that [...]

August 28, 2008 · polesen · 14 Comments
Tags: , ,  Â· Posted in: Design, Programming

Applet Caching and the Control Panel on Linux

The Sun Java applet plugin will cache applets outside the browser cache, in its own cache directory. Clearing the cache in the browser will not clear the applet cache, which can be irritating when you need to be sure, that a fresh copy of a given applet is loaded. What you need to do, is [...]

August 25, 2008 · polesen · One Comment
Tags: , ,  Â· Posted in: Operating Systems

System.currentTimeMillis, System.nanoTime and Their Resolution

When reading about Robust Java Benchmarking, I came across some things I had not thought about myself. It turns out, that even though System.currentTimeMillis() has the unit of milliseconds, the precision with which the method can return, is quite different on various operating systems. Brent Boyer explains that Windows XP has a granularity of 15 [...]

August 10, 2008 · polesen · 7 Comments
Tags:  Â· Posted in: Programming