Skip to main content
Level 4
April 6, 2022
Solved

Junit test fails with SAXNotRecognizedException while loading json

We created project using latest archetype (cloud runtime).

Junit test fails in the part when json is loading,

ctx.load().json("/com/myproject/core/models/impl/MycmpntImplTest.json", "/content");

 

Same test works when I move it and run from inside weekend project or when I use weekend test libs (pom defintions) in our project.

 

Exception follows :

 

java.lang.IllegalStateException: Unable to enable secure processing.
at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.<init>(JCRXMLContentParser.java:61)
at org.apache.sling.testing.mock.sling.loader.ContentLoader.<init>(ContentLoader.java:149)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:376)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:366)
at com.myproject.core.models.impl.MycmpntImplTest.setUp(MycmpntImplTest.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
.

.

.at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: org.xml.sax.SAXNotRecognizedException: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.
at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source)
at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source)
at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.<init>(JCRXMLContentParser.java:57)

nbg62Accepted solution
Level 4
April 24, 2022

Adding following to Core resolved it (thanks to Adobe support)

 

<dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.2</version> <scope>test</scope> </dependency>

7 replies

joerghoh
Adobe Employee
Adobe Employee
April 6, 2022

What Java version are you using? mvn -version should display it.

Translate
nbg62Author
Level 4
April 6, 2022

hi Jorg,

 

I'm running it from eclipse, 1.8 Java version

Translate
nbg62AuthorAccepted solution
Level 4
April 24, 2022

Adding following to Core resolved it (thanks to Adobe support)

 

<dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.2</version> <scope>test</scope> </dependency>

Translate
August 29, 2022

It required a restart of IDE. 

 

Thanks, it worked.

Translate
Level 3
April 2, 2023

In cloud instance, adding <dependency> <groupId>xerces</groupId> <artifactId>xercesImpl</artifactId> <version>2.12.2</version> <scope>test</scope> </dependency> does not work for me.
Changing version from 4.1.8 to 4.1.0 in root pom makes it work for me. 

<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<!-- <version>4.1.8</version>-->
<version>4.1.0</version>
<scope>test</scope>
</dependency>

 

Translate