JSR 223 PreProceesor错误:令牌解析错误:第41行第1列的词汇错误

时间:2016-12-29 00:08:18

标签: java jmeter

我有一个java代码并试图在Jmeter中的JSR223 Preprocessor中运行它们来清理服务器中的一些数据。当我使用jsr223运行java脚本时,我发现了错误消息:

  

import java.io.BufferedReader; import java.io.File;进口   java.io.FileOutputStr。 。 。 ''令牌解析错误:词汇错误   第41行,第1列。遇到" ..

异常详情:

Problem in JSR223 script javax.script.ScriptException: Sourced file: inline evaluation of: ``import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStr . . . '' Token Parsing Error: Lexical error at line 41, column 1. Encountered: "\u2002" (8194), after : "": <at unknown location> in <unknown file>

以下是代码:

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.UUID;

import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicSessionCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.securitytoken.AWSSecurityTokenServiceClient;
import com.amazonaws.services.securitytoken.model.Credentials;
import com.amazonaws.services.securitytoken.model.GetSessionTokenRequest;
import com.amazonaws.services.securitytoken.model.GetSessionTokenResult;
import com.amazonaws.util.json.JSONArray;
import com.amazonaws.util.json.JSONException;
import com.amazonaws.util.json.JSONObject;
import com.couchbase.client.java.Bucket;
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.CouchbaseCluster;
import com.couchbase.client.java.document.json.JsonArray;
import com.couchbase.client.java.env.CouchbaseEnvironment;
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment;
import com.couchbase.client.java.query.N1qlQuery;
import com.couchbase.client.java.query.N1qlQueryResult;
import com.couchbase.client.java.query.N1qlQueryRow;
import com.couchbase.client.java.view.ViewQuery;
import com.amazonaws.services.s3.model.GetObjectRequest;
import com.amazonaws.services.s3.model.ObjectListing;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult;
import com.amazonaws.services.s3.model.S3Object;

public class BasicSession {
  private static String bucketName = "fis-uiux-images";

  public static void main(String[] args) throws IOException, JSONException {

   CouchbaseEnvironment env = DefaultCouchbaseEnvironment.builder().connectTimeout(60000).build();

    String jsonValue = null;
    String width = null;
    String pathFormed = "";
    String height = null;
    String resource = null;

    String actualResourceId = null;
    BasicSessionCredentials basicSessionCredentials = new BasicSessionCredentials("ASIAJ54RURPJEXTWGW7A",
        "GBeDHB0M6yG5RpnRvKzaXbVnk8qzBur8igRMiXVC",
        "FQoDYXdzEDgaDNrLLE2ta12hepvWyyKhAq6QMnQIag1BbV+3XUAcTDEDsDUZKEt2Aa7grdud4EkcR+szuFu+ArPDNLdaJg534qyp2UHfIDjH7e1MXjIXQXeVukT9ZLQjhIKyKNCQ17+s4qmyXoBOKOGIlUWdvSBLqeTCdtd2EdwmdxBmM3RkugoBYCkAZd1Kgqq/RhB5RMjtw2SdQx7+WzSugXzZCCzavaV6eLKcEmpCOIl8KZT3ALx8zDVL5swkwexlN/EB/NL9GlqGOsdc9zMG6O36Qw7B6O9qpewo/SHs2hPqK02skD++Q0frLlo+jnSk+5HYTEjdhDCbLttxoFV0Lm80Bz4MgWmNxI+ynvs3pfyRgtilHedYhlPQrBVRMVBjHb9WGQTH9Sl7cUYij9/6AWS58LAkv8oyoaRwwU=");
    AmazonS3Client s3 = new AmazonS3Client(basicSessionCredentials);

    Cluster cluster = CouchbaseCluster.create(env, "dev-int-couchbase1.aeg.cloud");
    // Bucket bucket = cluster.openBucket("programs");
    Bucket bucket = cluster.openBucket("uiux-image");
    System.out.println("bucket connected" + bucket.toString());

    N1qlQueryResult queryResult = bucket.query(N1qlQuery.simple("SELECT * FROM `uiux-image`"));
    System.out.println("vvv" + queryResult.allRows());
    for (N1qlQueryRow row : queryResult) {
      System.out.println(row.value().getObject("uiux-image") + "\n");
      try {
        System.out.println(
            "prg image value iss" + row.value().getObject("uiux-image").getString("resourceId") + "\n");
        resource = row.value().getObject("uiux-image").getString("resourceId");

        if ((row.value().getObject("uiux-image").getString("resourceId")).startsWith("prg")) {
          System.out.println("HEYY!!IT STARTS WITH PRGG");
          actualResourceId = resource.substring(3, 6);
          for (int i = 0; i < row.value().getObject("uiux-image").getArray("uiUxImages").size(); i++) {
            jsonValue = row.value().getObject("uiux-image").getArray("uiUxImages").get(i).toString();
            JSONObject parser = new JSONObject(jsonValue);
            System.out.println("parser valuee is" + parser.getString("width") + "\n");
            width = parser.getString("width");
            height = parser.getString("height");
            pathFormed = "prg/" + actualResourceId + "/" + (resource.substring(3)) + "/" + "Poster" + "/"
                + resource + "_" + "Poster" + "_" + width + "_" + height + ".jpg";

            System.out.println("PATH FORMED ISS" + pathFormed);
            s3.deleteObject(bucketName, pathFormed);
          }

        } else {
          System.out.println("IT DID NOT START WITH 'PRG!!!'");
          continue;
        }

      } catch (NullPointerException exception) {
        continue;
      } catch (AmazonServiceException ase) {
        System.out.println("Caught an AmazonServiceException, which means your request made it"
            + "to Amazon S3, but was rejected with an error response for some reason.");
        System.out.println("Error Message:" + ase.getMessage());
        System.out.println("HTTP Status Code:" + ase.getStatusCode());
        System.out.println("AWS Error Code:" + ase.getErrorCode());
        System.out.println("Error Type:" + ase.getErrorType());
        System.out.println("Request ID:" + ase.getRequestId());
        /*
         * if(ase.getErrorCode()) {
         * 
         * }
         */
      } catch (AmazonClientException ace) {
        System.out.println("Caught an AmazonClientException, which means the client encountered"
            + "a serious internal problem while trying to communicate with S3, "
            + "such as not being able to access the network.");
        System.out.println("Error Message: " + ace.getMessage());
      }
      // Test. For example, get object keys for a given bucket.

    }
    ObjectListing objects = s3.listObjects(bucketName);
    System.out.println("value iss" + s3.doesBucketExist(bucketName));
    System.out.println("No. of Objects = " + objects.getObjectSummaries().toString());
  }

  private static void deleteObject() {

  }

}

我的代码中有任何问题吗?或关于JSR223 Preprocessor的语法问题?

0 个答案:

没有答案