jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: Exception while executing Java in Jmeter
Date Mon, 23 Jun 2014 15:18:51 GMT
Hi
I believe you are missing some jars .. and the documentation for BSF shows
a convoluted version history - try using Beanshell or JSR-223 instead


On Mon, Jun 23, 2014 at 8:13 AM, Abhijeet Kushe <abhijeet.kushe@gmail.com>
wrote:

> I am trying to execute Preprocessor written in Java in my Jmeter
> performance but I can getting the below exception while doing so I followed
> the steps in the following
>
> http://heshans.blogspot.com/2014/03/fixing-javalangclassnotfoundexception.html
> .
>
> I have raised this on Stackoverflow.
>
> http://stackoverflow.com/questions/24273262/exception-while-executing-java-in-jmeter
>
> java.io.FileNotFoundException: ./BSFJava4.class (No such file or directory)
>
> at java.io.FileInputStream.open(Native Method)
> at java.io.FileInputStream.<init>(FileInputStream.java:146)
> at java.io.FileInputStream.<init>(FileInputStream.java:101)
> at org.apache.bsf.util.BSFClassLoader.loadClassData(BSFClassLoader.java:65)
> at org.apache.bsf.util.BSFClassLoader.loadClass(BSFClassLoader.java:50)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
> at org.apache.bsf.util.EngineUtils.loadClass(EngineUtils.java:372)
> at org.apache.bsf.engines.java.JavaEngine.eval(JavaEngine.java:241)
> at org.apache.bsf.util.BSFEngineImpl.exec(BSFEngineImpl.java:141)
> at
> org.apache.jmeter.util.BSFTestElement.processFileOrScript(BSFTestElement.java:101)
> at
> org.apache.jmeter.modifiers.BSFPreProcessor.process(BSFPreProcessor.java:41)
> at
> org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:749)
> at
> org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:413)
> at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
> at java.lang.Thread.run(Thread.java:745)
>
> unable to load class 'BSFJava4':java.lang.ClassNotFoundException:
> BSFJava4: java.lang.ClassNotFoundException: BSFJava4
> at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
>
> Here is my code
>
> import java.io.BufferedReader;import java.io.File;import
> java.io.FileReader;import java.io.IOException;import
> java.io.PrintWriter;import java.net.URI;import
> java.net.URISyntaxException;import java.util.ArrayList;import
> java.util.Arrays;import java.util.HashMap;import
> java.util.HashSet;import java.util.List;import java.util.Map;import
> java.util.Set;
> public class SplitRequestLogs{
> public static void main(String[] args){
>
>     class Group
>     {
>         String fileName;
>         List<String> urls = new ArrayList<String>();
>         Group(String fileName)
>         {
>             this.fileName = fileName;
>         }
>     }
>
>     Map<Set<String>, Group> params = new HashMap<Set<String>, Group>();
>
>     params.put(new HashSet<String>(Arrays.asList(new String[] { "lat",
> "lng", "radius" })), new Group("6_params_40.csv"));
>     params.put(new HashSet<String>(Arrays.asList(new String[] { "lat",
> "lng", "radius", "page_number", "items_per_page" })), new
> Group("5_params_17.csv"));
>     params.put(new HashSet<String>(Arrays.asList(new String[] { "lat",
> "lng", "radius", "page_number", "items_per_page", "eligibility_cc",
> "quality_filter" })), new Group("7_params_17.csv"));
>
>     try
>     {
>
>         File dir = new
> File("/Users/akushe/POINT_SRC_CODE/places/perftest/jmeter/v3");
>         File out_dir = new
> File("/Users/akushe/POINT_SRC_CODE/places/perftest/jmeter/v3/files");
>
>         BufferedReader br = new BufferedReader(new FileReader(new
> File(dir, "allRequests.log")));
>         String s = null;
>         while ((s = br.readLine()) != null)
>         {
>             URI url = new URI(s);
>             Set<String> paramVal;
>             if (url.getQuery() != null && !url.getQuery().isEmpty())
>             {
>                 paramVal = new HashSet<String>
> (Arrays.asList(url.getQuery().split("&")));
>             }
>             else
>             {
>                 paramVal = new
> HashSet<String>(Arrays.asList(url.getPath()));
>             }
>             for (Set<String> paramsSet : params.keySet())
>             {
>                 if (paramVal.size() == paramsSet.size())
>                 {
>                     boolean found = true;
>
>                     for (String param : paramsSet)
>                     {
>                         if (!s.contains(param))
>                         {
>                             found = false;
>                             break;
>                         }
>                     }
>
>                     if (found)
>                     {
>                         params.get(paramsSet).urls.add(s);
>                         break;
>                     }
>
>                 }
>             }
>
>         }
>         br.close();
>
>         for (Group group : params.values())
>         {
>             List<String> urls = group.urls;
>
>             PrintWriter pw = new
> PrintWriter(out_dir.getCanonicalPath() + "/" + group.fileName);
>
>             for (String url : urls)
>             {
>                 pw.println(url);
>             }
>
>             pw.close();
>         }
>     }
>     catch (IOException e)
>     {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
>     }
>     catch (URISyntaxException e)
>     {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
>     }}
> }
>
>
>
> --
> Thanks & Regards
> Abhijeet S Kushe
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message