Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8026497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:30:38+00:00 2026-06-04T23:30:38+00:00

I followed this guide https://developer.mozilla.org/en/Java_in_Firefox_Extensions to enable me to access java classes in a

  • 0

I followed this guide https://developer.mozilla.org/en/Java_in_Firefox_Extensions to enable me to access java classes in a firefox plugin (I am actually adding them to a user-extension for selenium ide).

Everything works great with the guide above, until my java code tries to initialise imported objects…

So if I import jtidy to try to clean the html, as soon as I initialise it I get a java.lang.reflect.InvocationTargetException exception. Interestingly I can initialise the jtidy class in the javascript and then pass this through and it works until I try to parse the dom. I think this all has to do with permissions, but I haven’t worked enough with Live Connect to know where to go from here.

My code is as follows:

Javascript

PageBot.prototype.locateElementByLabelText = function(labelText, inDocument) {
    //var pageTitle = inDocument.getElementsByTagName('title').item(0).nodeName;
    var pageTitle = inDocument.title;
    LOG.warn("Title = "+ pageTitle);
    var pageSource = inDocument.getElementsByTagName('html')[0].innerHTML;
    LOG.warn("I have the page source");
    var xpathValue = getXpathUsingJavaFnc(labelText, pageTitle, pageSource);
    LOG.warn("Xpath = "+xpathValue);
    return this.locateElementByXPath(xpathValue, inDocument);
};


Selenium.prototype.doLoadProject = function(locator, paramString) {
    LOG.warn("starting to load Load Project "+locator + " " + paramString);
    try{
    var result = inst.initialiseProject(locator, Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('AUTOMATED_HOME')+"/");
    }catch(e){
    LOG.warn(e.message);
    }
    LOG.warn("finished Load Project");
    LOG.warn(result);
};




var basePath = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get('AUTOMATED_HOME');
 var fullPath = 'file:///' + basePath + '/ScenarioFramework-jar-with-dependencies.jar';

LOG.warn("full path = "+fullPath);
var extensionUrl = "file:///" + basePath +'/javaFirefoxExtensionUtils.jar';  
var classLoaderJarpath = extensionUrl;  
var myJarpath = fullPath;   
//var testTidy = "file:///" + basePath +'/jtidy-r938.jar'; 

var urlArray = []; 
urlArray[0] = new java.net.URL(myJarpath);  
urlArray[1] = new java.net.URL(classLoaderJarpath);  
urlArray[2] = new java.net.URL(testTidy); 
var cl = java.net.URLClassLoader.newInstance(urlArray);  

policyAdd(cl, urlArray);  
var classToLoad = "scenario.framework.main.SeleniumRunner";
var aClass = cl.loadClass(classToLoad);
//var aClass = java.lang.Class.forName(classToLoad, true, cl);
var inst = aClass.newInstance();

LOG.warn("finished loading add Java");



function getXpathUsingJavaFnc(eleName, pageTitle, pageSource) {
LOG.warn("Testing getXpath");
    try{    
        var xpathValue = inst.findElementUsingName(eleName, pageTitle, pageSource);

    }catch(e){
        //var jvm = Components.classes["@mozilla.org/oji/jvm-mgr;1"].getService(Components.interfaces.nsIJVMManager);
        //jvm.showJavaConsole();
        logExc(e);
    }
return xpathValue;
};


function policyAdd (loader, urls) {  
    try {       
        var str = 'edu.mit.simile.javaFirefoxExtensionUtils.URLSetPolicy';  
        var policyClass = java.lang.Class.forName(  
           str,  
           true,  
           loader  
    );  
    var policy = policyClass.newInstance();  
    policy.setOuterPolicy(java.security.Policy.getPolicy());  
    java.security.Policy.setPolicy(policy);  
    policy.addPermission(new java.security.AllPermission());  
    for (var j=0; j < urls.length; j++) {  
        policy.addURL(urls[j]);  
    }  
    java.lang.System.setSecurityManager(null);

var t = java.lang.Thread.currentThread().setContextClassLoader(cl);

    }catch(e) {  
        logExc(e);
    }  
}  


function logExc(e) {
    try {
        while(e != null) {
            LOG.warn(e);
            e = e.getCause();
        }
        LOG.warn(netscape.javascript.JSUtil.getStackTrace(e));
    } catch(exp) {
         LOG.warn("exception while logging exception");
         LOG.warn(exp);
        LOG.warn("exception being logged");
        LOG.warn(e);
    }
}

Java:

public static String findElementUsingName(String Name, String pageTitle, String html){
     org.w3c.tidy.Tidy tidy = new org.w3c.tidy.Tidy();
     return "//input[@id='password']";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:30:39+00:00Added an answer on June 4, 2026 at 11:30 pm

    Restart Firefox after each compile

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
Device: Samsung Galaxy Tab I followed this guide: http://developer.android.com/resources/articles/window-bg-speed.html I put the background image
I followed http://wiki.orbeon.com/forms/doc/developer-guide/xforms-with-java-applications and successfully got separate deployments working. I would like to create
I can't install Ruby Eclipse Plugin. I just followed the guide from https://help.ubuntu.com/community/EclipseIDE But
I'm using Eclipse 3.5.2 and when I followed the steps on this tutorial( http://developer.android.com/guide/developing/tools/adt.html
I have followed this guide: http://www.danielbaulig.de/socket-ioexpress/ to link express.js to socket.io and it works
I followed this guide here perfectly and have gone through it again but when
I followed this tutorial: https://github.com/EllisLab/CodeIgniter/wiki/PDF-generation-using-dompdf However, I can't seem to set the path right.
My site was working fine until I followed this guide, http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-ubuntu-9.10 to set up
I followed this guide: http://wiki.unto.net/setting-up-clojure-and-slime Which walked me through the steps of building Clojure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.