5

So I've been working on updating old extensions for use with FF4 and Gecko 2 but I am having some issues where I am getting an error that says, classID missing or incorrect for component....

Has anyone else had a similar issue or know of how to get around this?

function jsshellClient() {
  this.classDescription = "sdConnector JavaScript Shell Service";
  this.classID = Components.ID("{54f7f162-35d9-524d-9021-965a3ba86366}");
  this.contractID = "@activestate.com/SDService?type=jsshell;1"
  this._xpcom_categories = [{category: "sd-service", entry: "jsshell"}];
  this.name = "jsshell";
  this.prefs = Components.classes["@mozilla.org/preferences-service;1"]
      .getService(Components.interfaces.nsIPrefService)
      .getBranch("sdconnector.jsshell.");
  this.enabled = this.prefs.getBoolPref("enabled");
  this.port = this.prefs.getIntPref("port");
  this.loopbackOnly = this.prefs.getBoolPref("loopbackOnly");
  this.backlog = this.prefs.getIntPref("backlog");
}
jsshellClient.prototype = new session();
jsshellClient.prototype.constructor = jsshellClient;

When calling generateNSGetFactory on the prototype for this it gives an error in the Error Console in FF4 complaining about the classID. I'm pretty sure that nothing else is using the same GUID so I don't see the problem.

Tyler
  • 21,762
  • 11
  • 61
  • 90
Jesus Ramos
  • 22,940
  • 10
  • 58
  • 88

2 Answers2

2

An important change in JS XPCOM components in Fx4 is that they now need to be registered in the chrome.manifest, see this page of documentation on the changes.

erikvold
  • 15,988
  • 11
  • 54
  • 98
  • I know that. I have this registered in the chrome.manifest file the problem is when I try to create the NSGetFactory. – Jesus Ramos Oct 24 '10 at 17:30
  • var NSGetFactory = XPCOMUtils.generateNSGetFactory([jsshellclient]); tries to create this factory and it complains about the CID being incorrect. – Jesus Ramos Oct 24 '10 at 17:31
  • and you made the required changes to the chrome.manifest? and you're sure that those changes are correctly done? if not then can you please post your chrome.manifest? – erikvold Oct 24 '10 at 20:48
  • 1
    I fixed that issue now (stupid mistake on my part, forgot to apply function) but my extension will not run, it just initializes the js files and does nothing. Do I need to specify an app-startup or something so the extension .start() gets called? – Jesus Ramos Oct 26 '10 at 01:38
0

The special properties used by XPCOMUtils, like classID, contractID, and so on, have to be defined on Class.prototype, not in the constructor function, as you did: https://developer.mozilla.org/en/XPCOMUtils.jsm#Class_declaration

As for the other question, you posted in a comment, please post it in a different question, if it's still relevant, with the necessary code provided.

Nickolay
  • 31,095
  • 13
  • 107
  • 185