Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-01-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
Ice::NoObjectFactoryException

Hello,

I my slice definition I've created a sequence, that contains Test objects. In this class there is a function, which returns the 'TestSequence':

class Test;
sequence<Test> TestSequence;
class Test
{
TestSequence op();
};

The client invokes the function as follows:

TestSequence test = new TestSequence;
test = testProxy->op();


The server executes the function call:

TestSequence TestI:p()
{
TestSequence testSeq = new TestSequence;
...
TestPtr obj = new TestI();
testSeq.push_back(obj);
...
return testSeq;
}

If I run my application I get the following error message:

Test.cxx: Ice::NoObjectFactoryException:
protocol error: no suitable object factory found for '::Test'


I don't know where the problem lies. Can you help me out?

Thanks
Reply With Quote
  #2 (permalink)  
Old 09-01-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,771
If you want to transfer "Test" objects by-value, then you must install an object factory for "TestI" in the client, so that Ice knows how to instantiate new Test objects when unmarshaling.

For an example, have a look at demo/Ice/value. In the file Client.cpp, you'll find the following code:

Ice::ObjectFactoryPtr factory = new ObjectFactory;
communicator->addObjectFactory(factory, "::Printer");

You can take this as an example for how to install object factories for by-value transfer of objects.
Reply With Quote
  #3 (permalink)  
Old 09-01-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
Thanks for your fast reply.

Another question, is there any possibility to transfer objects by reference? If yes, how can I implement it in my testcase?
Reply With Quote
  #4 (permalink)  
Old 09-01-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,771
Sure, that's called "by proxy". (We try to avoid the term "reference", because it is so ambiguous.)

Sending a proxy for an object instead of the object by value is much more common. Please see the Ice documentation for more information, it has lots of examples for by-proxy transfer.
Reply With Quote
  #5 (permalink)  
Old 09-02-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
After I had a look at the demo programs, I have changed my example to 'by proxy' transfer. In my client I invoke a function as remote call. In the server the function is executed and send back a proxy [TestSequence - Object] to the client.

Slice:
****
class Test;
sequence<Test> TestSequence;
class Test
{
void op(out TestSequence testSeq);
};


Client:
*****
Ice::ObjectFactoryPtr factory = new ObjectFactory;
communicator->addObjectFactory(factory, "::Test");
TestSequence *testObject = new TestSequence;
proxy->op(*testObject);

Server:
******
void TestI:p(TestSequence &testSeq, const Ice::Current&)
{
...
TestPtr obj = new TestI();
testSeq.push_back(obj);
...
}

While executing my application I get the following message:
server: error: unknown exception in 'Ice.ThreadPool.Server'

I think it's only a small problem, but I can't see it.
Reply With Quote
  #6 (permalink)  
Old 09-02-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,771
This is still by-value transfer. If you want by-proxy transfer, you would have to change:

sequence<Test> TestSequence;

To:

sequence<Test*> TestSequence;

As for the exception, I'm afraid I don't know where this is coming from. Do you have a stack trace?

Also note that you don't need an object factory for by-proxy transfer.
Reply With Quote
  #7 (permalink)  
Old 09-02-2003
Mr.Freeze Mr.Freeze is offline
Registered User
 
 
Join Date: Aug 2003
Location: Germany
Posts: 23
Thanks, now it works fine.

I followed your hint and changed some minor problems.
I've read it in the documentation, that I don't need an object factory, but it seems I forgot it ;-).
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
NoObjectFactoryException for method-less class borax00 Help Center 7 07-20-2006 05:07 AM
"NoObjectFactoryException" when call methods in interface by java richardma Help Center 8 12-02-2005 08:46 AM


All times are GMT -4. The time now is 07:31 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.