JUNIT SAXNotRecognizedException | Community
Skip to main content
New Participant
August 17, 2022
Solved

JUNIT SAXNotRecognizedException

  • August 17, 2022
  • 3 replies
  • 2145 views
Testing locally and getting error at this this line: ctx.load().json("/com/test/core/models/impl/CardTest.json", "/content"); Java test class: @ExtendWith({AemContextExtension.class, MockitoExtension.class}) public class CardTest { private final AemContext ctx = new AemContext(); private Card card; @BeforeEach public void setUp() throws Exception { ctx.addModelsForClasses(Card .class); ctx.load().json("/com/test/core/models/impl/CardTest.json", "/content"); } @test void testGetTitle() { ctx.currentResource("/content/cardtest"); card = ctx.request().adaptTo(Card.class); assertEquals("Title", card.getTitle()); } CardTest.json { "cardtest": { "jcr:primaryType": "nt:unstructured", "sling:resourceType": "test/components/test-component", "title": "Title" } } java.lang.IllegalStateException: Unable to enable secure processing. at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.(JCRXMLContentParser.java:61) at org.apache.sling.testing.mock.sling.loader.ContentLoader.(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.test.core.models.impl.card.CardTest .setUp(CardTest.java:22) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) 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.(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.(JCRXMLContentParser.java:57) ... 77 more
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by rute

How I solved:

            <dependency>
                <groupId>junit-addons</groupId>
                <artifactId>junit-addons</artifactId>
                <scope>test</scope>
                <version>1.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

 

3 replies

Sachin_Arora_
New Participant
August 18, 2022

To fix this issue you need to add below dependency in pom.xml

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

Please refer this link of same issue : 
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxnotrecognizedexception-while-loading/td-p/447234

 

ruteAuthorAccepted solution
New Participant
August 18, 2022

How I solved:

            <dependency>
                <groupId>junit-addons</groupId>
                <artifactId>junit-addons</artifactId>
                <scope>test</scope>
                <version>1.4</version>
                <exclusions>
                    <exclusion>
                        <groupId>xerces</groupId>
                        <artifactId>xercesImpl</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

 

arunpatidar
New Participant
August 17, 2022

I think json is not loaded.

Can you try with examples at here https://github.com/arunpatidar02/com.aemlab.junitapp/tree/master/core/src/test 

Arun Patidar
joerghoh
Employee
August 17, 2022

Which version of jackson are you using? It should be listed in your pom.