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

Reply via email to