package com.zeroc.Ice not found Ice 3.7 Java Ubuntu 16.04

nerosneros Member Mauris DupondOrganization: CERIProject: middleware
edited December 2017 in Help Center

I have a problem in java files compilation on Ubuntu (slice2java from Slice definition was successfully generated)

The error is "package com.zeroc.Ice does not exist"

The compilation command line is " javac -d pathTo/classes -classpath /pathTo/classes:/pathTo/Ice.jar Serveur.java ClientServeurI.java Morceau.java /PathTo/generated/MP3/*.java "

All code source is in attachment

Best Answers

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    Where did you copy/get the Ice.jar file from? Are you sure it's the Ice jar file for the new Java mapping and not the old mapping (see https://doc.zeroc.com/display/Ice37/New+Features+in+Ice+3.7#NewFeaturesinIce3.7-NewJavaMapping)?

    You can check the content of the Ice.jar file with:

    jar tf <path>/Ice.jar
    

    If the classes don't start with the com/zeroc prefix, the Ice.jar file contains the Ice runtime for the old Java mapping.

    Cheers,
    Benoit.

  • bernardbernard Jupiter, FLBernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi Mauris,

    You just need to install and use the correct ice.jar file (with a lowercase i).

    One option is to use Maven Central, as described on https://doc.zeroc.com/display/Ice37/Building+Ice+Applications+in+Java.

    On Ubuntu 16.04, another option is to install the libzeroc-ice3.7-java package - see https://doc.zeroc.com/display/Ice37/Using+the+Linux+Binary+Distributions.

    Best regards,
    Bernard

  • joegeorgejoegeorge Jupiter, FloridaJoe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    The ice jar files are installed into /usr/share/java. For example, the Ice 3.7.0 jar file is /usr/share/java/ice-3.7.0.jar.

  • nerosneros Mauris DupondOrganization: CERIProject: middleware
    Accepted Answer
    Please, I would like solve the problem.
    I need to have a good mark for this work to valid my semester
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    you need to add /usr/share/java/ice-3.7.0.jar to the classpath when running the application try:

    java -cp classes:/usr/share/java/ice-3.7.0.jar Serveur
    
  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    Hi Mauris,

    The source you upload has the following structure

    source
      classes
        TP3
           Serveur.class
    

    Try running this command from source directory

  • xdmxdm La Coruña, SpainJose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    You are using the wrong object identity in the client proxy

    base = communicator.stringToProxy("clientserveurAdapter:default -p 10000")
    

    Should be

    base = communicator.stringToProxy("clientserveur:default -p 10000")
    

