Archive

Posts Tagged ‘software development’

Change system time, to emulate… are you sure?!

No Gravatar

Just need to emulate how would an application work in 3 month, or after 2010, or whatever. Think twice before you just change your system time to test.

If you really need to do it, do it from within virtualization. Or…

Or you might face strange effects when you switch back to current time. Some applications depend on files last modified date. And some would check for biggest time ever, to protect them self from using  trial for ever…

In our case after switching back to normal time Eclipse WTP just stopped publishing to server… guess why… :-)

Share

Eclipse WTP Server start hangs… on Windows…

No Gravatar

We have a strange animal: A web application with really lots of jars. (Today total of 273 JARs.)

We use Maven 2, Eclipse with WTP, Tomcat, Q4E, etc.., but from these technologies only Eclipse, WTP and Tomcat are relevant for the problem I’d like to describe. Most of developer machines runs Windows XP, and some Windows 2000, and just few Linux.

As we use Maven 2, the jars came form ${user.home}/.m2/repository/ folder. We just let Q4E set up the path for our projects inside Eclipse. For some reason we stack with Q4E 0.3.0, and we tweaked the WTP Server (Tomcat) launch settings, to have all JARs included. We did not used “served modules without publishing”, nor “J2EE Module Dependencies” for few (here) non-relevant reasons.

After adding few new modules (JARs) to the webapp, for few developers the Tomcat Server just failed to start. No log, and nothing in the debug view, nor in the error view. Eclipse WTP were just waiting for Tomcat to start… forever… We were bitterly searching for solution/bug. With no luck. After adding even more JARs, even more developers were complaining: the same problem.

Read more…

Share

Weird Eclipse behaviour

No Gravatar

I use Eclipse as my primary IDE under Ubuntu Linux (now Hardy). IMHO it’s a great combination. Stable, fast, clean. But from time to time, as Eclipse evolves, and there are more and more plugins I use, I ran into strange erratic behaviour of Eclipse. First there were the nasty problem with PermGenSpece, and now this…

Read more…

Share

Maven 2.0.9 dependency import and Continuum 1.1

No Gravatar

We use Maven2 for developing our huge application, (and few smaller). We have almost 200 projects which depends on each other somehow. That’s why I really like Maven2. It was a nightmare to handle all those dependencies by hand, – as we did it before moving to Maven. Of course there are other great things about Maven, like reports, site and of course the release management. – OK, there is still an annoying bug with release plugin, ranges and snapshots, but we can live with it.

With the release of 2.0.9, we got a new powerful feature for handling dependency versions. The so called “Importing Dependencies” noted in release notes and described in the documentation and in wiki.

Read more…

Share

Why you should Open Source your software?

No Gravatar

Lots of software companies does not Open Source their software. It is a bad practice, and a waste of money. Open Souring your software has a real good ROI.

This article is first of all for business people leading software companies, or for those who pay for software development. Actually for all those who are decision makers. On the other side I hope it will be interesting for software architects, developers too.

This is not mean to be an in-depth analysis or an article about sheer numbers, charts and stuff. It’s just few thoughts and examples from the real world.

Read more…

Share

Continuum 1.1 with LDAP and the Roles hack

No Gravatar

We use Continuum 1.1 as our Continuous Integration server. We also have an LDAP directory that we like to use whenever it comes to user management. So we tried to integrate Continuum with LDAP. As described by the documentation, and here we configured the Continuum to use LDAP authentication.

Everything looked fine. Users could log in, as expected.

But there was one nasty problem. When we tried to change user roles, the users were not in the users list. Even if they logged in, the list showed only the admin and the guest user (and one user created before the LDAP configuration). We tried to google for an answer, but no luck. We tried to tweak the configuration, but it did not worked…

Read more…

Share

Autoboxing and synchronization…

No Gravatar

We were writing a small, low level code to provide sequence number generator. It was backed by database sequences, and it worked fine, or at least we thought so…

All unit tests passed fine. – We wrote some multi-thread testNG tests. So we were quite sure, everything is fine, until we got a bug report… They said we have duplications. Well the first reaction was “no way”. But the error came out again and again. To isolate the problem, we wanted to be sure that our code is fine, so we wrote a stress test: 10 threads, 20 iterations of getting 1 million numbers and storing it into a unique field of database table.

And the stress test started. We event started it 3 times: 3 separate VMs * 20 iterations simultaneously consuming 10 threads. And it ran… ran… for about 5h… and crash… oups, unique constraint violation… :-(

Well there is no way to reproduce this kind of error in debug mode, at least not until you know where the error might be. So we started an “eye debug” session… and after, about half an hour we got it! The code was:

private volatile Long last = -1l;
public final V getNext() {
  if (!initialized) {
   init();
  }

  synchronized (last) {
    if( last % increment == 0 ) {
      dbSequenceGetNextValue();
    }
    last++;
    return (V)last;
  }
}

Well, it looks fine… or at least at first glance. But this code is nasty.

The problem is with autoboxing. Well not exactly with autoboxing, but how we used it.

If you look at the line #11, that would be actually:Long.valueOf(last.intValue()++)

And that is the problem! We have a new object here! And we were using that variable to synchronize our block! Ouch.

Now the correct version is:

private volatile Long last = -1l;
//synch object
private volatile Object getNextSynch = new Object();
public final V getNext() {
  if (!initialized) {
    init();
  }
  synchronized (getNextSynch) {
    if( last % increment == 0 ) {
      dbSequenceGetNextValue();
    }
    last++;
    return (V)last;
  }
}

Of course we could use AtomicLong too, but we do not need that complexity…

Moral of the story:

  1. Always think twice, when you are coding thread-safe, synchronized, parallel, etc…
  2. Instant sugar is evil!

p.s.: Stress tests still running… :-) Hope we’ll get a result by tomorrow.

Share

Hibernate 3.2.x and Groovy – ASM madness

No Gravatar

I was playing a bit with Hibernate and Groovy. I was about to examine the possibility of using Groovy producing JPA Entities.

As I use Maven 2, the natural way is to create a project and define dependencies. As a good Maven user I was looking for the best artifact in the maven repository. I found Hibernate, and Groovy too. I took the latest from both. For groovy there was a choice between groovy-all and groovy. The groovy POM file was more descriptive, so I took that one.

Now that was a bad idea.

The problem is: Hibernate depends on ASM 1.5.3 while Groovy depends on ASM 2.2. ASM is not backward compatible, so ASM 2.2 won’t work for Hibernate. It will fail with class not found exception, (and vice versa for Groovy). After a day of hacking Maven POM file, and looking for some solution, I found this. Just look at the last paragraph, there is the solution. Just pick groovy-all. So I did that, and everything is fine again. Or at least to thought so…
I work on a framework, so I need to use ASM to enhance or to create some code at runtime. I usually do that by using ASM Eclipse plugin, because that is the fastest and easiest path. But that plugin relies on ASM 2.2, and now I’m back where I was… :-(

Ok, I could use a class loader hierarchy, but that would mean special configuration for Maven, or even worst, special configuration at deployment.

I think the Hibernate team should consider the solution Groovy team made.

Or I’m going to do that. :-)

Nice and easy.

Share