T loadConfigurationWithXIncludes(URL schema, InputStream stream, Class[] boundedCl" /> T loadConfigurationWithXIncludes(URL schema, InputStream stream, Class[] boundedCl" /> T loadConfigurationWithXIncludes(URL schema, InputStream stream, Class[] boundedCl"/>

Getting InvalidConfigurationException: javax.xml.bind.UnmarshalException:

30 Views Asked by At

This is my code

 @SuppressWarnings("unchecked")
    public static <T> T loadConfigurationWithXIncludes(URL schema, InputStream stream, Class<?>[] boundedClasses,
            Class<T> clazz, File rootResolutionFolder)
            throws SAXException, JAXBException, IOException, InstantiationException, IllegalAccessException {
        JAXBContext jc = JAXBContext.newInstance(boundedClasses);
        Unmarshaller u = jc.createUnmarshaller();

        SAXParserFactory spf = SAXParserFactory.newInstance();
        spf.setXIncludeAware(true);
        spf.setNamespaceAware(true);

        SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        u.setSchema(sf.newSchema(schema));

        u.setEventHandler(new XmlValidationEventHandler(null));

        try {
            spf.setFeature("http://apache.org/xml/features/xinclude/fixup-base-uris", false);
            XMLReader reader = spf.newSAXParser().getXMLReader();
            if (rootResolutionFolder != null) {
                reader.setEntityResolver(new FileEntityResolver(new File("."), rootResolutionFolder, reader
                        .getEntityResolver()));
            }
            if (clazz != null) {
                //System.out.println(""+);
                return u.unmarshal(new SAXSource(reader, new InputSource(stream)), clazz).getValue();
            } else {
                return (T) ((JAXBElement<?>) u.unmarshal(new SAXSource(reader, new InputSource(stream)))).getValue();
            } 
        } catch (ParserConfigurationException e) {
            throw new IOException(e);
        }
    }

After migrating from java1.8 to openjdk11, the below error is thrown:

 configFile content----/home/Default/./conf/negotiating-socket-interface.xml
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="ChannelNegotiationCollector">
     <listen>2000</listen>
     <timeout>3600000</timeout>
     <capabilities>encryption compression</capabilities>
    </config>
    schema---jar:file:/home/Default/lib/socket-communicator.jar!/channel-negotiated-server.xsd
    stream---java.io.ByteArrayInputStream@29be7749
    clazz---class channel.server.config.Configuration
    rootResolutionFolder---/home/Default/.
    boundedClasses--- communicator.channel.server.config.Configuration
    .config.InvalidConfigurationException: InvalidConfigurationException: javax.xml.bind.UnmarshalException: unexpected element (uri:"http://ChannelNegotiationCollector", local:"listen"). Expected elements are <{}capabilities>,<{}capabilitiesConfiguration>,<{}timeout>,<{}listen>
        at io.plugins.NegotiatingSocketCollectorInterface.configure(NegotiatingSocketCollectorInterface.java:96)
        at io.CacheControlInterface.configure(CacheControlInterface.java:50)
        at io.CacheControlInterfaceManager.initControlInterface(CacheControlInterfaceManager.java:127)
        at io.CacheControlInterfaceManager.initialize(CacheControlInterfaceManager.java:98)
        at Cache.start(Cache.java:321)
        at .Cache.serviceStart(Cache.java:948)
        at com.cache.Cache.main(Cache.java:1027)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.component.loader.util.ComponentLauncher.invoke(ComponentLauncher.java:108)
        at com.component.loader.util.ComponentLauncher.main(ComponentLauncher.java:49)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.module.plugin.service.Bootstrap.main(Bootstrap.java:155)
    Caused by: InvalidConfigurationException: javax.xml.bind.UnmarshalException: unexpected element (uri:"ChannelNegotiationCollector", local:"listen"). Expected elements are <{}capabilities>,<{}capabilitiesConfiguration>,<{}timeout>,<{}listen>
        at communicator.utils.ServerConfigurationLoader.loadConfigurationWithDefaults(ServerConfigurationLoader.java:67).

How should I perform the migration to openjdk11?

0

There are 0 best solutions below