java.security.AccessControlException:拒绝访问(“java.net.SocketPermission”“localhost:10648”“listen,resolve”)

时间:2014-12-26 09:34:12

标签: java coldfusion phantomjs coldfusion-10

我从CF调用一个jar文件。在CF内部,我成功创建了一个java类对象。当我打算在那个时候调用我的函数时,会产生以下错误:

  

java.security.AccessControlException:访问被拒绝   (" java.net.SocketPermission"" localhost:10648"" listen,resolve")

如何克服此异常?我已将代码部署在CF 10服务器中。这是我的login.cfm文件代码:

<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>

这是我的java代码:

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

请提供您的建议。我该如何解决这个例外?

1 个答案:

答案 0 :(得分:0)

猜测是一个权限问题。编辑client.policy或server.policy以授予读写权限。

更多here