0

I'm running a unit test that throws this error:

java.lang.NoClassDefFoundError: com/sun/logging/LogDomains
    at com.sun.enterprise.util.ORBManager.<clinit>(ORBManager.java:93)
    at com.sun.enterprise.naming.SerialInitContextFactory.<clinit>(SerialInitContextFactory.java:65)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:247)
    at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.init(InitialContext.java:223)
    at javax.naming.InitialContext.<init>(InitialContext.java:175)
    myCode

My code is this:

    try {
        Context c = new InitialContext();  //line that errors
        return (T) c.lookup(name);
    } catch (NamingException ne) {
        log.error(ne.getMessage(), ne);
        throw new RuntimeException(ne);
    }

How do I get around this issue?

It seems like this answer would work, except for the huge deal breaker I mention in a comment:

The problem with this is that they seem to have exploded a bunch of jars and packaged them back together inside glassfish-embedded-all. You better hope you're using the same slf4j version they packaged in there, because they didn't give a way to exclude what they give you. There has got to be a better way.

FWIW, I'm deploying to Glassfish 3.

Perhaps I need to prevent my unit test from getting to this line. But it feels weird that I get an NoClassDefFoundError Why is this happening?

Community
  • 1
  • 1
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

0 Answers0