Eclipse J2EE Module Dependencies Page contains Illegal Values

January 22, 2008

I just ran into this problem that eclipse wouldn’t display the J2EE module dependencies for a couple of my projects.  The solution I found was to open the MANIFEST.MF files for those projects and delete the classpath entries.  I suspect I had some old classpath entries in there which were no longer valid, and the property page code was flipping out about it.

Hope this helps someone …


Can Java learn from python when it comes to library design?

January 16, 2008

When it comes to the language wars, I eventually came to realize that productivity in a language is driven first by the library that comes with the language (if any) and second by the IDE’s that are available for that language.

One thing that makes python great is that they integrate a lot of useful stuff right into the core library. Java, unfortunately, hasn’t done a great job of following this lead. For example, they don’t provide a way to encode a Base64 string by default. When I use my IDE to search for classes with the name Base64, I get a rather amusing list of re-re-implementations and copies of the same class, all because the Java library maintainers are unable or unwilling to put this common functionality into the library.

Anyway, when I saw this, I thought “Java could really learn a few things from python about having a feature rich standard library …”

All the completions of Base64 in my Java EE app


Glassfish: Setting the context-root of a WAR inside an EAR

January 15, 2008

I’ve been bashing my head against THIS one for weeks, on and off.  Each time I tried to figure out how to map my app to the name of my choice (‘/’) nothing I did seemed to work!

Finally today I learned about yet another XML file you have to edit in Java EE – application.xml.  Yep, the Java EE development life is filled with wonderful and magical XML files.

Application.xml is a lot like web.xml, but it applies to the EAR.  What isn’t obvious, and which nobody warned me about, is that the context-root for an app is set in application.xml, and it doesn’t matter what you put into sun-web.xml, web.xml, or anything else to try and rename the context-root of your war.  application.xml will override all of that.

So, I’m happy to have found it, but sad that it took so long.  Hopefully others having the same problem – “context-root in sun-web.xml ignored” or “glassfish ignores my context-root” for those searchers out there – can find this post and be enlightened by it!


Software testing with testuff.com

January 11, 2008

I just ran into this interesting tool at testuff.com.  It’s a combination bug reporter and screen capture tool designed to help clearly document and describe test results.  Easily adding some screenshots and a video of what you did seems like a great way to report bugs!  It integrates with trac, bugzilla, and others which lets the tester submit directly to your favorite bug tracker.  It looks very nice!

It’s free during beta and for single-user use, and they’re planning to charge $300/year for it after beta for 1-5 user setups.


Database schema migration with LiquiBase

January 8, 2008

One item of concern for me during development is figuring out what to do one I have actual live data on a database, and I can’t do schema updates by dropping all tables and letting hibernate re-create them.

A solution I’ve run into today that seems promising is LiquiBase. It’s still very much in development but they are working on roughly what I want.

The idea behind liquibase is fairly simple – store a list of database changes to a file, and let the user run them. I think it has a way to keep track of which changes were already run in the past, and then it can roll forward any new changesets you add to the file. This is a great idea!

The only trouble I have with it is that I’m using hibernate to generate my database schemas and I’m generally pretending I don’t know anything about the schemas it generates (sequences, foreign keys, foreign key names, not null constraints etc.). LiquiBase generally assumes you know what changes are being made and you’ll be entering them into the changesets file as you go.

LiquiBase does provide a diff tool which allows me to generate XML changesets that would convert one schema to another. I should be able to take that XML diff and “fix it up” to replace drop/create with a rename, or provide a custom data upgrader.

The last bit is one thing that seems promising. I can specify a Java class which is instantiated and used to roll forward or back a changeset. I think this will be something I’d use to manage the “real” schema changes – adding new relationships. Without something like this, there’s no way for me to transform the data properly. So, I can tweak the changesets to prepare my data upgrade, then have it invoke my class, then finish the job. Probably it’ll create new columns and remove constraints first, then run my custom code, then drop columns and add constraints afterwards.

