Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Junit test fails with SAXNotRecognizedException while loading json

Avatar

Level 5

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)

1 Accepted Solution

Avatar

Correct answer by
Level 5

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>

View solution in original post

5 Replies

Avatar

Employee Advisor

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

Avatar

Level 5

hi Jorg,

 

I'm running it from eclipse, 1.8 Java version

Avatar

Correct answer by
Level 5

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>

Avatar

Level 1

It required a restart of IDE. 

 

Thanks, it worked.

Avatar

Level 4

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>