java.security.AccessControlException: access denied (“java.net.SocketPermission” “localhost:10648” “listen,resolve”)

こ雲淡風輕ζ 提交于 2019-12-10 20:51:51

问题


I am calling a jar file from CF. Inside CF I have created a java class object successfully. When I am going to call my function that time, it generates the following error:

java.security.AccessControlException: access denied ("java.net.SocketPermission" "localhost:10648" "listen,resolve")

How can I overcome this exception? I have deployed our code in a CF 10 server. Here is my login.cfm file code:

<cfsetting requesttimeout="1000000"> 

<!---Setting phantomJS path start--->
<cfset phantompath = #ExpandPath("./")# & "phantomjs\phantomjs.exe">    
<cfoutput>#phantompath#</cfoutput>

<!---Setting phantomJS path ends--->
<cfset sessionCookies="">

<!---Script for setting JAR file and creating java class object--->
<cfscript>
    paths = arrayNew(1);
    paths[1] = expandPath("CFDevshop\lib\Counsel_Cookies_Phantom.jar");
    writeDump(paths);
    loader = createObject("component", "javaloader.JavaLoader").init(paths);
    writedump(loader);
    classObject = loader.create("counsel_cookies.Counsel_Cookies").init();
    writedump(classObject);

    try{
        sessiondata=classObject.getSessionCookies  ("XXX","XXX","https://paser.login.csologin/login.jsf","phantomjs.exe");
    } 
    catch(Any e) { 
        WriteOutput("<p>An Expression exception was thrown.</p>");
        WriteOutput("<p>#e.Message#</p>");
    }
    writedump(sessiondata);                 
</cfscript>

Here is my java code:

public String getSessionCookies(String user, String pass,String loginUrl,String phantomPath) {
         StringBuilder builder=new StringBuilder();        
    try{            

        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(caps);
        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);

        Set<org.openqa.selenium.Cookie> allCookies=driver.manage().getCookies();
        builder.append(" : Thakre2");
        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()));
        }           

    } catch(Exception e){
        writeFile(e.toString(),logfilepath);
    }

    return builder.toString();
}

Please provide your suggestions. How can I resolve this exception?


回答1:


I am guessing its a permission issue. Edit client.policy or server.policy to grant read write permissions.

More here



来源:https://stackoverflow.com/questions/27655288/java-security-accesscontrolexception-access-denied-java-net-socketpermission

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!