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

JUNIT SAXNotRecognizedException

  • August 17, 2022
  • 2 replies
  • 632 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"); } @2785667 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 EstebanBustamante

Hi, 


This is because you are missing the "xercesImpl" dependency in your project, please check this thread to know how to fix this issue: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxnotrecognizedexception-while-loading/td-p/447234 

2 replies

kautuk_sahni
Employee
October 13, 2023

@rute  Did you find the suggestions from @estebanbustamante helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni
EstebanBustamante
EstebanBustamanteAccepted solution
New Participant
October 11, 2023

Hi, 


This is because you are missing the "xercesImpl" dependency in your project, please check this thread to know how to fix this issue: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/junit-test-fails-with-saxnotrecognizedexception-while-loading/td-p/447234 

Esteban Bustamante