无法加载类路径;调度失败(def payload = new com.eviware.soapui.support.XmlHolder(mockRequest.requestContent)

时间:2014-06-14 12:01:57

标签: soap groovy soapui

我使用以下代码完全来自使用SoapUI'的Web服务测试。动态模拟酒店的服务。该服务包括客人管理,客房管理和预订课程。我试图从书中添加下面的代码

def payload = new com.eviware.soapui.support. XmlHolder(mockRequest.requestContent) def guestname = payload["//typ:getGuestDetails/typ:guestName"] def response = "";
....

这给出了错误

com.eviware.soapui.impl.wsdl.mock.DispatchException: Failed to dispatch using script; 
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script11.groovy: 1: unable to resolve class com.eviware.soapui.support.XMLHolder @ line 1,
column 1. import com.eviware.soapui.support.XMLHolder ^org.codehaus.groovy.syntax.SyntaxException: unable to resolve class
com.eviware.soapui.support.XMLHolder @ line 1, column 1. at
org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) at
org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1145) at
org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at
org.codehaus.groovy.control.CompilationUnit$10.call(CompilationUnit.java:632) at
org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) at
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523) at
groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) at
groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) at
groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) at
groovy.lang.GroovyShell.parse(GroovyShell.java:625) at
groovy.lang.GroovyShell.parse(GroovyShell.java:652) at
groovy.lang.GroovyShell.parse(GroovyShell.java:643) at
com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:152) at
com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:97) at
com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher.selectMockResponse(ScriptMockOperationDispatcher.java:81) at
com.eviware.soapui.impl.wsdl.mock.dispatch.ScriptMockOperationDispatcher$RunScriptAction.actionPerformed(ScriptMockOperationDispatcher.java:237) at
javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at 
javax.swing.DefaultButtonModel.setPressed(Unknown Source) at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at
java.awt.AWTEventMulticaster.mouseReleased(Unknown Source) at
java.awt.Component.processMouseEvent(Unknown Source) at
javax.swing.JComponent.processMouseEvent(Unknown Source) at
java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at
java.awt.Container.dispatchEventImpl(Unknown Source) at
java.awt.Component.dispatchEvent(Unknown Source) at
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at
java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(UnknownSource) at
java.awt.EventQueue.dispatchEventImpl(Unknown Source) at
java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at
java.awt.EventQueue$3.run(Unknown Source) at
java.security.AccessController.doPrivileged(Native Method) at
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at 
java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at 
java.security.AccessController.doPrivileged(Native Method) at
java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at
java.awt.EventQueue.dispatchEvent(Unknown Source) at
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at
java.awt.EventDispatchThread.pumpEvents(Unknown Source) at
java.awt.EventDispatchThread.pumpEvents(Unknown Source) at
java.awt.EventDispatchThread.run(Unknown Source) 1 error

如何解决此错误。

1 个答案:

答案 0 :(得分:0)

起初我猜这是一个类路径问题,但它可能不是原因,因为抛出它的脚本的异常是com.eviware.soapui.impl.wsdl.mock.DispatchException,它与com.eviware.soapui.support.XmlHolder在同一个jar中。所以我意识到在你的问题中有一些我不理解的东西,在java(和groovy)中,类名是区分大小写的,所以如果你想使用com.eviware.soapui.support.XmlHolder类,你就不能使用{{1 }}。在您发布的代码示例中,我看到您使用了正确的语法:

com.eviware.soapui.support.XMLHolder

但是在你的堆栈跟踪中,我发现你在def payload = new com.eviware.soapui.support.XmlHolder上使用了错误的类名:

import

所以错误出现在... unable to resolve class com.eviware.soapui.support.XMLHolder @ line 1, column 1. import com.eviware.soapui.support.XMLHolder...声明中,请使用:

import

而不是

import com.eviware.soapui.support.XmlHolder

希望这有帮助,