I have developed a runner module for my automation framework which will allow testers author and execute the tests using Eclipse IDE.
Now I am looking to add a module to connect to QC and upload my tests to the respective test plan. For this I am using qcutils.jar.
My Code:
public static void QCConnect()
{
File fUser = new File("lib");
File fNat = new File(fUser, "jacob-1.18-x64.dll");
// Set java library path at runtime
String javaPath = System.getProperty("java.library.path");
javaPath = javaPath+";"+fUser.getAbsolutePath()+";";
System.setProperty("java.library.path", javaPath);
String javaPath1 = System.getProperty("java.library.path");
// Load dll
System.load(fUser.getAbsolutePath()+"\\jacob-1.18-x64.dll");
IQcConnection conn = QcConnectionFactory.createConnection("https://<myqc>/qcbin");
conn.connect("user", "pass", "domain", "project");
TestClient tc = conn.getTestClient();
Test t = new Test();
t.setTestFolder(TestFolder.ROOT_FOLDER + "\\Demo");
t.setDescription("This is a QcTools4j Test");
t.setStatus("Design");
t.setName("myTest");
tc.saveTest(t)
}
Encountered Exception:
org.qctools4j.utils.DllLoader loadLibrary
SEVERE: DLL not found in the class path!
Exception in thread "main" org.qctools4j.exception.QcException: Can't get object clsid from progid
at org.qctools4j.clients.QcConnectionImpl.initConnection(Unknown Source)
at org.qctools4j.clients.QcConnectionImpl.<init>(Unknown Source)
at org.qctools4j.QcConnectionFactory.createConnection(Unknown Source)
at QCJavaConnect.main(QCJavaConnect.java:37)
Caused by: com.jacob.com.ComFailException: Can't get object clsid from progid
at com.jacob.com.Dispatch.createInstanceNative(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
at org.qctools4j.clients.QcConnectionImpl.initConnection(Unknown Source)
... 3 more
I am a looking for a solution on handling QC using java, I do not mind using any other java package.
Thanks in Advance!
Related
I have a simple project: https://github.com/MarcoLunar/native-pid-test
All what it is doing is calling getpid from C library. Project is as simple as:
public static void main(String[] args) throws Exception {
System.out.println("start");
C_lib cLib = Native.loadLibrary("c", C_lib.class);
int getpid = cLib.getpid();
System.out.println("pid = " + getpid);
System.out.println("end");
}
When launching from IDE everything works fine:
start
pid = 155080
end
When trying to build using native-image from GraalVM I got this error:
[simpletest:155323] compile: 2,597.81 ms, 2.05 GB
Fatal error:org.graalvm.compiler.graph.GraalGraphError: java.lang.NullPointerException
at node: 43|&
at method: Object com.oracle.svm.reflect.JNIGeneratedMethodSupport_getFieldOffsetFromId_5041c78d77a7b3d62103393b72fc35d80d2cc709.invoke(Object, Object[])
at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.tryCanonicalize(CanonicalizerPhase.java:397)
at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.processNode(CanonicalizerPhase.java:325)
at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.processWorkSet(CanonicalizerPhase.java:302)
at org.graalvm.compiler.phases.common.CanonicalizerPhase$Instance.run(CanonicalizerPhase.java:264)
at org.graalvm.compiler.phases.common.CanonicalizerPhase.run(CanonicalizerPhase.java:177)
at org.graalvm.compiler.phases.common.CanonicalizerPhase.run(CanonicalizerPhase.java:73)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:214)
at org.graalvm.compiler.phases.BasePhase.apply(BasePhase.java:147)
at com.oracle.svm.hosted.code.CompileQueue.doInlineTrivial(CompileQueue.java:587)
at com.oracle.svm.hosted.code.CompileQueue.access$000(CompileQueue.java:156)
at com.oracle.svm.hosted.code.CompileQueue$TrivialInlineTask.run(CompileQueue.java:284)
at com.oracle.graal.pointsto.util.CompletionExecutor.lambda$execute$0(CompletionExecutor.java:173)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.NullPointerException
at org.graalvm.compiler.nodes.calc.BinaryArithmeticNode.tryConstantFold(BinaryArithmeticNode.java:120)
I have tried many times, many different solutions ... but for now I have no more to check.
I am asking for help in repairing the project. I think this is possible, because with some configurations I have the same error as in https: //github.com/oracle/graal/issues/2261 ... where someone fixed it ... but didn't write the solution: (
I think currently JNA doesn't work in native image. You can use JNI if that's possible. Or you can use another interface to native code that will work specifically in the native images. Some info can be found in the javadoc of org.graalvm.nativeimage.c and its subpackages: https://www.graalvm.org/sdk/javadoc/index.html?org/graalvm/nativeimage/c/package-summary.html
Here's an example of using it: https://www.praj.in/posts/2020/opengl-demo-using-graalvm/
I am trying to progamatically compile and load protobuf code in an eclipse plugin but for some reason it gives me this error:
java.lang.NoClassDefFoundError: com/google/protobuf/ExtensionRegistryLite
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
I know I have the dependencies set up correctly because I am able to import ExtensionRegistroyLite and use it. Also when I run this code as a Java application it works fine. Here is how I am compiling and loading the class:
compiler.run(null, null, null, "-d", "path/to/dir, "-classpath", "protobuf-java-3.11.4.jar", "myProtoClass.java")
URL url = protoDir.toUri().toURL();
URL[] urls = new URL[]{url};
// load compiled class
ClassLoader cl = new URLClassLoader(urls);
// create object of compiled class
Class<?> cls = Class.forName(fullMessageName, true, cl); // Crashes at this line
If I scroll down further in the errors it says:
Caused by: java.lang.ClassNotFoundException: com.google.protobuf.ExtensionRegistryLite
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
Any hints as to what may be causing this would be appreciated!
I am trying to inject a .jar file in a running VM.
I've added tools.jar in the build path in eclipse, but when I try to run the injector, this error pops up. How should I add tools.jar to the project?
Full error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/VirtualMachine
at src.testinjector.MainClass.main(MainClass.java:13)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more
you may try:
Give the path to tools.jar instead of being dependent on JAVA_HOME.
Note: JAVA_HOME/path to jdk/bin/ should not have any space.
By default, the "tools.jar" classes are not loaded, your options are to either use a jdk that does load it, include tools.jar in your jar, or forcefully load it with the method below, (note: this might not work on certain jdk/jvm's)
private static void prepareAttach() throws NoSuchMethodException, MalformedURLException, InvocationTargetException, IllegalAccessException {
String binPath = System.getProperty("sun.boot.library.path");
// remove jre/bin, replace with lib
String libPath = binPath.substring(0, binPath.length() - 7) + "lib";
URLClassLoader loader = (URLClassLoader) [This Class].class.getClassLoader();
Method addURLMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
addURLMethod.setAccessible(true);
File toolsJar = new File(libPath + "/tools.jar");
if (!toolsJar.exists()) throw new RuntimeException(toolsJar.getAbsolutePath() + " does not exist");
addURLMethod.invoke(loader, new File(libPath + "/tools.jar").toURI().toURL());
}
I am trying to call java class from Groovy script in SoapUI
My Java Class
public class LogTest {
public void sayHello (){
System.out.println("Hello");
}
}
Groovy script
import LogTest;
new LogTest().sayHello()
I places the LogTest.class in ...SmartBear\SoapUI-4.6.1\bin\ext path and restart SoapUI
But still I am getting following error in SoapUI
:ERROR:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script5.groovy: 1: unable to resolve class LogTest
# line 1, column 1.
import LogTest;
^
org.codehaus.groovy.syntax.SyntaxException: unable to resolve class LogTest
# 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.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:93)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:149)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:239)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:48)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:148)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:43)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:135)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
What could be the possible root cause
Cheers
Were you able to resolve this issue? If not I ran into the same scenario, and here is how I fixed it.
I had a jar file (HelloWorldTest.jar) with the following information:
package helloworldtest;
public class HWT {
public static String Testing() {
return "Hello World!";
}
}
Notice that my file name and package name are different. Make sure when importing into Groovy you use the package name.
I used:
import helloworldtest.HWT;
log.info HWT.Testing();
Result would be:
Thu Mar 06 16:26:01 PST 2014:INFO:Hello World!
Build a jar file containing your code (LogTest)
Put that jar file in the /bin/ext directory.
This will allow you to call your code from a Groovy script.
I'm using JasperSoft Studio 5.1.0 for creating my report. This is library I used so far
commons-beanutils-1.8.3.jar commons-collections.jar
commons-digester-1.7.jar commons-javaflow-20060411.jar
commons-logging-1.1.3.jar groovy-all-1.7.5.jar itext-2.1.7.jar
jasperreports-5.1.0.jar
I'm trying using parameter and it's not showing any error when I see the preview on JasperSoft Studio, but when I try to print from my Java program it's show an error like this:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
the code I use on my program for action performed is like this
try
{
String NamaFile = "src/Laporan Penawaran.jasper";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection konek = Koneksi.getKoneksi();
HashMap hash = new HashMap();
hash.put("param1",no_tender.getText());
File file = new File(NamaFile);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hash,konek);
JasperViewer.viewReport(jasperPrint);
} catch(Exception ex) {
System.out.println(ex);
}
I just wondering maybe my jasper file is error, but when I try to erase all field and using only static text the error still exist. What am I supposed to do?
well I'm just trying to update groovy-all to version 2. And after that there's no problem at all and work smoothly :)
note: make sure you are using a specific version for each library, somehow the new one it's not always match for your report
FIX for me:
i changed type of fields from java.math.BigInteger to java.math.BigDecimal
Below is whole stack trace by which I was able to identify the issue.
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:782)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:458)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnHeader(JRVerticalFiller.java:502)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:284)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:651)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:308)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:582)
at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:181)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1234)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1208)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1577)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149)
... 8 more
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
at ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237.evaluateEstimated(calculator_ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237:272)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:295)
... 14 more
**Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.BytecodeInterface8**
at java.lang.ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
FIX Worked for me
I have updated all reports/subreports language property from "groovy" to "Java" and it's fixed .
Though it looks like workaround I suggest to update library which will include the missing class in jasperreports-5.1.2.jar.