What would you recommend for modular development in Java. OSGI is great but it's support for JPA is pitiful. I would really like not to have to write yet another framework, but it seems inevitable.
The best aproach to modular development: think first, code later, refactor often. There's no framework / library in the world that can replace thinking.
Think about what you want to achieve and keep the conceptual as detached from technology as you can. Then try to look for technologies that can fit into what you're trying to achieve. If there isn't a set of technologies/tools/frameworks that meets what you need, do some re-thinking and find a spot somewhere in the middle for concept and implementation to meet.
I don't think the problem is lack of support in OSGI for JPA, but lack of support in JPA implementations for the OSGI classloader. Anyway I digress.
You may have success using OpenJPA with OSGI. The latest versions are already packed as OSGI bundles. I leave also this link that explains how to get OpenJPA working in Apache Felix.
The answer to your question is very dependent on the application(s) you are building. JEE, ESB and OSGi are all appropriate, modular deployment strategies to certain problems.
Building enterprise service oriented software, vs a pluggable client application are very different applications with different solutions.
I currently work on a project that makes usage of JEE deployed services for the backend and an Eclipse/OSGi based rich client that consumes those services. The design and deployment is quite modular between backend services (JEE), client based services (pure OSGi) and UI components (Eclipse plugins).
The largest factor to overcome with any of these technologies is understanding how they work and designing your applications appropriately to work within their constraints. As was already mentioned, classloading is a pretty consistent issue with any complex application in these environments, but understanding these issues up front will allow the software to be designed appropriately for the technology.
Usage of frameworks like Spring go a long way to writing code that will cut the dependency to the underlying technology, but still be able to take advantage of its unique features.
I guess OSGi is the mainstream in nowadays JEE. And it's right choice to build modular applications. Yes, there are some problems with platform maturity and acceptance but take look at the community efforts and will (SpringSource, Eclipse, for example) to make it better. The implementations are open sourced and many IDEs support OSGi development. I would suggest to adopt one of the OSGi implementations instead of developing own framework even with those limitations existing today.