mTurk | AWSService.java无法找到StrictSSLProtocolSocketFactory

时间:2015-12-24 03:41:16

标签: amazon-web-services apache-httpcomponents mechanicalturk

使用net.ettinsmoor:java-aws-mturk:1.6.2 maven导入。当我运行一个基本的教程脚本时,我发现无法找到类StrictSSLProtocolSocketFactory,它是从AWSService.java调用的。

我已导入org.apache.httpcomponents:httpclient:4.41commons-httpclient-3.1。无法理解为什么找不到这门课。请指教。

堆栈追踪:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/contrib/ssl/StrictSSLProtocolSocketFactory
    at com.amazonaws.mturk.service.axis.AWSService.<clinit>(AWSService.java:104)
    at com.conceptual.mturk.mTurkService.main(mTurkService.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.contrib.ssl.StrictSSLProtocolSocketFactory
    at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

Java类:

package com.conceptual.mturk;

import com.amazonaws.mturk.requester.HIT;
import com.amazonaws.mturk.service.axis.RequesterService;
import com.amazonaws.mturk.service.exception.ServiceException;
import com.amazonaws.mturk.util.PropertiesClientConfig;

/**
 * Created by astrorobotic on 12/23/15.
 */
public class mTurkService {

    private RequesterService service;

    // Defining the attributes of the HIT to be created
    private String title = "Answer a question";
    private String description =
            "This is a HIT created by the Mechanical Turk SDK.  Please answer the provided question.";
    private int numAssignments = 1;
    private double reward = 0.05;

    public static void main(String[] args) {

        mTurkService mturk = new mTurkService();

        mturk.service = new RequesterService(new PropertiesClientConfig("com/conceptual/mturk.properties"));
        double balance = mturk.service.getAccountBalance();
        System.out.println("Got account balance: " + RequesterService.formatCurrency(balance));

        if (mturk.createHelloWorld()) {
            System.out.println("Success.");
        } else {
            System.out.println("You do not have enough funds to create the HIT.");
        }
    }


    public boolean createHelloWorld() {
        try {

            // The createHIT method is called using a convenience static method of
            // RequesterService.getBasicFreeTextQuestion that generates the QAP for
            // the HIT.
            HIT hit = service.createHIT(
                    title,
                    description,
                    reward,
                    RequesterService.getBasicFreeTextQuestion(
                            "What is the weather like right now in Seattle, WA?"),
                    numAssignments);

            System.out.println("Created HIT: " + hit.getHITId());

            System.out.println("You may see your HIT with HITTypeId '"
                    + hit.getHITTypeId() + "' here: ");
            System.out.println(service.getWebsiteURL()
                    + "/src/main/mturk/preview?groupId=" + hit.getHITTypeId());

        } catch (ServiceException e) {
            System.err.println(e.getLocalizedMessage());
        }
        return true;
    }
}

0 个答案:

没有答案