So, a tool with promise. I haven’t managed to use it yet, unfortunately. I’m putting all my tables into a seperate postgres schema and the schema support is temporarily incomplete, which means I’d have to do a bunch of messing around to get it to work easily for me. Once I get closer to the point of really needing it, hopefully that’ll be fixed or I can copy the tables into the public schema temporarily for diffing purposes in order to figure out what hibernate changed.

Ideally there would be a tool I could use to take an existing changeset file and persistence unit (persistence.xml and a bunch of annotated classes) and generate the changes I could put into the LiquiBase changeset file (after fixing up anything not automatically handled by the diffing tool). That way, just before I make a “release” to production, I would run that tool and it would do its magic.

I can think of a way to do that manually now – I could create a temporary database using the old XML, and another temporary database with the hibernate classes, and diff them. Currently my ejb3unit test cases leave behind the latest hibernate-generated database, so I just need a copy of the last released database to do my diff. Then, I drop that into my XML file and my next deploy should upgrade the database automatically. I’d also have to turn off the hibernate’s schema update and only use this scheme to manage the database being used in Java EE, both in development and production, but that’s a good thing since it’ll mean I’m testing the schema changesets during development.

Still, this schema issue is a bit of a pain to work around, so I’ll wait a bit and see if I can get a fix for that before I spend any more time on this.


Hibernate + fetch=FetchType.LAZY making trouble

January 6, 2008

Now, for the third time, I’ve run into some weird and wonderful situation where a lazy object wasn’t initialized when I was using it.  When will I learn?  Don’t use FetchType.LAZY unless you’re really know what you’re doing, and test carefully afterwards.  The precise problem I seem to be having is that my hashCode() and equals() methods don’t work.  Anyway, a word of caution!


Zend PHP Library

January 4, 2008

I just ran into this Zend PHP Library.  I don’t know how I never heard of it before, it looks really good!

This library makes PHP look useful again (mostly because PHP hosting is so cheap…)

http://framework.zend.com/manual/en/

Thanks to This WebAppers Post for bringing this to my attention!


Outsourcing web design to india, and how they get such positive reviews

January 1, 2008

I recently completed a project to outsource my web design to a design firm in india.  It was an interesting experience and I learned some things from it.

There were a few hiccups in the process:

  • I wanted a modern table-less layout design, to fit into Web 2.0 and acccessibility guidelines (for no particular reason other than compliance).  The designer could only do table designs.  I suspect this may be because he cuts his photoshop using a tool that outputs tables.
  • I was hoping he could put this directly into my CMS as a template; I want to use CMS Made Simple, but he wasn’t able to figure that one out.
  • The first design we got we didn’t like much, so we had to talk him into making a second design from scratch.  The second design attempt was like the first one, but much worse!  And it didn’t follow our samples very well at all!  Still, he redeemed himself with a pretty nice third design.
  • We always wanted to keep all the design samples around for reference, so when giving feedback we can refer to previous samples he gave us, but he often just deleted the old samples so we couldn’t do that unless we specifically asked him to do so.

In the end, he gave me a feedback of 10 for being such a great client, saying he would love to work with me again.

I guess this buttered me up a bit, so out of kindness I gave him an 8 instead of the 6 that popped into my head first.  Interestingly, he immediately came back and said

“hi dobes….got ur review…with 8 Rating…..we didnt expect this….better…plz withdraw this review…..”

I didn’t feel like I cared much one way or the other, so I retracted my review.  After all, he has 51 other reviews which are either 9 or 10, and getting 8 review might put the poor guy out of business!

If, like me, you’ve noticed the % positive reviews for these indian companies are so good, it’s probably because they’re asking the client remove their review (or not give one) if the review is bad.

If you’re a freelancer on one of those sites, I suggest you also ask your client to give a good review or none, it works and it’ll probably give you more business.


Outsourcing to India?

January 1, 2008

I recently finished reading a very amusing an interesting book – “The Four-Hour Work Week”. This is a very popular book which is primarily about reducing the amount of time you need to work, mostly by setting up online stores, outsourcing, systemizing, and making sure you know what to do once you don’t have to work all the time.

