The message Could not initialize class org.perfectjpattern.jee.integration.dao.LocalDaoFactory
means that the JVM has been unable to statically initialize the class with this name.
I looked at source of this class and its superclasses HibernateDaoFactory and AbstractDaoFactory. The only static initialization done by LocalDaoFactory and HibernateDaoFactory is to create a single instance of each class and store it in a private static final
field named INSTANCE
. So, there must be a problem instantiating these singletons.
LocalDaoFactory has no constructor of its own, and AbstractDaoFactory's constructor uses only standard Java classes and ones in the same package as it. HibernateDaoFactory's constructor is a little more interesting, in that it creates a HibernateCurrentSessionStrategy and a HibernateConfiguredTransactionStrategy. The code itself doesn't look particularly problematic, so it seems likely that some of the classes that this code is trying to instantiate are missing.
The only dependencies that I could see on code outside PerfectJPattern were:
- Hibernate Core,
- Apache Commons Lang.
I'm going to assume that you do have the relevant Hibernate core JAR, so that leaves the finger of blame pointing at Apache Commons Lang.
The Apache Commons Lang website mentions that commons-lang version 3 uses a different package to earlier versions of commons-lang. Given that your project worked before upgrading to Hibernate 4 and now doesn't work, I'm going to guess that upgrading to Hibernate 4 replaces commons-lang 2.6 or earlier with commons-lang 3 or later, and the problem arises because PerfectJPattern has a dependency on commons-lang 2.
EDIT: it looks like your project does include commons-lang v2.5, so the absence of that would seem not to be the problem. A NoClassDefFoundError
with message Could not initialize class ...
means that the JVM has tried and failed to load the class at least twice - if you could get hold of the exception message when it failed for the first time, that might help you more. I'm afraid all I can really suggest is to start your project under a debugger that has been set to break on exceptions.