Class java.util.HashMap cannot be cast to class org.w3c.dom.Node

Hi,

We are migrating a Coldfusion application to a Lucee application. Most of the code works like a charm, but we get an error on a component that acts as a webservice. The code is:

<cfcomponent>
	<cffunction name="GetCustomer" returntype="xml" returnFormat="xml"  access="remote">

		<cfset local.qObj = createObject("component","Query").init()>
		<cfset getCustomer =  local.qObj.customer(action="getApi")>

		<cfsavecontent variable="returnBody">
			<cfoutput><result><customers></cfoutput>
			
			<cfloop query="getCustomer">
				<cfoutput><customer><no>#No#</no><name>#Name#</name><city>#City#</city></customer></cfoutput>
			</cfloop>
			
			<cfoutput></customers></result></cfoutput>
		</cfsavecontent>
		
		<cfreturn XmlParse(returnBody)>
   </cffunction>
 </cfcomponent>

When I call the webservice with from SOAPUI, an exception is logged:

“Severity”,“ThreadID”,“Date”,“Time”,“Application”,“Message”
“ERROR”,“ajp-nio-0:0:0:0:0:0:0:1-8009-exec-8”,“07/19/2021”,“15:03:35”,“Axis1”,"AxisFault:;; nested exception is:
java.lang.ClassCastException: class java.util.HashMap cannot be cast to class org.w3c.dom.Node (java.util.HashMap is in module java.base of loader ‘bootstrap’; org.w3c.dom.Node is in module java.xml of loader ‘bootstrap’);AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.ClassCastException: class java.util.HashMap cannot be cast to class org.w3c.dom.Node (java.util.HashMap is in module java.base of loader ‘bootstrap’; org.w3c.dom.Node is in module java.xml of loader ‘bootstrap’)
faultActor:
faultNode:
faultDetail:
{WebServices - Axis}stackTrace:java.lang.ClassCastException: class java.util.HashMap cannot be cast to class org.w3c.dom.Node (java.util.HashMap is in module java.base of loader ‘bootstrap’; org.w3c.dom.Node is in module java.xml of loader ‘bootstrap’)
at com.Api_wrap.GetCustomer(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.lucee.extension.axis.server.Axis1Server.doPost(Axis1Server.java:336)
at org.lucee.extension.axis.server.Axis1Server.doPost(Axis1Server.java:227)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at lucee.runtime.net.rpc.ref.WSServerReflector.doPost(WSServerReflector.java:46)
at lucee.runtime.ComponentPageImpl.callWebservice(ComponentPageImpl.java:985)
at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:182)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1031)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:923)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:217)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2457)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2447)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2418)
at lucee.runtime.engine.Request.exe(Request.java:44)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1179)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1125)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:394)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)

{http://xml.apache.org/axis/}hostname:WEB-25

java.lang.ClassCastException: class java.util.HashMap cannot be cast to class org.w3c.dom.Node (java.util.HashMap is in module java.base of loader ‘bootstrap’; org.w3c.dom.Node is in module java.xml of loader ‘bootstrap’)
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:333)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.lucee.extension.axis.server.Axis1Server.doPost(Axis1Server.java:336)
at org.lucee.extension.axis.server.Axis1Server.doPost(Axis1Server.java:227)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at lucee.runtime.net.rpc.ref.WSServerReflector.doPost(WSServerReflector.java:46)
at lucee.runtime.ComponentPageImpl.callWebservice(ComponentPageImpl.java:985)
at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:182)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:1031)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:923)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:217)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:44)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2457)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2447)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2418)
at lucee.runtime.engine.Request.exe(Request.java:44)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1179)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1125)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:394)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ClassCastException: class java.util.HashMap cannot be cast to class org.w3c.dom.Node (java.util.HashMap is in module java.base of loader ‘bootstrap’; org.w3c.dom.Node is in module java.xml of loader ‘bootstrap’)
at com.Api_wrap.GetCustomer(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
… 48 more
"

I have played with the returntype and returnformat, but to no avail. Searching the internet didn’t produce any clue either.

Does anyone has a clue how to solve this issue?

Thanks for your time!

OS: Windows Server 2019 Standard
Java Version: 11.0.3 (AdoptOpenJDK) 64bit
Tomcat Version: Apache Tomcat/9.0.20
Lucee Version: Lucee 5.3.8.189

do you have the full java stack trace of the error?

Hi Michael,

I have included the entire trace in my original post.

Thanks!

I have created a test case based on your example code and i can reproduce the issue.
Can you please raise a ticket at issues.lucee.org .

Problem is that Lucee does not have a custom serializer/deserializer for “xml” and the default fail to do it.
To be honest the ticket will not have the highest priority, because this is an issue that exists for years already and most people are moving away from SOAP anyway.

Best is to find a workaround for the issue, of course that depends on the client using the service. First thing i would try is to change the return type from “xml” to “string”.
if that does not work i would adjust the soap response itself, with help of the soap functions

BTW the attribute “returnformat” has no effect in that case, the transport protocol always is soap (what is XML based) and cannot be changed, this attribute is only used for http web services.

Hi Michael,

Thank you for your answer and the time and effort you’ve put into it! We will discuss it with the developer on the client side: changing the returntype to string produces a proper SOAP response from Lucee, however with the payload encapsulated inside a CDATA block. So he has to change some of the code.

I will also have a look at the SOAP functions you mentioned.

I have created this ticket:
https://luceeserver.atlassian.net/browse/LDEV-3629

Thanks again!