Answers

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi,

    Where did you copy/get the Ice.jar file from? Are you sure it's the Ice jar file for the new Java mapping and not the old mapping (see https://doc.zeroc.com/display/Ice37/New+Features+in+Ice+3.7#NewFeaturesinIce3.7-NewJavaMapping)?

    You can check the content of the Ice.jar file with:

    jar tf <path>/Ice.jar
    

    If the classes don't start with the com/zeroc prefix, the Ice.jar file contains the Ice runtime for the old Java mapping.

    Cheers,
    Benoit.

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    The classes don't start with, could you tell me how can I do ?

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware
    edited December 2017

    Please, I'm a student and I must solve the problem

    jar tf Ice.jar > log.txt

    log.txt 43.4K
  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    Hi Mauris,

    You just need to install and use the correct ice.jar file (with a lowercase i).

    One option is to use Maven Central, as described on https://doc.zeroc.com/display/Ice37/Building+Ice+Applications+in+Java.

    On Ubuntu 16.04, another option is to install the libzeroc-ice3.7-java package - see https://doc.zeroc.com/display/Ice37/Using+the+Linux+Binary+Distributions.

    Best regards,
    Bernard

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    Where can I find the right ice.jar ?

    I have already installed libzeroc-ice3.7-java

  • joegeorgejoegeorge Jupiter, FloridaAdministrators, ZeroC Staff Joe GeorgeOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Accepted Answer

    The ice jar files are installed into /usr/share/java. For example, the Ice 3.7.0 jar file is /usr/share/java/ice-3.7.0.jar.

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware
    edited December 2017

    Compilation command line :

    javac -d /path/classes -classpath /path/classes:/usr/share/java/ice-3.7.0.jar Serveur.java ClientServeurI.java Morceau.java /path/generated/MP3/*.java

    Compilation result into log25.txt, jar tf /usr/share/java/ice-3.7.0.jar into log2.txt

    Please help I don't have much time

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware
    edited December 2017

    Compilation problem solved, I have a problem in trying of execute the Server (impossible of load the main class TP3.Serveur)

    Execution command line : java TP3/Serveur

    Source code attached

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    I have a problem when I execute Serveur

    java Serveur

    Exception in thread "main" java.lang.NoClassDefFoundError: com/zeroc/Ice/Object
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544 )
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
    Caused by: java.lang.ClassNotFoundException: com.zeroc.Ice.Object
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware
    Accepted Answer
    Please, I would like solve the problem.
    I need to have a good mark for this work to valid my semester
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    you need to add /usr/share/java/ice-3.7.0.jar to the classpath when running the application try:

    java -cp classes:/usr/share/java/ice-3.7.0.jar Serveur
    
  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    Result : impossible to find or load main class Serveur

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    Right you need to include the package name of Serveur

    java -cp classes:/usr/share/java/ice-3.7.0.jar TP3.Serveur
    
  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    Result : impossible to find or load main class TP3.Serveur

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    If this can help, the content of the folder in which I run the command :

    ClientServeurI.class Morceau.class MP3 Serveur.class TP3

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    Hi Mauris,

    The source you upload has the following structure

    source
      classes
        TP3
           Serveur.class
    

    Try running this command from source directory

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    I don't find the "source" folder

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    The server is running, no error for the moment in execution.

    Thanks you

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    I'am newbie with Ice, all my pure Java cod works, but I don't have tested the Ice code part yet.
    If I understand it correctly, thanks to Ice work with Slice definition, the server method call mechanism is invisible ? For the client point of view, its like a simply local method call ?

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    I have a problem with my Python, client.

    Client in attachment

    A simply server connection test failed with this error :

    Traceback (most recent call last):
    File "client.py", line 6, in
    printer = MP3.ClientServeurPrx.checkedCast(base)
    File "/home/hector/Téléchargements/python/ClientServeur_ice.py", line 133, in checkedCast
    return _M_MP3.ClientServeurPrx.ice_checkedCast(proxy, '::MP3::ClientServeur', facetOrContext, context)
    Ice.ObjectNotExistException: exception ::Ice::ObjectNotExistException
    {
    id =
    {
    name = clientserveurAdapter
    category =
    }
    facet =
    operation = ice_isA
    }

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff

    Seems you attach the wrong file

  • bernardbernard Jupiter, FLAdministrators, ZeroC Staff Bernard NormierOrganization: ZeroC, Inc.Project: Ice ZeroC Staff

    Hi Mauris,

    Did you try the Ice demos? They include a build system and instructions on how to run the client and server, so it should make everything easier for you.

    For this latest ObjectNotExistException error, ObjectNoExistException means the object adapter in your server could not find an object with the specified identity. The exception shows the object identity specified by your client is "clientserverAdapter". Check if this matches the identity for the target object in your server (the identity in your call to "add" on the object adapter).

    Best regards,
    Bernard

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    Python client :

    import sys, Ice
    import MP3

    with Ice.initialize(sys.argv) as communicator:
    base = communicator.stringToProxy("clientserveurAdapter:default -p 10000")
    printer = MP3.ClientServeurPrx.checkedCast(base)
    if not printer:
    raise RuntimeError("Invalid proxy")

    Java server :

    package TP3;

    public class Serveur {

       public static void main(String[] args) throws Exception
        {
            try(com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args))
            {
    
                com.zeroc.Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("clientserveurAdapter", "default -p 10000");
                com.zeroc.Ice.Object object = new ClientServeurI();
                adapter.add(object, com.zeroc.Ice.Util.stringToIdentity("clientserveur"));
                adapter.activate();
                communicator.waitForShutdown();
            }
        }
    

    }

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware
    I can't find the problem, cloud you help ?
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Accepted Answer

    You are using the wrong object identity in the client proxy

    base = communicator.stringToProxy("clientserveurAdapter:default -p 10000")
    

    Should be

    base = communicator.stringToProxy("clientserveur:default -p 10000")
    
  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    I have a problem with my Python client

    def ajouterMorceau():
    global titre;
    global id;
    global serveur;
    titre = raw_input("Veuillez entrer le nom du morceau : ");
    '''resultat = serveur.getIdMorceauByTitre(titre);'''
    interprete = raw_input("Veuillez entrer l'interprete : ");
    genre = raw_input("Veuillez entrer le genre : ");
    url = raw_input("Veuillez entrer l'URL : ");
    print "Ajout morceau..."
    id = serveur.addMorceau(titre)
    print id
    serveur.setInterpreteMorceauById(int(id),interprete)
    serveur.setGenreMorceauById(id,genre)
    serveur.setURLMorceauById(id,url)

    Result :

    Traceback (most recent call last):
    File "UIclientV2.py", line 143, in
    menuPrinci();
    File "UIclientV2.py", line 31, in menuPrinci
    ajouterMorceau();
    File "UIclientV2.py", line 85, in ajouterMorceau
    serveur.setInterpreteMorceauById(int(id),interprete)
    File "/home/hector/Téléchargements/python/ClientServeur_ice.py", line 72, in setInterpreteMorceauById
    return _M_MP3.ClientServeur._op_setInterpreteMorceauById.invoke(self, ((id, interprete), context))
    Ice.UnknownException: exception ::Ice::UnknownException
    {
    unknown = java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at TP3.ClientServeurI.setInterpreteMorceauById(ClientServeurI.java:43)
    at MP3.ClientServeur._iceD_setInterpreteMorceauById(ClientServeur.java:113)
    at MP3.ClientServeur._iceDispatch(ClientServeur.java:261)
    at com.zeroc.IceInternal.Incoming.invoke(Incoming.java:226)
    at com.zeroc.Ice.ConnectionI.invokeAll(ConnectionI.java:2695)
    at com.zeroc.Ice.ConnectionI.dispatch(ConnectionI.java:1282)
    at com.zeroc.Ice.ConnectionI.message(ConnectionI.java:1193)
    at com.zeroc.IceInternal.ThreadPool.run(ThreadPool.java:416)
    at com.zeroc.IceInternal.ThreadPool.access$500(ThreadPool.java:12)
    at com.zeroc.IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:785)
    at java.lang.Thread.run(Thread.java:748)

    }

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    Problem solved, index error in Java Interface

  • nerosneros Member Mauris DupondOrganization: CERIProject: middleware

    After small debug of Java server, all the project is working, thanks a lot

Sign In or Register to comment.