Archived

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

IceStorm Java client: cannot find symbols

Hi,

I'm writing a client to an IceStorm publisher using Java, and I'm pretty much going by the manual on this, as it's my first such IceStorm client. I'm having problems in two areas.

First, in the manual, it says that my class needs to extend a _MonitorDisp. Manual example:
class MonitorI extends _MonitorDisp {

I cannot find any _MonitorDisp class to extend. In my files that were generated from slice2java I have a _NVACMonitorDisp class, but I cannot extend it, as it has final methods:
[javac] /u/dgresh/dev/ice/NVAC/client/NVACObserverClient.java:8: nvac.NVACObserverClient is not abstract and does not override abstract method registerChanged(java.lang.String,int,Ice.Current) in NVAC._NVACMonitorOperations
    [javac] public final class NVACObserverClient extends _NVACMonitorDisp {

I assume this leads up to my second problem. The manual states I need to declare a new Monitor object and instantiate it to my Client class:
Monitor monitor = this;

I cannot find any Monitor symbol, and I get a compiler error telling me so. Does "Monitor" stand for something else, such as my generated Monitor class? If so, I also get a compiler error when I try that, as NVACMonitor.class, which was generated from slice2java, is an interface, not a class.

I'm not getting errors with anything else; I'm just stuck on these two and I'm uncertain where to go from here.

Any help would be greatly appreciated.

Thanks,
Dan

Comments

  • benoit
    benoit Rennes, France
    Hi,

    You should post the Slice file that you're using. It looks like you define a Slice interface named "NVACMonitor" instead of "Monitor".

    The compilation error indicates that you didn't override the abstract methods from the _NVACMonitorOperations generated Java interace in the NVACObserverClient class. You need to override these methods.

    Before trying to write your own subscriber, I recommend you to take a close look at the demo located in the demo/IceStorm/clock directory from your Ice distribution. I'm sure it will answer many of your questions.

    Cheers,
    Benoit.
  • I will take a look at the demo and follow your advice, then come back with any more questions.

    Thank you for the assistance,
    Dan
  • Hello again,

    I took a look at the demo files and they were indeed very helpful. I overrode the appropriate method from my _MonitorDisp class, and it allowed me to compile. It seems however that I have a problem subscribing to the topic I need to subscribe to, and this throws an Exception at runtime:
    Topic Manager Proxy: Success
    NVAC TopicName retrieved succesfully
    Ice.OperationNotExistException
        id.name = "NVAC.TopicName"
        id.category = ""
        facet = ""
        operation = "subscribeAndGetPublisher"
            at IceInternal.Outgoing.invoke(Outgoing.java:148)
            at IceStorm._TopicDelM.subscribeAndGetPublisher(_TopicDelM.java:273)
            at IceStorm.TopicPrxHelper.subscribeAndGetPublisher(TopicPrxHelper.java:307)
            at IceStorm.TopicPrxHelper.subscribeAndGetPublisher(TopicPrxHelper.java:277)
            at nvac.NVACObserverClient.init(Unknown Source)
            at nvac.NVACObserverClient.main(Unknown Source)
    

    **Note: the first two lines of the compiler output are System.out.printlns I added to make sure I could establish the TopicManager proxy and retrieve the TopicName succesfully.

    I'm not sure what I am doing wrong here, as I've checked my code against the manual and the demo code. Am I creating the servant wrong maybe?

    Here is the relevant portion of my code:
    Ice.ObjectAdapter adapter = ic.createObjectAdapter("MonitorAdapter");
    			NVACMonitor monitor = this;
    			IceStorm.TopicPrx topic = null;
    
    			try {
    				topic = topicManager.retrieve("NVAC.TopicName");
    				System.err.println("NVAC TopicName retrieved succesfully");
    			} catch (IceStorm.NoSuchTopic e) {
    				System.err.println("No such topic");
    				topic = topicManager.create("NVAC.TopicName");
    			}
    
    			Ice.ObjectPrx subscriber = adapter.addWithUUID(monitor).ice_oneway();
    			try {
    				Map<String, String> qos = null;
    				topic.subscribeAndGetPublisher(qos, subscriber);
    			} catch (IceStorm.AlreadySubscribed e) {
    				System.err.println("Already subscribed to this topic");
    				e.printStackTrace();
    			} catch (IceStorm.BadQoS e) {
    				System.err.println("Quality of Service (QoS) set incorrectly");
    				e.printStackTrace();
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    
    			adapter.activate();
    			ic.waitForShutdown();
    			topic.unsubscribe(subscriber);
    

    Thank you for your help,
    Dan
  • matthew
    matthew NL, Canada
    This says that the slice interfaces are not compatible. That is your client is using a different version of the Slice interface than your server. Another possibility is that the object with id "NVAC.TopicName" is not a topic manager (you don't show the code where you get the topicManager -- if you are using a checkedCast this cannot occur).

    My guess is that you are running against an old version of IceStorm. What version of Ice does the IceStorm service come from? What version of Ice is your client using?
  • Hi,

    I am retrieving the values for the topicName and topicManager from a config file, which reads like this:
    Ice.Trace.Network=0
    
    Ice.Default.Locator=IceGrid/Locator:default -h localhost -p port
    IceStorm.TopicManager.Proxy=IceStorm/TopicManager:tcp -p port -h localhost
    
    MonitorAdapter.Endpoints=tcp
    
    NVAC.TopicName=NVACRegisters1
    
    /* Define IceStorm proxy */
    			Ice.ObjectPrx base = ic.propertyToProxy("IceStorm.TopicManager.Proxy");
    
    			/* Define the TopicManager for IceStorm */
    			topicManager = IceStorm.TopicManagerPrxHelper.checkedCast(base); //topicManager is a TopicManagerPrx
    

    About the version information, my client IS running from a newer version than the server is. The server is running on Ice-3.1.0, according to --version. My client is running on Ice-3.2b.

    Is the version causing the problem or is my loading of the topic manager? If it is the version, is there any way to correct this?

    Thanks,
    Dan
  • Hi again,

    I've figured out that it certainly seems to be the version. When I use slice2java from Ice-3.1.0 and try to compile the generated .java files with the Ice-3.2b Ice.jar, it will not work.

    For some reason, the version of Ice-3.1.0 we have does not include an Ice.jar file. I looked in the archives for it and even downloaded Ice-3.1.0, but the version I downloaded did not contain the Ice.jar file (the lib and bin directories were empty). Is there a place where I may download this from?

    Thanks,
    Dan
  • marc
    marc Florida
    Please try your application (client/server/IceStorm) with the latest Ice 3.2.0. Our free support here in these forums is limited to the latest version, except if the problem is not version-specific. For commercial support, which also covers older versions, please contact us at info@zeroc.com.
  • Hello,

    I searched around on Zeroc.com a bit and found the version of Ice.jar from Ice-3.1.0 and compiled with that, and everything seems to be working fine now.

    Thank you for your help,
    Dan