Archived
package com.zeroc.Ice not found Ice 3.7 Java Ubuntu 16.04
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
Comments
-
Hi,
Where did you copy/get the
Ice.jarfile 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/zerocprefix, theIce.jarfile contains the Ice runtime for the old Java mapping.Cheers,
Benoit.0 -
-
Hi Mauris,
You just need to install and use the correct
ice.jarfile (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-javapackage - see https://doc.zeroc.com/display/Ice37/Using+the+Linux+Binary+Distributions.Best regards,
Bernard0 -
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
0 -
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
0 -
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 more0 -
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
}0 -
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,
Bernard0 -
Python client :
import sys, Ice
import MP3with 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(); } }}
0 -
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)}
0
