Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError Thrown for compact profile1 #2544

Closed
Jon901 opened this issue Nov 18, 2019 · 1 comment
Closed

java.lang.NoClassDefFoundError Thrown for compact profile1 #2544

Jon901 opened this issue Nov 18, 2019 · 1 comment
Milestone

Comments

@Jon901
Copy link

Jon901 commented Nov 18, 2019

Jackson version - 2.9.9.1

Exception in thread "DBus Worker Thread-3" java.lang.NoClassDefFoundError: org/w3c/dom/Node
        at com.fasterxml.jackson.databind.ext.OptionalHandlerFactory.<clinit>(OptionalHandlerFactory.java:52)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findOptionalStdDeserializer(BasicDeserializerFactory.java:1616)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findDefaultDeserializer(BasicDeserializerFactory.java:1839)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.findStdDeserializer(BeanDeserializerFactory.java:161)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:125)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:411)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:477)
        at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:4191)
        at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4010)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3005)

In OptionalHandlerFactory an assumption is made that DOM classes are always found and this is not true for embedded environments.(compact profile1)

    static {
        Class<?> doc = null, node = null;
        try {
            node = org.w3c.dom.Node.class;
            doc = org.w3c.dom.Document.class;
        } catch (Exception e) {
            // not optimal but will do
            Logger.getLogger(OptionalHandlerFactory.class.getName())
                .log(Level.INFO, "Could not load DOM `Node` and/or `Document` classes: no DOM support");
        }
        CLASS_DOM_NODE = node;
        CLASS_DOM_DOCUMENT = doc;
    }

In NoClassDefFoundError is an Error not an Exception (NoClassNotFoundException).

Is there a workaround to disable the checking of optional handlers on embedded environments?

@cowtowncoder
Copy link
Member

cowtowncoder commented Nov 18, 2019

Looks like ode needs to catch Throwable instead of Exception.
No, there is no separate setting as catch block is supposed to cover the case you are observing: unfortunately it is difficult to test on regular JVMs.

NOTE: similar code in Java7Handlers.java catch Throwable properly, so this is an oversight. Will fix for 2.10.2 (will actually fix in 2.9 branch, just in case new versions might be released).

@cowtowncoder cowtowncoder added this to the 2.10.2 milestone Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants