Service Virtualization

  • 1.  Getting ExceptioninitializerError while using SV as Code

    Posted Aug 19, 2017 03:10 PM
      |   view attached

    While running JUnit test case for SV as code, I am getting the below error, even though all the SV as Code jars and lib for jars mentioned in github repository have been configured in build path. Pls see below for the error:

     

    java.lang.ExceptionInInitializerError
    at com.ca.svcode.protocols.http.agent.HttpAgentProtocol.getInterceptor(HttpAgentProtocol.java:77)
    at com.ca.svcode.protocols.http.agent.HttpAgentProtocol.getInterceptor(HttpAgentProtocol.java:48)
    at com.ca.svcode.engine.IpvConnectedServer.start(IpvConnectedServer.java:135)
    at com.ca.svcode.engine.IpvProtocolServer.withConnection(IpvProtocolServer.java:67)
    at com.ca.svcode.protocols.http.fluent.impl.HttpTransactionBuilderImpl.buildTransaction(HttpTransactionBuilderImpl.java:77)
    at com.ca.svcode.protocols.http.fluent.AbstractHttpTransactionBuilder.doReturn(AbstractHttpTransactionBuilder.java:132)
    at TestClass.testSimpleHttpGetWithResponseCodeAndStringBody(TestClass.java:25)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
    Caused by: java.lang.RuntimeException: Cannot load initialize agent with HTTP Protocol.
    at com.ca.svcode.protocols.http.agent.HttpInterceptor.<clinit>(HttpInterceptor.java:45)
    ... 32 more
    Caused by: com.ca.svcode.agent.AgentException: Failed to initialize agent for protocol
    at com.ca.svcode.agent.Agent.initialize(Agent.java:76)
    at com.ca.svcode.protocols.http.agent.HttpInterceptor.<clinit>(HttpInterceptor.java:43)
    ... 32 more
    Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.tools.attach.VirtualMachine
    at com.ca.svcode.agent.AgentLoader.loadAgent(AgentLoader.java:62)
    at com.ca.svcode.agent.Agent.initialize(Agent.java:70)
    ... 33 more
    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 java.lang.ClassLoader.loadClass(Unknown Source)
    at com.ca.svcode.agent.AgentLoader.dynamicLoadOfVirtualMachine(AgentLoader.java:87)
    at com.ca.svcode.agent.AgentLoader.loadAgent(AgentLoader.java:60)
    ... 34 more

     

    I have referred to this thread: Error when trying to create and run a sample test using SV as code 

    Attached in the list of jars which i have configured in build path.

    However, I am still facing the same issue. Please suggest.



  • 2.  Re: Getting ExceptioninitializerError while using SV as Code
    Best Answer

    Broadcom Employee
    Posted Aug 22, 2017 09:20 PM

    Hi,

    I got the same error message when I tried to use SV as Code with JRE in project library.
    And I did same thing at the comment dated 2017/08/22 8:21 in https://communities.ca.com/thread/241781202-error-when-trying-to-create-and-run-a-sample-test-using-sv-as-code. (Used JDK jar files on behalf of JRE libraries.)

     

    And the error message was not appeaered.

    Please see the screenshot the JRE libraries in my environment.

     

    Cheers,