This forum has been archived. Please start a new discussion on GitHub.

NoObjectFactoryException with class that has no methods


I don't know if this is a bug or maybe a I have missed something but:

I declared a method-less class:
class EmailAddressIce
        string emailAddress;
        string displayName;

I use this class as a input parameter to method changeEmail:
interface IdentityIce
        // ............
        EmailAddressChangeRequestIce* changeEmailAddress(EmailAddressIce emailAddress);
        // ............

I invocated the method changeEmailAddress from php with an object as an argument and on my java server I got this exception:
26.09.08 10:08:23:218 warning: Ice.ThreadPool.Server-0: dispatch exception:
identity: pl.posterus.posso.core.Identity/faf68534-df80-40d6-9fb5-9954735dbff3:9
operation: changeEmailAddress
    reason = ""
    type = "::interfacesice::EmailAddressIce"
	at IceInternal.BasicStream.readObject(
	at IceInternal.BasicStream.readPendingObjects(
	at pl.posterus.posso.interfacesice._IdentityIceDisp.___changeEmailAddress(
	at pl.posterus.posso.interfacesice._IdentityIceDisp.__dispatch(
	at IceInternal.Incoming.invoke(
	at Ice.ConnectionI.invokeAll(
	at Ice.ConnectionI.message(
	at IceInternal.ThreadPool.access$100(
	at IceInternal.ThreadPool$

In chapter 10.14.4 one can read:
Finally, keep in mind that if a class has only data members, but no operations, you need not create and register an object factory to transmit instances of such a class. Only if a class has operations do you have to define and register an object factory.

I made a test and in my communicator initialisation I did the following:
InitializationData ini = new InitializationData();
Properties properties = Util.createProperties();
properties.setProperty("Ice.Trace.Protocol", "1"); = properties;

communicator = Ice.Util.initialize(ini);

// line below makes the exception disappear		
communicator.addObjectFactory(EmailAddressIce.ice_factory(), EmailAddressIce.ice_staticId());

And voila! This solved the issue.

So now my doubt is: is this a bug, a documentation mislead, or maybe I missed something important here?

My Ice version is 3.3.0.



  • mes
    mes California

    When you change the package of the generated code, the Ice run time is no longer able to translate a Slice type id such as ::interfacesice::EmailAddressIce into its mapped class name. Specifically, the Ice run time looks for a class named interfacesice.EmailAddressIce but can't find it, which is the reason for the NoObjectFactoryException.

    The solution is to add property definitions that aid the Ice run time in making these translations. In the example you provided, you would define a configuration property like this:

    For more information, see Section 10.15 of the manual.

  • mes
    mes California
    mes wrote: »

    Sorry, that should be:
  • Not a surprise, you're right :). This helped.

    Thank you.