On 10/17/07, Simon Laws <[EMAIL PROTECTED]> wrote:
>
>
>
> On 10/17/07, Ana Belén Antón Gironés <[EMAIL PROTECTED]> wrote:
> >
> > Yes, I am using the same .composite file
> >
> > Ana Belen
> >
> > -----Mensaje original-----
> > De: Simon Laws [mailto:[EMAIL PROTECTED]
> > Enviado el: miércoles, 17 de octubre de 2007 13:04
> > Para: [email protected]
> > Asunto: Re: *SPAM*: 06.40/6.0 - Re: How use org.dom4j in my tuscany-sca
> > component
> >
> > On 10/17/07, Ana Belén Antón Gironés < [EMAIL PROTECTED]>
> > wrote:
> > >
> > > Thank you very much!! That compiles!!! :-) But it doesn't run :-( . I
> > > get the same error which I remarked on a previous thread:
> > >
> > > =============================================================
> > > Buildfile: build.xml
> > >
> > > Buildfile: build.xml
> > >
> > > run-classes:
> > >      [java] Starting ...
> > >      [java] Information.composite ready
> > >      [java] Exception in thread "main"
> > > org.osoa.sca.ServiceUnavailableException: No service invoker is
> > > available for reference default
> > > (bindingURI=InformationServiceComponent
> > > operation=getInformationObject).
> > >      [java]     at
> > >
> > > org.apache.tuscany.sca.binding.sca.impl.RuntimeSCAReferenceBindingProv
> > > ider.c
> > > reateInvoker(RuntimeSCAReferenceBindingProvider.java :192)
> > >      [java]     at
> > > org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.addBindingInterce
> > > ptor
> > > (R
> > > untimeWireImpl.java:214)
> > >      [java]     at
> > > org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.initInvocationCha
> > > ins
> > > (Ru
> > > ntimeWireImpl.java:156)
> > >      [java]     at
> > > org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.getInvocationChai
> > > ns
> > > (Run
> > > timeWireImpl.java:97)
> > >      [java]     at
> > >
> > > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.getInvocat
> > > ionCha
> > > in(JDKInvocationHandler.java:190)
> > >      [java]     at
> > > org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke
> > > (JDKInvoca
> > > tionHandler.java:124)
> > >      [java]     at $Proxy5.getInformationObject(Unknown Source)
> > >      [java]     at Client.isClient.main(isClient.java:34)
> > >
> > > BUILD SUCCESSFUL
> > > Total time: 1 second
> > >
> > > ================================================================
> > >
> > > Best regards.
> > >
> > > Ana Belen.
> > >
> > >
> > >
> > > -----Mensaje original-----
> > > De: Simon Laws [mailto:[EMAIL PROTECTED]
> > > Enviado el: miércoles, 17 de octubre de 2007 10:23
> > > Para: [email protected]
> > > Asunto: *SPAM*: 06.40/6.0 - Re: How use org.dom4j in my tuscany-sca
> > > component
> > >
> > > On 10/17/07, Ana Belén Antón Gironés < [EMAIL PROTECTED]>
> > wrote:
> > > >
> > > > Sorry, the success had a short time :-(
> > > >
> > > > In one of the classes of my component I use the library dom4j. How
> > > > do I have to add this library? I added it to C:\TUSCANY\tuscany-
> > > > sca-1.0-incubating\lib
> > > >
> > > > But when I compile, I get the follow error:
> > > >
> > > >
> > > > ====================================================================
> > > > ==
> > > > ======
> > > > ========
> > > > compile:
> > > >     [javac] Compiling 15 source files to
> > > > C:\TUSCANY\tuscany-sca-1.0-incubating\samples\mypath
> > > >     [javac]
> > > > C:\TUSCANY\tuscany- sca-1.0-incubating\samples\myclasspath.java:10:
> > > > package org.dom4j does not exist
> > > >     [javac] import org.dom4j.Attribute;
> > > >     [javac]                  ^
> > > >     [javac]
> > > > C:\TUSCANY\tuscany- sca-1.0-incubating\samples\myclasspath.java:72:
> > > > cannot find symbol
> > > >     [javac] symbol  : class DocumentException
> > > >     [javac] ..........
> > > >                 .........
> > > > ====================================================================
> >
> > > > ==
> > > > ======
> > > >
> > > > ===========
> > > >
> > > > Thanks,
> > > >
> > > > Ana Belen
> > > >
> > > Hi
> > >
> > > Interesting one this.
> > >
> > > The jar you are using is required by your component implementation so
> > > it should be part of the contribution, i.e . the set of files that
> > > comprise the .composite file and the class files that provide
> > > component implementations.
> > >
> > > You see the contribution being added to Tuscany SCA in the client in
> > > the line that reads.
> > >
> > > SCADomain scaDomain = SCADomain.newInstance("Information.composite");
> > >
> > > This is a slightly tricky line but what it is actually saying is look
> > > for the directory which holds the file Information.composite. Then go
> > > and load all of the files there. In your sample it should find the
> > > target/classes directory and so load all of the resources there as
> > > part of the contribution.
> > >
> > > You will of course need to include any new jars on the compile line so
> > > you can compile you component implementation. If you are using the
> > > build.xmldiscussed on the previous thread you can adjust the compile
> > > target.
> > >
> > >     <target name="compile" depends="init">
> > >         <javac srcdir="src/main/java"
> > >                destdir="target/classes"
> > >                debug="on"
> > >                source="1.5"
> > >                target="1.5">
> > >             <classpath>
> > >                 <pathelement
> > > location="../../lib/tuscany- sca-manifest.jar
> > > "/>
> > >             </classpath>
> > >         </javac>
> > >
> > > By adding a new path element pointing at your new jar.
> > >
> > >   <pathelement location="domedir/mynewjar.jar"/>
> > >
> > > I expect you have already done this. This should allow you to compile
> > it.
> > >
> > > Now we come to running the sample. The class loader story in Tuscany
> > > is being reviewed at the moment it isn't as tidy as it should be (see
> > > the thread on the developer list). I would imagine in this case that
> > > the new jar should automatically be made available to the running
> > > application by virtue of it being included in the contribution.
> > > However it doesn't work like that at the moment. You should make the
> > > new jar available on the runtime classpath alongside the compile
> > > component implementations. Take the run-classes target
> > >
> > >     <target name="run-classes">
> > >         <java classname="${test.class}"
> > >               fork="true">
> > >             <classpath>
> > >                 <pathelement path="target/classes"/>
> > >                 <pathelement
> > > location="../../lib/tuscany-sca-manifest.jar
> > > "/>
> > >             </classpath>
> > >         </java>
> > >     </target>
> > >
> > > And add the new pathelement line here also.
> > >
> > >   <pathelement location="domedir/mynewjar.jar"/>
> > >
> > > This all sounds very complicated but the idea is that SCA
> > > contributions collect together all of the resources that you need to
> > > run your SCA application, i.e. .composite files, .class files, .jar
> > > files and allow you simply to add this to the the SCA runtime and have
> > > it run.  This will provide a relatively straightforward mechanism for
> > > adding applications to Tuscany when the classloader story is sorted
> > out.
> > >
> > > Regards
> > >
> > > Simon
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > > So we are back to the situation where the target service cannot be
> > found.
> > I.e. the line in isClient
> >
> > InformationService is = scaDomain.getService(InformationService.class ,
> > "InformationServiceComponent");
> >
> > Is returning a proxy but the proxy doesn't point to the component
> > defined
> > locally as either something went wrong when reading the composite file
> > or
> > the composite file has change so that "InformationServiceComponent" is
> > not a
> > valid component name now.
> >
> > Are you still using the sample .composite file with.
> >
> > <component name="InformationServiceComponent">
> > <implementation.java class="
> > eu.services.information.rh.InformationServiceImpl "/>
> > </component>
> >
> >
> > If so can you flip the implementation back so that it doesn't depend on
> > the
> > other jar. It's interesting to see if the dependency is causing a
> > problem
> > for some reason. It's strange that the output you provided doesn't
> > suggest
> > that it had a problem loading the composite file if this is the case
> > though.
> >
> >
> > Regards
> >
> > Simon
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> Ok let me see if having a dom4j dependency  makes my version of the sample
> fail.
>
> Simon
>
>
> Hi Ana Belen

Ok , I added some dom4j processing in my local copy of the sample:

import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.Service;
import eu.services.information.exceptions.*;
import eu.services.information.io.InformationObject;
import eu.services.information.is.*;
import org.dom4j.io.DOMReader;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

@Service(InformationService.class)
public class InformationServiceImpl implements InformationService{

//----------------------------------------------------------------------------------------------------------
 public InformationObject getInformationObject(String id) throws
ISNotFoundException{

    try {
        SAXReader reader = new SAXReader();
        Document document = reader.read("
http://svn.apache.org/repos/asf/incubator/tuscany/java/sca/samples/pom.xml
");
        System.out.println(document.getRootElement().getName());
    } catch (Exception ex ){
        System.out.println(ex.toString());
    }

 InformationObject io = new InformationObjectImpl();
 //code
 return io;
 }

}

And I updated the compile and run-classes targets in build.xml...

    <target name="compile" depends="init">
        <javac srcdir="src/main/java"
               destdir="target/classes"
               debug="on"
               source="1.5"
               target="1.5">
            <classpath>
                <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
                <pathelement location="c:/simon/install/dom4j-1.6.1.jar"/>
            </classpath>
        </javac>
        <copy todir="target/classes">
            <fileset dir="src/main/resources"/>
        </copy>
        <jar destfile="target/${test.jar}" basedir="target/classes">
            <manifest>
                <attribute name="Main-Class" value="${test.class}" />
            </manifest>
        </jar>
    </target>

    <target name="run-classes">
        <java classname="${test.class}"
              fork="true">
            <classpath>
                <pathelement path="target/classes"/>
                <pathelement location="../../lib/tuscany-sca-manifest.jar"/>
                <pathelement location="c:/simon/install/dom4j-1.6.1.jar"/>
            </classpath>
        </java>
    </target>

It worked for me.

Buildfile: build.xml

run-classes:
     [java] Starting ...
     [java] Information.composite ready
     [java] project
     [java] String: a string

BUILD SUCCESSFUL
Total time: 5 seconds

Do you have any other dependencies that could be causing problems? Can you
step through with me what is different between the sample we both had
working and the sample that is failing?

Regards

Simon

Reply via email to