Forum Discussion

SKoneru's avatar
SKoneru
Contributor
12 years ago

Exception when new dependencies are added via maven

Hi,

I created a java project that imports additional jars from Maven and nexus repo that my company maintains. These java classes are being invoked from some Groovy test steps.
Now before I did this the Groovy test steps are working fine. But once I set-up the dependency to additional jars as described above, I noticed below exception.

May be the new dependencies loaded jars that cause this issue. But which jar exactly has the problem? How can I resolve this? Is the groovy script correct?

Simple Groovy code and the exception details:-
================================
def colorlist = ["Greens", "Reds", "Blues"]
def count = 0;

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder( "AddFPItem#Request" )
holder.namespaces["ns1"] = /urn:ebay:apis:eBLBaseComponents/
def dNode = holder.getDomNode("//ns1:Variations[1]")
def doc = dNode.ownerDocument

org.w3c.dom.Node[] varnode = holder.getDomNodes("//ns1:Variation")
if(varnode.size() > 0){
for(def i = 1; i <= varnode.size(); i++){
org.w3c.dom.Node n = dNode.removeChild(holder.getDomNode("//ns1:Variation[1]"))
holder.updateProperty()
context.requestContent = holder.xml
log.info context.requestContent
}
}

Exception:-
=======
java.lang.ClassCastException: net.sf.saxon.dom.NodeWrapper cannot be cast to org.w3c.dom.Node
at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.getUnderlyingNode(XBeansXPath.java:170)
at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectNodes(XBeansXPath.java:127)
at org.apache.xmlbeans.impl.xpath.saxon.XBeansXPath.selectPath(XBeansXPath.java:148)
at org.apache.xmlbeans.impl.store.Path$DelegatePathImpl$DelegatePathEngine.next(Path.java:541)
at org.apache.xmlbeans.impl.store.Cursor._toSelection(Cursor.java:931)
at org.apache.xmlbeans.impl.store.Cursor._toNextSelection(Cursor.java:920)
at org.apache.xmlbeans.impl.store.Cursor.toNextSelection(Cursor.java:2670)
at com.eviware.soapui.support.xml.XmlUtils.selectFirstDomNode(XmlUtils.java:1411)
at com.eviware.soapui.support.XmlHolder.getDomNode(XmlHolder.java:147)
at com.eviware.soapui.support.XmlHolder$getDomNode.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at Script1.run(Script1.groovy:7)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:96)
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    Hi,
    This seems to be related to a classpath issue
    as the error is related to code from xmlbeans, I wanted to share this information.

    The xmlbeans dependency declared in the soapui pom does not follow the usual maven coordinates. This means that if you custom code also depends on xmlbeans and declare this dependency with regular maven coordinates, then, the xmlbeans dependency is added twice to the plugin classpath

    Unfortunately, there are also a lot of other dependencies with not regular maven coordinates that could lead to this situation.

    Tell me if it helps
  • oops, that is a problem.
    The custom code that my app depends on has lots of dependencies, so I will not be surprised if it's fetching xmlbeans from maven central and caused this classpath dependency.
    That is sad that I can not reuse the utilities written in custom package.

    Thanks a lot for the info.
  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    notice that's I am not sure this is the cause of the problem, this is just a supposition.
    you would have to investigate to confirm this
  • Hi SKoneru,

    Have you reached any conclusion regarding this? If you have double xmlbeans dependencies with different versions, bad things can happen. Let me know what the latest status is and I'll try to help.

    Regards,
    Arian
    SmartBear Sweden