when i have run java code in server it will showing below exception:
java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:15990" "listen,resolve")
here is my java code:
public String getSessionCookies(String user, String pass,String loginUrl,String phantomPath) {
StringBuilder builder=new StringBuilder();
try{
PhantomJSDriverService service = new PhantomJSDriverService.Builder().usingAnyFreePort().usingPhantomJSExecutable(new File(phantomPath)).build();
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true);// not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,phantomPath);
driver = new PhantomJSDriver(service,DesiredCapabilities.phantomjs());
driver.get(loginUrl);
System.out.println(driver.getTitle());
driver.findElement(By.id("login:loginName")).sendKeys(user);
driver.findElement(By.id("login:password")).sendKeys(pass);
waitForJQueryProcessing(driver, 5);
driver.findElement(By.xpath("/html/body/div[3]/div/div[1]/div[1]/div[15]/div[2]/form/div[2]/button[1]")).click();
Thread.sleep(10000);
driver.get("https://ecf.ca2.uscourts.gov/");
Thread.sleep(10000);
Set<org.openqa.selenium.Cookie> allCookies=driver.manage().getCookies();
for ( org.openqa.selenium.Cookie loadedCookie : allCookies) {
builder.append(String.format("%s->%s, ", loadedCookie.getName(),loadedCookie.getValue()));
//System.out.println(String.format("%s->%s, ", loadedCookie.getName(),loadedCookie.getValue()));
}
driver.close();
}catch(Exception e){
System.out.println(e.getStackTrace());
writeFile(e.toString(),phantomPath);
}
return builder.toString();
}
above code run perfectly in local system but when i have to call in server it will generate above exception.
please provide your suggestion.
thanks