简体   繁体   English

AWS Lambda函数chromedriver无法执行

[英]aws lambda function chromedriver is not executable

I've been stuck with this error "Caused by: java.lang.IllegalStateException: The driver is not executable: /var/task/chromedriver" When I deploy my jar project into aws lambda function. 当我将jar项目部署到aws lambda函数中时,我一直被这个错误所困扰"Caused by: java.lang.IllegalStateException: The driver is not executable: /var/task/chromedriver" The project works fine on my local machine, but it seems like aws can't execute chromedriver for some reason. 该项目在我的本地计算机上运行良好,但似乎aws由于某种原因无法执行chromedriver。 My chromedriver file is placed in the resources folder. 我的chromedriver文件位于资源文件夹中。

Following is my test config file: 以下是我的测试配置文件:

@Configuration
public class TestConfig {

    private static final Logger l = LoggerFactory.getLogger(TestConfig.class);

    private String chromeDriver = org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS ? "chromedriver.exe" : "chromedriver" ;

    public WebDriver getDriver(){
        URL resource = getClass().getClassLoader().getResource(chromeDriver);
        String chromePath = null;
        try {
            chromePath = Paths.get(resource.toURI()).toString();
        } catch (URISyntaxException e) {
            l.info("cannot find chromedriver in resources");
        }
        System.setProperty("webdriver.chrome.driver", chromePath);
        return new ChromeDriver();
    }
}

I have both chromedriver and chromedriver.exe, and I've tried to chmod 777 the file, but have no success. 我同时拥有chromedriver和chromedriver.exe,但我尝试对文件进行chmod 777,但没有成功。

Lambda has a limit of 300 seconds and memory limit of 1536MB. Lambda的限制为300秒,内存限制为1536MB。

It is a very bad approach for you to try and launch a chromedriver in your lambda function. 尝试在lambda函数中启动chromedriver是非常糟糕的方法。 What you should be doing is setting up a Selenium grid and then using RemoteWebDriver to launch a Chrome browser in remote machine 您应该做的是设置Selenium网格,然后使用RemoteWebDriver在远程计算机中启动Chrome浏览器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AWS Lambda Java函数Spring上下文初始化 - AWS Lambda Java function Spring context initialization 具有 spring 自动装配依赖项的 aws lambda 函数 - aws lambda function with spring autowired dependencies Spring Cloud Function on AWS lambda 中的多个功能 - Multiple functions in Spring Cloud Function on AWS lambda AWS Lambda: java.lang.ClassNotFoundException 即使在 AWS Lambda 函数中提到了完整路径 - AWS Lambda: java.lang.ClassNotFoundException even if the full path is mentioned in the AWS Lambda function 发布到 AWS IoT 时 Java Lambda 函数卡住 - Java Lambda Function stuck when publishing to AWS IoT 在 JDK 17 Docker 映像中运行 AWS Lambda / Spring Cloud Function - Running AWS Lambda / Spring Cloud Function in JDK 17 Docker image Spring Cloud Function 能否与 AWS Lambda 基础镜像一起使用 - Can Spring Cloud Function be used with AWS Lambda base image 使用 SpringBootRequestHandler 访问 Function 内的 AWS Lambda 上下文? - Accessing AWS Lambda Context inside Function using SpringBootRequestHandler? Spring Cloud Function on AWS Lambda Platform 全局异常处理 - Global Exception Handling in Spring Cloud Function on AWS Lambda Platform 无法通过 Springs 框架在 AWS Lambda 函数内注入依赖项 - Not able to inject dependencies inside the AWS Lambda function through Springs framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM