dev@glassfish.java.net

debugging ClassNotFoundException runtime exception in hk2/OSGi?

From: Bobby Bissett <bobby.bissett_at_oracle.com>
Date: Tue, 29 Jun 2010 14:46:24 -0400

Hi,

How in the world do I debug a ClassNotFoundException during runtime in
GF? I think I have my dependencies ok, and the module compiles without
any issues, but then at runtime I get a NoClassDefFoundError caused by
a ClassNotFoundException. I'm not using reflection; the class in
question is explicitly imported and the compiler is happy. Just not
runtime.

The situation: I've split the shoal-gms.jar from the Shoal workspace
into shoal-gms-api and shoal-gms-impl jars.

Inside GF, cluster/gms-bootstrap depends only on the shoal-gms-api
bits. So far so good. When needed, the gms-bootstrap module loads the
gms-adapter module. This module depends on shoal-gms-api and shoal-gms-
impl (and on the gms-bootstrap mod in GF). The class it can't find at
runtime is in the shoal-gms-impl jar.

I see that the jar is present in the modules dir and it includes the
class I need. The pom of the gms-adapter module includes this:

         <dependency>
             <groupId>org.shoal</groupId>
             <artifactId>shoal-gms-impl</artifactId>
         </dependency>

...and the full dependency is declared in the top-level pom. So how do
I figure out what my actual classpath is when this runs? Is there
something I need in my dependency element that's missing? Am lost in
the whole OSGi world on this one.

Thanks,
Bobby