Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-28-2004
vsonnathi vsonnathi is offline
Registered User
 
Name: Venkat Ramana
Organization: Amazon.com
Project: Prototype
 
Join Date: May 2004
Posts: 39
package metadata directive - ClassCast Exception

Hi,

I am getting ClassCast Exception when I use the package metadata directive.

I am using Ice 1.5.1 distribution running on Win2K pro, JDK 1.4.2.

Here's my Slice definition:
Printer.ice
----------------
[["javaackage:com.testing"]]

module print {
class Data {
string name;
int number;
};

interface Printer {
void printString(Data s);
};
};


PrinterI.java
----------------
package com.testing.print;

import Ice.Current;

/**
* The <code>PrinterI </code>
*
* @author Venkat Ramana Sonnathi (HTC Global Svc. Inc.)
* @version 1.0
*/
public class PrinterI extends _PrinterDisp{
public void printString(Data s, Current __current) {
System.out.println("s = " + s.name);
}
}

Server.java
---------------
public class Server {
public static void
main(String[] args) {
int status = 0;
Ice.Communicator ic = null;
try {
ic = Ice.Util.initialize(args);
Ice.ObjectAdapter adapter
= ic.createObjectAdapterWithEndpoints("SimplePrinter Adapter", "default -p 10000");
Ice.Object object = new PrinterI();
adapter.add(object,
Ice.Util.stringToIdentity("SimplePrinter"));
adapter.activate();
ic.waitForShutdown();
} catch (Ice.LocalException e) {
e.printStackTrace();
status = 1;
} catch (Exception e) {
System.err.println(e.getMessage());
status = 1;
} finally {
if (ic != null)
ic.destroy();
}
System.exit(status);
}
}

Client.java
--------------
public class Client {
public static void
main(String[] args) {
int status = 0;
Ice.Communicator ic = null;
try {
ic = Ice.Util.initialize(args);
Ice.ObjectPrx base = ic.stringToProxy("SimplePrinter:default -p 10000");
PrinterPrx printer
= PrinterPrxHelper.checkedCast(base);
if (printer == null)
throw new Error("Invalid proxy");
Data data = new Data();
data.name = "Testing";
printer.printString(data);
} catch (Ice.LocalException e) {
e.printStackTrace();
status = 1;
} catch (Exception e) {
System.err.println(e.getMessage());
status = 1;
} finally {
if (ic != null)
ic.destroy();
}
System.exit(status);
}
}

When run the client, I get the following error:

Ice.UnknownLocalException
unknown = "Ice.NoObjectFactoryException
type = ":rint:ata"
at IceInternal.BasicStream.patchReferences(BasicStrea m.java:1604)
at IceInternal.BasicStream.readObject(BasicStream.jav a:1365)
at IceInternal.BasicStream.readPendingObjects(BasicSt ream.java:1487)
at com.testing.print._PrinterDisp.___printString(_Pri nterDisp.java:59)
at com.testing.print._PrinterDisp.__dispatch(_Printer Disp.java:102)
at IceInternal.Incoming.invoke(Incoming.java:152)
at IceInternal.Connection.message(Connection.java:117 3)
at IceInternal.ThreadPool.run(ThreadPool.java:689)
at IceInternal.ThreadPool.access$100(ThreadPool.java: 12)
at IceInternal.ThreadPool$EventHandlerThread.run(Thre adPool.java:1103)
Caused by: java.lang.ClassCastException
at com.testing.print.DataHolder$Patcher.patch(DataHol der.java:32)
at IceInternal.BasicStream.patchReferences(BasicStrea m.java:1600)
... 9 more
"
at IceInternal.Outgoing.invoke(Outgoing.java:158)
at com.testing.print._PrinterDelM.printString(_Printe rDelM.java:26)
at com.testing.print.PrinterPrxHelper.printString(Pri nterPrxHelper.java:32)
at com.testing.print.PrinterPrxHelper.printString(Pri nterPrxHelper.java:19)
at Client.main(Client.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main (AppMain.java:78)

Looks like the package metadata is not added to the object identities.

Thanks,
--Venkat.
Reply With Quote
  #2 (permalink)  
Old 09-28-2004
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 962
Hi Venkat,

This is a known problem that will be fixed in the next release. As a workaround, you can define and install object factories for classes. Unfortunately, this workaround isn't possible for user exceptions.

Take care,
- Mark
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
OSX package on Intel MAC ctennis Bug Reports 2 11-23-2006 08:32 PM
Another solution about package mapping in Java rc_hz Comments 4 08-23-2006 09:33 PM
Metadata directives bartley Help Center 1 02-03-2006 01:35 PM
Reference for Metadata tags Nis Baggesen Help Center 3 09-13-2004 08:04 AM
c++ metadata sylvain Help Center 5 08-06-2003 09:10 AM


All times are GMT -4. The time now is 04:24 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.