smooks / smooks-edi-cartridge

Smooks EDI & EDIFACT cartridges for reading as well as writing EDI
https://www.smooks.org
Other
19 stars 14 forks source link

SecurityManager warnings when using the `smooks-edi-cartridge` and the `camel-spring-boot-starter` dependencies in same project. #140

Open jeffgbradley2 opened 3 years ago

jeffgbradley2 commented 3 years ago

Description

When smooks-edi-cartridge is used alongside the camel-spring-boot-starter dependency, XMLConverter spams WARN log messages for the following reason:

WARN 63053 --- [  restartedMain] o.a.camel.converter.jaxp.XmlConverter    : DocumentBuilderFactory doesn't support the attribute http://apache.org/xml/properties/security-manager, due to class org.apache.xerces.util.SecurityManager cannot be cast to class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager (org.apache.xerces.util.SecurityManager and org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager are in unnamed module of loader 'app').

No other Smooks or Camel dependencies cause the warning messages.

Reproduce

In a Camel Spring Boot app, the camel-spring-boot-starter Maven dependency shown below is added to the POM.

 <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>3.10.0</version>
        </dependency>

For Smooks, the following dependencies are added to the POM.

...
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.smooks</groupId>
                <artifactId>smooks-bom</artifactId>
                <version>2.0.0-M3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

<dependencies>
...
        <dependency>
            <groupId>org.smooks.cartridges.edi</groupId>
            <artifactId>smooks-edi-cartridge</artifactId>
        </dependency>
...
</dependencies>

The following warning occurs multiple time when the app starts up.

2021-06-30 15:31:58.016  WARN 63053 --- [  restartedMain] o.a.camel.converter.jaxp.XmlConverter    : DocumentBuilderFactory doesn't support the attribute http://apache.org/xml/properties/security-manager, due to class org.apache.xerces.util.SecurityManager cannot be cast to class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager (org.apache.xerces.util.SecurityManager and org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager are in unnamed module of loader 'app').

java.lang.IllegalArgumentException: class org.apache.xerces.util.SecurityManager cannot be cast to class org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager (org.apache.xerces.util.SecurityManager and org.smooks.engine.delivery.sax.ng.org.apache.xerces.util.SecurityManager are in unnamed module of loader 'app')
    at org.smooks.engine.delivery.sax.ng.org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:145) ~[smooks-core-2.0.0-M3.jar:na]
    at org.apache.camel.converter.jaxp.XmlConverter.createDocumentBuilderFactory(XmlConverter.java:975) ~[camel-xml-jaxp-3.10.0.jar:3.10.0]
    at org.apache.camel.converter.jaxp.XmlConverter.getDocumentBuilderFactory(XmlConverter.java:880) ~[camel-xml-jaxp-3.10.0.jar:3.10.0]
    at org.apache.camel.converter.jaxp.XmlConverter.getDocumentBuilderFactory(XmlConverter.java:938) ~[camel-xml-jaxp-3.10.0.jar:3.10.0]
    at org.apache.camel.converter.jaxp.XmlConverter.toDOMDocument(XmlConverter.java:674) ~[camel-xml-jaxp-3.10.0.jar:3.10.0]
    at org.apache.camel.xml.jaxb.JaxbHelper.loadRouteTemplatesDefinition(JaxbHelper.java:233) ~[camel-xml-jaxb-3.10.0.jar:3.10.0]
    at org.apache.camel.dsl.xml.jaxb.JaxbXmlRoutesBuilderLoader$1.configure(JaxbXmlRoutesBuilderLoader.java:52) ~[camel-xml-jaxb-dsl-3.10.0.jar:3.10.0]
    at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:541) ~[camel-core-model-3.10.0.jar:3.10.0]
    at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:487) ~[camel-core-model-3.10.0.jar:3.10.0]
    at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:462) ~[camel-core-model-3.10.0.jar:3.10.0]
    at org.apache.camel.impl.engine.AbstractCamelContext.addRoutes(AbstractCamelContext.java:1150) ~[camel-base-engine-3.10.0.jar:3.10.0]
    at org.apache.camel.main.RoutesConfigurer.configureRoutes(RoutesConfigurer.java:200) ~[camel-main-3.10.0.jar:3.10.0]
    at org.apache.camel.spring.boot.CamelSpringBootApplicationListener.onApplicationEvent(CamelSpringBootApplicationListener.java:106) ~[camel-spring-boot-3.10.0.jar:3.10.0]
    at org.apache.camel.spring.boot.CamelSpringBootApplicationListener.onApplicationEvent(CamelSpringBootApplicationListener.java:58) ~[camel-spring-boot-3.10.0.jar:3.10.0]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586) ~[spring-context-5.3.8.jar:5.3.8]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:771) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:763) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:438) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:339) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) ~[spring-boot-2.4.7.jar:2.4.7]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1318) ~[spring-boot-2.4.7.jar:2.4.7]
    at com.example.integrationdemo.IntegrationDemoApplication.main(IntegrationDemoApplication.java:12) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.4.7.jar:2.4.7]
uliSchuster commented 2 years ago

I can confirm this issue. It does not show up with plain Java configuration (No Spring XML). But as soon as XML processing comes into play, the above warning shows up. I do observe it in combination with Spring-Boot and Apache Camel, when I advise a Camel route for testing and the test fixture logs the advised route as XML.