Archived

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

"NoObjectFactoryException" when call methods in interface by java

when I call a method in interface that was generated by C++ by java, It generated exception as follows:

Ice.NoObjectFactoryException
reason = (null)
type = "::WASP::PlayerInfo"

The phenomena is:
when the value returned is empty, the exception above not appear. But when the value not empty, the exception appear. why???

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Please see [thread=1697]this thread[/thread] regarding our support policy on the forums.

    Thanks,

    Benoit.
  • Update over

    I've done it!
  • benoit
    benoit Rennes, France
    Hi,

    Thanks!

    It would be useful to see the definition of "::WASP::PlayerInfo". I'll assume it's defined as an abstract Slice class.

    If the returned value is null, no object needs to be created so it's expected to not get this exception. However, if it's not null, the process receiving the object over the wire needs to instantiate it. The instantiation is delegated to the object factory. Did you register an object factory for the "::WASP::PlayerInfo" class?

    Please see the Ice manual for more information on object factories, the Section 6.14.5 for instance. I also recommend you to have a look at the demo/Ice/value demo from your Ice distribution, it shows how to register object factories.

    Benoit.
  • need factory?

    my slice definition as follows:
    class Player
    {
    int iActId;
    int iId;
    string sPlayerId;
    ......
    }
    class PlayerInfo extends Player
    {
    int iSupVoteNum;
    int iOppVoteNum;
    };

    sequence<PlayerInfo> SeqPlayInfo;

    interface trans
    {
    SeqPlayInfo GetVoteObjInfo( int iActId, int iPage );
    }

    ===========================================
    The methods I call by java client is 'GetVoteObjInfo' in interface trans, No methods in class PlayerInfo, so the server implement by C++ doesn't need factory.
    right?
  • benoit
    benoit Rennes, France
    It's not clear from your definitions if the Player class has some methods or not. If it has some methods, then it's abstract and the PlayerInfo class is also abstract since it extends it. So you'll need to register an object factory for the PlayerInfo type if this is the case.

    Benoit.
  • hi

    thanks

    the Player class hasn't methods
  • benoit
    benoit Rennes, France
    Ok, so you don't need to register an object factory :).

    When the Ice for Java runtime receives the "::WASP::PlayerInfo" type, it transforms it to the WASP.PlayerInfo Java class name. It then tries to load this class and instantiates it. If it can't find the class, it throws an Ice.ObjectFactoryException.

    Is your CLASSPATH correctly setup? Is the WASP.PlayerInfo class in your CLASSPATH? If it's not this might be the reason for this exception. Also, please post the full stack trace of the exception if possible, this would help to figure out where exactly the exception coming from.

    One last thing, if you're using a specific package for your Java generated classes, you will need to set the Ice.Default.Package or Ice.Package.<module> configuration property. See Section 10.15 and 10.15.2 in particular for more information about this.

    Benoit.
  • problem has been solved, thanks a lot!

    thanks:D :D:D:D:D:D