Forum Discussion

orodoro's avatar
orodoro
New Contributor
12 years ago

Java7 class not found error in loadUI Groovy script

What has to be done to make test cases that are ok in soapUI be runnable in loadUI?
Please check a test case containing the following simple Groovy script:
log.info(javax.xml.bind.DatatypeConverter.printDateTime(Calendar.getInstance()))

Although this class is contained in the bundled Java 7 of the loadUI installation, I get
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 1: unable to resolve class javax.xml.bind.DatatypeConverter
@ line 1, column 1.
import javax.xml.bind.DatatypeConverter
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class javax.xml.bind.DatatypeConverter
@ line 1, column 1.
at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:148)
at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1240)
at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:148)
at org.codehaus.groovy.control.CompilationUnit$8.call(CompilationUnit.java:601)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:544)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:493)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:306)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:287)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:731)
at groovy.lang.GroovyShell.parse(GroovyShell.java:743)
at groovy.lang.GroovyShell.parse(GroovyShell.java:770)
at groovy.lang.GroovyShell.parse(GroovyShell.java:761)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:148)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.<init>(WsdlGroovyScriptTestStep.java:91)
at com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory.buildTestStep(GroovyScriptStepFactory.java:37)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.createTestStepFromConfig(WsdlTestCase.java:318)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase.<init>(WsdlTestCase.java:117)
at com.eviware.soapui.impl.wsdl.WsdlTestCasePro.<init>(SourceFile:47)
at com.eviware.soapui.impl.wsdl.WsdlTestSuitePro.buildTestCase(SourceFile:64)
at com.eviware.loadui.components.soapui.SoapUISamplerComponent$SoapUITestCaseRunner.getTestCase(SoapUISamplerComponent.java:829)
at com.eviware.loadui.components.soapui.SoapUISamplerComponent$SoapUITestCaseRunner.run(SoapUISamplerComponent.java:711)
at com.eviware.loadui.components.soapui.SoapUISamplerComponent.sample(SoapUISamplerComponent.java:570)
at com.eviware.loadui.impl.component.categories.RunnerBase.doSample(RunnerBase.java:489)
at com.eviware.loadui.impl.component.categories.RunnerBase.access$700(RunnerBase.java:58)
at com.eviware.loadui.impl.component.categories.RunnerBase$Worker.run(RunnerBase.java:749)
at com.eviware.loadui.util.dispatch.CustomThreadPoolExecutor$Worker.run(CustomThreadPoolExecutor.java:197)
at java.lang.Thread.run(Unknown Source)
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Make sure you invoke loadui with jdk7. Not sure what is the default java version used by loadui. You may see it in its logs.
  • orodoro's avatar
    orodoro
    New Contributor
    Hi Rao,
    unfortunately the log (\.loadui\logs\soapui.log in the user profile directory) doesn't state anything about the used java version.
    What is the correct way to let loadUI use a dedicated JDK? I renamed the jre directory of the loadUI 2.6.1 distribution, observed changed values via System.getProperties().list(System.out), but the error stays the same.
    Nevertheless the class not found is contained in the bundled JRE7, so it should not matter if we use JRE or JDK.

    Thanks in advance.
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    Does your installation contains jre as well?
    If you want to use external JDK, you may set environment variables to point to that installation. May be you need to look at the script that is used to invoke loadui where it may pointing to JDK and update it, note that have a backup of original script before updating.

    By the way, the class seems to be available / seen in JDK 7 api
    http://docs.oracle.com/javase/7/docs/api/
  • orodoro's avatar
    orodoro
    New Contributor
    As the output of System.getProperties().list(System.out) shows, loadUI uses either

    • the bundled JDK7, if nothing changed

    • the external JDK7, if the directory jre within loadUI installation does not exist

    • the external JDK7, if defined by environment variable JAVA in a changed loadUI.bat

    In all cases, the error is the same.
    You may try this using the loadUI 2.6.1 distribution from http://sourceforge.net/projects/loadui/ with a Groovy test step as follows:

    System.getProperties().list(System.out)
    log.warn(javax.xml.bind.DatatypeConverter.printDateTime(Calendar.getInstance()))

    which works fine in soapUI 4.5.1.
  • nmrao's avatar
    nmrao
    Icon for Champion Level 2 rankChampion Level 2
    I can see it working in soapui 4.5.1. Unfortunately, do not have loadui.
  • Hello!

    Unfortunately you cannot use that class inside the LoadUI environment. Maybe you could look at alternative methods to format time?
    For example you can look at how its done in groovy here:
    http://groovycookbook.org/basic_types/dates_times/

    That will certainly work on both LoadUI and SoapUI.

    Regards,
    Max
  • orodoro's avatar
    orodoro
    New Contributor
    Why to reinvent the wheel?
    This Java 7 class is intended to be used for XML schema datatypes, web service calls use XML schema, soapUI may be used to test web services, and loadUI may be used to stress test web services... As a test developer, I don't want to waste time in programming an already implemented function.