Archived

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

slice2java task source code

xdm
xdm La Coruña, Spain
Hello Zeroc

is slice2javaTask code open

Comments

  • mes
    mes California
    Yes, look in the ant subdirectory of the IceJ archive.

    - Mark
  • slice2javaTask

    I tried to build build.xml file. I got the below error

    taskdef class Slice2JavaTask cannot be found
  • matthew
    matthew NL, Canada
    You need to ensure that ant-jar.jar is in your CLASSPATH.
  • slice2javaTask

    Yes, the ant-1.6.5.jar is in the path. I'm using the MyEclipse IDE, It has got default ant. Still it is saying the taskdef class Slice2JavaTask cannot be found.
  • matthew
    matthew NL, Canada
    You need to ensure that ant-ice.jar (not ant-jar.jar, or ant-1.6.5.jar) from the Ice distribution, which contains the implementation for the slice2java task, is your in CLASSPATH.
  • build.xml

    When I was trying to build build.xml. I got this error

    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/tools/ant/Main


    Thanks
  • xdm
    xdm La Coruña, Spain
    Hi Lakshmi

    From the error message seems that your ant distribution is not working fine.

    What is the output of ant -version in your system

    if ant is property installed you should see
    Apache Ant version 1.7.0 compiled on December 13 2006

    Note you need ant 1.7.0 or later for build Ice Java, quoted from Ice-3.3.0/java/INSTALL
    The Ice for Java build system requires Apache Ant 1.7.0 or later. Ant
    is available at the link below:

    Apache Ant - Welcome

    Regards,
    José
  • build.xml

    I'm using Myelipse ide . So ant comes automaticlaly with that right?
  • xdm
    xdm La Coruña, Spain
    Hi lakshmiK,

    I´m not use Eclipse Ide and can help you with that, by the way seems that the problem is the ant eclipse integration, you should check Eclipse help for ant builds.

    Regards,
    José
  • builtinsequences

    How would I set the path for the Builtinsequences.ice in the build.xml file?

    Could you please let me know the examples ?

    thanks
  • xdm
    xdm La Coruña, Spain
    Hi LakshmiK

    You need to use appropiate includepath in your Slice2Java task
        <target name="generate">
            <!-- Create the output directory for generated code -->
            <mkdir dir="generated"/>
            <slice2java outputdir="generated">
                <fileset dir="slice" includes="*.ice"/>
                [B]<includepath>
                    <pathelement path="c:\Ice-3.3.0-VC90\slice"/>
                </includepath>[/B]
            </slice2java>
        </target>
    

    Then in your slice definitions you only need to wrote
    #include <Ice/BuiltinSequences.ice>
    

    Regards,
    José
  • Sequences

    I'm Learning ICe.
    Is sequence<FileSystemPr::PrStruct>optPr; same as
    sequence<PrStruct>optPr; If not, what is the differnce between two?

    I need some examples simliar to this.

    thanks.
  • matthew
    matthew NL, Canada
    They may or may not be the same, depending on the module in which they are being referenced. One is using a fully qualified name, the other is not.
  • Sequences

    sequence<FileSystemPr::PrStruct>optPr

    what is :: mean ?
  • xdm
    xdm La Coruña, Spain
    Hi lakshmiK

    :: is used to separate module names in slice definitions;
    module A
    {
       Interface B
       {
             //...
       };
    };
    

    To refer to interface B in ohter module than A you should use
    Module C
    {
         interface Foo
         {
             ::A::B* getB();
         };
    };
    

    But inside module A you can simple use B
    module A
    {
         interface Foo
         {
             B* getB();
         };
    };
    

    in both case getB returns a proxy to an interface of type B defined inside module A.

    The concept is similar to what namespaces are in c++ or packages in java.

    I first edited your post, i moved the reply to a new post

    Regards,
    Jose
  • slice2javaTask

    Thanks for your reply. In the below code. the interface Reser has a method getdata right? Is it going to return the PStruct or void?

    Actually I want to call this method in my java file.
    First.ice

    module printer
    {
    enum enumtype{type1,dataType,DetailsType};

    struct PrStruct
    {
    enumtype memberType;
    string errorMsg;
    PRData data;
    };

    }





    second.ice


    #include <First.ice>

    module ReserInfo
    {

    enum SearchType {Exact,Contain};
    sequence<First::PnrStruct> OptPr;
    struct Info
    {
    string RecLoc;

    string CreationDateTime;
    };
    sequence<Info> MList;

    exception PrException
    {
    string errMessage;
    };

    exception PrNotFound extends PrException
    {
    };

    exception OldPrException extends PrException
    {
    };


    Interface Reser
    {


    ["nonmutating"] idempotent First::PStruct getdata(string RecLoc) throws PrException;
    OptPr setPr(Ice::ByteSeq Pr) throws PrException;

    };

    };


    #endif

    thanks
  • matthew
    matthew NL, Canada
    It returns First::PStruct, not void. If it was to return a void it would be void getdata.

    I strongly suggest you read the slice mapping chapter of the Ice manual. It answers all of these questions, and more. Without studying this chapter, along with the java mapping chapter then you'll never really understand how things hang together.
  • Connection error

    I'm trying to connect to the Iceserver. I got the below errors:

    Ice.ConnectionRefusedException
    error = 0
    at IceInternal.Network.doConnect(Network.java:284)
    at IceInternal.TcpConnector.connect(TcpConnector.java:25)
    at IceInternal.OutgoingConnectionFactory.create(OutgoingConnectionFactory.java:308)
    at IceInternal.RoutableReference.createConnection(RoutableReference.java:379)
    at IceInternal.DirectReference.getConnection(DirectReference.java:192)
    at Ice._ObjectDelM.setup(_ObjectDelM.java:258)
    at Ice.ObjectPrxHelperBase.__getDelegate(ObjectPrxHelperBase.java:905)
    at Ice.ObjectPrxHelperBase.ice_isA(ObjectPrxHelperBase.java:73)
    at Ice.ObjectPrxHelperBase.ice_isA(ObjectPrxHelperBase.java:61)
    at Resfo.ReseHelper.checkedCast(ReseHelper.java:298)
    Caused by: java.net.ConnectException: Connection refused: no further information
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown Source)
    at IceInternal.Network.doConnect(Network.java:259
  • marc
    marc Florida
    Please see this FAQ.
  • slice2javaTask

    Hi,

    What could be the cause for the below error:?


    Exception in thread "main" Ice.ObjectNotExistException
    id.name = "Ice"
    id.category = ""
    facet = ""
    operation = "ice_isA"
    at IceInternal.Outgoing.invoke(Outgoing.java:148)
    at Ice._ObjectDelM.ice_isA(_ObjectDelM.java:31)
    at Ice.ObjectPrxHelperBase.ice_isA(ObjectPrxHelperBase.java:74)
    at Ice.ObjectPrxHelperBase.ice_isA(ObjectPrxHelperBase.java:61)
    at Res.ResPrxHelper.checkedCast(ResPrxHelper.java:298)
  • marc
    marc Florida
    Please read the manual! This forum cannot serve as a substitute for reading our documentation.
  • basic Slice2JavaTask ant question

    What's the proper way to add an arg, such as --tie, to the slice compiler using the build.xml and config/common.xml structures like in the demos?
  • mes
    mes California
    Hi,

    If you're using our slice2java ant task, you would pass options to the task like this:
    <slice2java outputdir="${generated.dir}" tie="on" stream="on">
        ...
    </slice2java>
    
    Hope that helps,
    Mark