The most amusing and part of part for me was the excerpt from the article My Outsourced Life, where a journalist for Esquire describes how he starts outsourcing as much as possible – including his worry! The author goes on to suggest that outsourcing some things to India is a good idea, since it gives you an experience in managing other people without all the expense of managing other people that cost serious money, and whose mistakes would have serious consequences.  If your man in india screws up, it costs $50 and you have to clean up the mess (do your own research, book your own movie tickets).  If your man in Canada screws up, it costs you $500.  Or something like that.

All the outsourcing websites and firms suggested in the book have since become extremely popular, and using them won’t save you as much money any more.  However, there are still plenty of other outsourcing sites that haven’t caught the wave.  I first tried an ad on elance.com and got very little response, for this reason.  I’ve found another site where I’m confident I can get a better response.

However, I’m faced with a difficult problem: what the hell can I outsource ?

For most things that can be done online, I do them a lot more quickly than I can write a detailed task description to my virtual assistant.

One area where I think there should be an opportunity for a virtual assistant to step in is business plan research.  But, I seem to have some uncertainty here.  I suspect I need to know more specifically what data I’m looking for, and I’m not too sure about that.  Or, I should at least be able to ask for data that I think it is possible to get!

Another question on my mind is how to find the virtual assistant – should I start out on a per-project basis and then branch out into hourly work if I find someone good?  Or hire directly as a virtual assistant and then come up with something for them to do?

So far I’ve outsourced a single project to India – a design for my company website.  The results were fairly good, and very cheap ($50!).  The process of communicating with the design team over there was educational, and I think I learned a lot from it.  So far, so good.


The seductions of hibernate specific features and annotations

January 1, 2008

I recently did a bit of exploration, experimenting with different JPA (Java Persistence API) implements to see which one would work best for me. Initially this was triggered by some frustrating behavior on the part of Toplink Essentials’ JPA implementation. Next, I tried OpenJPA, because I read a blog post by someone who seemed to find OpenJPA a refreshing change. OpenJPA had somewhat better error messages much of the time, and did some helpful validation, which was nice. However, I found that OpenJPA was missing some features that I was using, and for whatever reason (maybe my own cluelessness) I eventually ended up in confusing error message hell anyway. Then I tried hibernate, but I soon found myself unhappy with Hibernate as well and switched back to Toplink.

Now, however, I’ve switched back to hibernate again. Why?

  • ejb3unit uses hibernate internally, and using a different JPA provider from my unit tests makes the tests less valuable.
  • Hibernate Annotations: I want to be able to “remove” an object without removing its row from the database; this allows me to keep old objects around for “undo” and history/auditing purposes. I was afraid that I would have to replace all my collections with queries in order to achieve this effect, in which case the whole point of using ORM seems to be negated. Hibernate provides a @Where annotation on a collection which achieves this effect really nicely. Once I used that feature once, I found a ton of other places where I can use it.
  • Hibernate Search: Hibernate comes with a really nice search system; the only alternative I’ve seen is Compass, which also looks nice but I seem to the find the hibernate documentation a bit easier to get started with. Hibernate Search only works with hiberate as the persistence provider, so that’s another reason to use hibernate.

Hibernate does have it’s disadvantages; the largest in my mind is the unfortunate support situation. It seems like hibernate has become “too popular” for its maintainers to handle, and the conversion rate from user to maintainer isn’t very good. As a result their forums and issue tracker are littered with agressive push-back against the users, trying to get them to read all kinds of documentation and forum posts before posting any issues, and they want every issue posted to be carefully constructed and including a test case. A bit much to ask, in my opinion. If the product were simply easier to use, and helped the users more, they’d have a lot less issues.

I think if hibernate were to provide better validation and error messages that guide users to the problem more rapidly, there’d be much less traffic on the hibernate forums and issue tracker.

Anyway, that’s where I am in my JPA & Java EE adventures.