Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question: How to reliably create a XPCOM component for use with javaxpcom?

2 views
Skip to first unread message

Martini

unread,
Jul 31, 2006, 2:41:47 PM7/31/06
to

I'm trying to prototype what seems to be very simple and after reading
through numerous web pages, postings and examples I'm at a loss.

I want to create a XPCOM component in C++ that does not integrate with
mozilla or xul in any way (and indeed runs independent of the
existence of mozilla) and I want to then access the component through
java.

After a previous attempt to get javaxpcom to work with standalone XPCOM
I was kindly instructed to use xulrunner for the javaxpcom support.
Thanks for the help there to everyone.

I downloaded the gecko-sdk and xulrunner packages for win32, created a
java test application based on the outdated
mozilla/extensions/java/xpcom/tests examples that gets a IMutableArray
with success. Perfect.

I then created a test component and copied it (.dll/.xpt) to the
xulrunner/components. I tried to register from the xulrunner directory
as follows

../gecko-sdk/bin/regxpcom.exe -x . components
I get Registration failed: (80520012) components (ok, it can't find the
file)
so I try
../gecko-sdk/bin/regxpcom.exe -x .
d:\\workspaces\\XPCOM_Experiments\\xulrunner\\
I get Registration successful for
d:\workspaces\XPCOM_Experiments\xulrunner\

Looks good, but the *.dat files are untouched.

So I delete the test component and xpt file that I added and try the
above again.... same issue.

Hmmm..... it's unclear as to what I should do at this point since the
documentation is fragmented, not clear and mostly out of date.

This makes me wonder - is it even possible to do what I want, to use
XPCOM as a cross platform component model to create binary components,
and to use JavaXPCOM as a way to access these components.

If it is possible, I would appreciate any tips on how I can get this to
work.


Thanks in advance and best regards,

Martin

Martini

unread,
Aug 1, 2006, 1:22:21 PM8/1/06
to
I just realized there's a more succinct way to describe my problem:
I have created a XPCOM standalone component that provides some service
that I want to access in my self contained XUL dev environment.
How do I register it so that it is available for use just like the
components in xulrunner/components

The obvious way of registering with regxpcom is not resulting in the
updated components/*.dat files.

I may be just doing something stupid, but I can't tell what it could
be.

Any help, suggestions or RTFM pointers (with directions to manual) are
welcome.

Thanks in advance.

Martin

Benjamin Smedberg

unread,
Aug 2, 2006, 9:27:27 AM8/2/06
to
Martini wrote:
> I just realized there's a more succinct way to describe my problem:
> I have created a XPCOM standalone component that provides some service
> that I want to access in my self contained XUL dev environment.
> How do I register it so that it is available for use just like the
> components in xulrunner/components

What environment is this? A XULRunner app, or embedded? If it's a XR app,
all you need to do is put the component in <app>/components and force
reregistration of components. That's best done by changing the buildid in
application.ini

In embedded contexts, you will need to specify a directory to look for
components during XPCOM initialization. You may also need to force component
registration programmatically (nsIComponentRegistrar.autoRegister(null)).

> The obvious way of registering with regxpcom is not resulting in the
> updated components/*.dat files.

No toolkit-based apps should ever use regxpcom. It is a holdover from the
days when we kept compreg.dat in the application directory and is totally
unreliable.

--BDS

Martini

unread,
Aug 9, 2006, 10:00:10 AM8/9/06
to
Benjamin,

Thanks for the response - that makes sense to me right now.
I forced re-registration programmatically as you suggested which works
well.

Now the next steps are really puzzling me - the test component that I
have implements a generic factory of an object that implements the
dsTestEntryPoint interface through the macro:
NS_GENERIC_FACTORY_CONSTRUCTOR(TestEntryPoint)

What I am seeing though is that if I attempt to create the instance via

componentManager.createInstanceByContractID(NS_TESTCOMPONENT_CONTRACTID,
null, dsTestEntryPoint.DSTESTENTRYPOINT_IID);

I get an exception being thrown from the JavaXPCOM layer.


java.lang.NoClassDefFoundError: org/mozilla/xpcom/dsTestEntryPoint
at org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native
Method)
at
org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java:140)
at $Proxy4.queryInterface(Unknown Source)
at TestCustomComponent.main(TestCustomComponent.java:124)


I'm not sure what to make of it.


Martin

Martini

unread,
Aug 9, 2006, 10:05:27 AM8/9/06
to
The test component that I
have implements a generic factory of an object that implements the
dsTestEntryPoint interface through the macro:
NS_GENERIC_FACTORY_CONSTRUCTOR(TestEntryPoint)

What I am seeing though is that if I attempt to create the instance
via


componentManager.createInstanceByContractID(NS_TESTCOMPONENT_CONTRACTID,
null, dsTestEntryPoint.DSTESTENTRYPOINT_IID);

I get an exception being thrown from the JavaXPCOM layer.


java.lang.NoClassDefFoundError: org/mozilla/xpcom/dsTestEntryPoint
at org.mozilla.xpcom.internal.XPCOMJavaProxy.callXPCOMMethod(Native
Method)
at

org.mozilla.xpcom.internal.XPCOMJavaProxy.invoke(XPCOMJavaProxy.java:140)
at $Proxy4.queryInterface(Unknown Source)
at TestCustomComponent.main(TestCustomComponent.java:124)


I'm not sure what to make of it. Does anyone have experience with
this?


Martin

0 new messages