Skip to content

[🐛 Bug]: Selenium stoped working with IDEA and Ant (AccessControlException) #15617

Open
@newsgrep

Description

@newsgrep

Description

I were trying to do

Using the recent Selenium with Java 17, IDEA 2024.3.5 and the IDEA Ant-Plugin (Ant 1.10.14) on Linux.

Problem also reproducable on an other machine with IDEA 2023.3.2 and Ant 1.10.12/1.9.16 on Windows 10.

I expected to happen

Browser opens without problems.

actually happend

Browser does not start, I tested Chrome and Firefox with Selenium 3.31 and 3.14.

context

This was working fine with 3.13 and stoped working with 3.14.
I guess the root cause is some were in: [java] remove netty http client and use native java client by default

Maybe the java.security.manager is interfearing, but passing -Djava.security.manager=allow or -Djava.security.manager= did not work.
Setting fork="true" in the build.xml or using Java 21 can be used to work arround this error but is no solution.

stacktrace and error message

FEIN: Exception: newSession access denied ("java.net.URLPermission" "http://localhost:30709/session" "POST:Content-Type,User-Agent")
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.

at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:220)
	at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:155)
	at org.apache.tools.ant.taskdefs.Java.run(Java.java:892)
	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:232)
	at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:136)
	at org.apache.tools.ant.taskdefs.Java.execute(Java.java:109)
	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
	at org.apache.tools.ant.Task.perform(Task.java:350)
	at org.apache.tools.ant.Target.execute(Target.java:449)
	at org.apache.tools.ant.Target.performTasks(Target.java:470)
	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
	at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
	at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
	at org.apache.tools.ant.Main.runBuild(Main.java:818)
	at org.apache.tools.ant.Main.startAnt(Main.java:223)
	at org.apache.tools.ant.Main.start(Main.java:190)
	at org.apache.tools.ant.Main.main(Main.java:274)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at com.intellij.rt.ant.execution.AntMain2.main(AntMain2.java:31)
Caused by: java.lang.SecurityException: access denied ("java.net.URLPermission" "http://localhost:28213/session" "POST:Content-Type,User-Agent")
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:566)
	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:123)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:456)
	at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
	at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55)
	at org.openqa.selenium.remote.http.jdk.JdkHttpClient.lambda$executeAsync$1(JdkHttpClient.java:384)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.security.AccessControlException: access denied ("java.net.URLPermission" "http://localhost:28213/session" "POST:Content-Type,User-Agent")
	at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:485)
	at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:453)
	at java.net.http/jdk.internal.net.http.Exchange.checkPermissions(Exchange.java:729)
	at java.net.http/jdk.internal.net.http.Exchange.responseAsyncImpl(Exchange.java:382)
	at java.net.http/jdk.internal.net.http.Exchange.responseAsync(Exchange.java:378)
	at java.net.http/jdk.internal.net.http.MultiExchange.responseAsyncImpl(MultiExchange.java:408)
	at java.net.http/jdk.internal.net.http.MultiExchange.lambda$responseAsync0$2(MultiExchange.java:341)
	at java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1150)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1773)
	at java.net.http/jdk.internal.net.http.HttpClientImpl$DelegatingExecutor.execute(HttpClientImpl.java:158)
	at java.base/java.util.concurrent.CompletableFuture.completeAsync(CompletableFuture.java:2673)
	at java.net.http/jdk.internal.net.http.MultiExchange.responseAsync(MultiExchange.java:294)
	at java.net.http/jdk.internal.net.http.HttpClientImpl.sendAsync(HttpClientImpl.java:659)
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:553)
	... 10 more

Reproducible Code

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Main {
    public static void main(String[] args) {
        WebDriver driver = new ChromeDriver();
    }
}

Debugging Logs

Field can not be longer than 65536 characters
Please tell me what logger configuration (class and level) would be the most helpfull for this issue.

ℹ️ Last known working version: 4.8.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions