[JIRA] (WTES-72) ctx.load().json parse exception when moving from 4.1.0 to 4.1.2

469 views
Skip to first unread message

dangordon86 (JIRA)

unread,
Feb 25, 2022, 7:32:49 AM2/25/22
to wcm-i...@googlegroups.com
dangordon86 created WTES-72:
-------------------------------

Summary: ctx.load().json parse exception when moving from 4.1.0 to 4.1.2
Key: WTES-72
URL: https://wcm-io.atlassian.net/browse/WTES-72
Project: wcm.io Testing
Issue Type: Bug
Components: AEM Mocks
Affects Versions: AEM Mocks 4.1.2
Reporter: dangordon86


While upgrading some dependencies I noticed existing unit tests broke when updating io.wcm.testing.aem-mock.junit5 from 4.1.0 to 4.1.2.

When running the same unit test on 4.1.2 the following error is thrown when trying to load AEM context from a json file:


{code:text}
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:367)
at org.apache.sling.testing.mock.sling.context.SlingContextImpl.load(SlingContextImpl.java:357)
at com.adobe.aem.guides.wknd.core.models.impl.BylineImplTest.setUp(BylineImplTest.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:725)
at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeEachMethod(TimeoutExtension.java:76)
at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:506)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$21(ClassBasedTestDescriptor.java:491)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachMethods$3(TestMethodTestDescriptor.java:171)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:168)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at java.util.ArrayList.forEach(ArrayList.java:1259)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95)
at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91)
at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60)
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
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.(JCRXMLContentParser.java:57)
{code}

{code:java}

private final AemContext ctx = new AemContext();

@BeforeEach
void setUp() throws Exception {
ctx.addModelsForClasses(BylineImpl.class);
ctx.load().json("/com/adobe/aem/guides/wknd/core/models/impl/BylineImplTest.json", "/content");
}
{code}

BylineImplTest.json:

{code:json}
{
"byline": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "wknd/components/byline",
"name": "Jane Doe",
"occupations": ["Photographer", "Blogger", "YouTuber"]
}
}
{code}








--
This message was sent by Atlassian Jira
(v1001.0.0-SNAPSHOT#100192)

dangordon86 (JIRA)

unread,
Feb 25, 2022, 7:39:55 AM2/25/22
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-72?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

dangordon86 updated WTES-72:
----------------------------
Description:
While upgrading some dependencies I noticed existing unit tests broke when updating io.wcm.testing.aem-mock.junit5 from 4.1.0 to 4.1.2.

When running ctx.load().json() the same unit test (works on 4.1.0) fails on 4.1.2 what appears to be a xml parsing error gets thrown. These tests were originally written for 3.0.2 so maybe there is a new best practice for loading aem content for a json file?



*Exception*

{code:java}java.lang.IllegalStateException: Unable to enable secure processing.
at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.(JCRXMLContentParser.jav57){code}

{code:java}private final AemContext ctx = new AemContext();

@BeforeEach
void setUp() throws Exception {
ctx.addModelsForClasses(BylineImpl.class);
ctx.load().json("/com/adobe/aem/guides/wknd/core/models/impl/BylineImplTest.json", "/content");
}{code}



BylineImplTest.json:

{code:json}{
"byline": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "wknd/components/byline",
"name": "Jane Doe",
"occupations": ["Photographer", "Blogger", "YouTuber"]
}
}{code}

was:
> ctx.load().json parse exception when moving from 4.1.0 to 4.1.2
> ---------------------------------------------------------------
>
> Key: WTES-72
> URL: https://wcm-io.atlassian.net/browse/WTES-72
> Project: wcm.io Testing
> Issue Type: Bug
> Components: AEM Mocks
> Affects Versions: AEM Mocks 4.1.2
> Reporter: dangordon86
>
> While upgrading some dependencies I noticed existing unit tests broke when updating io.wcm.testing.aem-mock.junit5 from 4.1.0 to 4.1.2.
> When running ctx.load().json() the same unit test (works on 4.1.0) fails on 4.1.2 what appears to be a xml parsing error gets thrown. These tests were originally written for 3.0.2 so maybe there is a new best practice for loading aem content for a json file?
> *Exception*
> {code:java}java.lang.IllegalStateException: Unable to enable secure processing.
> at org.apache.sling.contentparser.xml.jcr.internal.JCRXMLContentParser.(JCRXMLContentParser.jav57){code}

Stefan Seifert (JIRA)

unread,
Feb 25, 2022, 7:57:22 AM2/25/22
to wcm-i...@googlegroups.com

[ https://wcm-io.atlassian.net/browse/WTES-72?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21473#comment-21473 ]

Stefan Seifert commented on WTES-72:
------------------------------------

this is not directly related to aem-mock:

* between AEM mock 4.1.0 to 4.1.2 we updated to sling-mock 3.1.0
* sling mock between 3.0.2 and 3.1.0 included org.apache.sling.contentparser.xml-jcr 2.0.0 to support mounting filevault XML content as well
* org.apache.sling.contentparser.xml-jcr is using this FEATURE_SECURE_PROCESSING which is failing here: [https://github.com/apache/sling-org-apache-sling-contentparser-xml-jcr/blob/bbe7662277278fc5fc3fae5cc70cbbc7c0e32804/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParser.java#L57|https://github.com/apache/sling-org-apache-sling-contentparser-xml-jcr/blob/bbe7662277278fc5fc3fae5cc70cbbc7c0e32804/src/main/java/org/apache/sling/contentparser/xml/jcr/internal/JCRXMLContentParser.java#L57]

of course it looks strange that you get an XML parsing error when parsing JSON. but the sling-mock ContentLoader is currently initializing the XML parser as well in it’s constructor even if not used.

so the main question is - why can the XML parser not initialized on your environment with FEATURE_SECURE_PROCESSING. it’s using xerces internally and should run fine with the version included in the JDK. probably you have some very outdated xerces parser version in your classpath which should be excluded from the dependencies?
Reply all
Reply to author
Forward
0 new messages