Home Bug Reports

NoObjectFactoryException with class that has no methods

MarcinKMarcinK Member Marcin KobylarzOrganization: Posterus Sp. z o. o.Project: Remote user database
Hi,

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
facet: 
operation: changeEmailAddress
Ice.NoObjectFactoryException
    reason = ""
    type = "::interfacesice::EmailAddressIce"
	at IceInternal.BasicStream.readObject(BasicStream.java:1418)
	at IceInternal.BasicStream.readPendingObjects(BasicStream.java:1632)
	at pl.posterus.posso.interfacesice._IdentityIceDisp.___changeEmailAddress(_IdentityIceDisp.java:328)
	at pl.posterus.posso.interfacesice._IdentityIceDisp.__dispatch(_IdentityIceDisp.java:487)
	at IceInternal.Incoming.invoke(Incoming.java:166)
	at Ice.ConnectionI.invokeAll(ConnectionI.java:2045)
	at Ice.ConnectionI.message(ConnectionI.java:977)
	at IceInternal.ThreadPool.run(ThreadPool.java:575)
	at IceInternal.ThreadPool.access$100(ThreadPool.java:12)
	at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:951)

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");
ini.properties = 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.

Greetings

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    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:
    Ice.Package.interfacesice=pl.posterus.posso.interfacesice
    

    For more information, see Section 10.15 of the manual.

    Regards,
    Mark
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    mes wrote: »
    Ice.Package.interfacesice=pl.posterus.posso.interfacesice
    

    Sorry, that should be:
    Ice.Package.interfacesice=pl.posterus.posso
    
  • MarcinKMarcinK Member Marcin KobylarzOrganization: Posterus Sp. z o. o.Project: Remote user database
    Not a surprise, you're right :). This helped.

    Thank you.
Sign In or Register to comment.