RE: How to use external jars in Merlin components?

"Stephen McConnell" <[email protected]>
Newsgroups gmane.comp.jakarta.avalon.user
Message-ID <000001c48717$98bc2080$1601a8c0@gloria>

> -----Original Message-----
> From: Harvinder Singh [mailto:[email protected]]
> Sent: 20 August 2004 23:03
> To: Avalon framework users
> Subject: RE: How to use external jars in Merlin components?
> 
> Stephen,
> 
> I am able to build the component but now it is giving me runtime
error.

Ok - build issue are out of the way 
... now onto the runtime. 

> I removed the jar file (abc-1.0.0.jar) from {Merlin.home}\system
folder
> and
> placed it under {user.dir}/.maven/repository/abc/jars and it worked.
> Actually whatever dependency I declare in project.xml I should have
those
> jars in the maven repository which I did not have it.
> By mistake I had overlooked that.
> Following the build, maven is installing the jar file (Test-1.1.jar)
into
> D:\Merlin\tutorials\Test\target folder.

This depends on the maven target that you issue.  For example, issuing
the command 'maven jar:install' will result in the build of the jar file
and the the creation of a copy in the maven repository.

> Now when I execute and run Test-1.1.jar, I am not able to instantiate
any
> class from the external jar (abc-1.0.0.jar) which I decalred as a
> dependency
> (NoClassDefFoundError)

There are two points to cover here - firstly, the addition of a
reference to the abc jar in your block definition, and secondly,
synchronization of the merlin and maven repositories (see below).

> You had mentioned below that Merlin looks for resources at runtime in
> {merlin.repository}.
> My {merlin.repository} property is set to  is
> {user.dir}/.avalon/repository
> and this only has the avalon-framework folder having its jar.
> Also now in kernel.xml should I have an entry for the abc-1.0.0.jar
any
> longer?

I suggest you remove the cache reference in the kernel and instead
create a merlin.properties file in you ${user.home} directory and add a
property definition to declare the merlin repository to be the same as
the maven repository.

For example:

merlin.repository = C:\maven\repository

That will tell merlin to use the directory C:\maven\repository as its
application repository cache so when you update resources via maven,
merlin will automatically pick them up.

Cheers, Steve.


> 
> Harvinder
> 
> -----Original Message-----
> From: Stephen McConnell [mailto:[email protected]]
> Sent: Friday, August 20, 2004 3:05 PM
> To: 'Avalon framework users'; [email protected]
> Subject: RE: How to use external jars in Merlin components?
> 
> 
> 
> 
> > -----Original Message-----
> > From: Harvinder Singh [mailto:[email protected]]
> > Sent: 20 August 2004 21:54
> > To: Avalon framework users
> > Subject: RE: How to use external jars in Merlin components?
> >
> > Here is the dependency declaration
> >   <dependencies>
> >     <dependency>
> >       <groupId>avalon-framework</groupId>
> >       <artifactId>avalon-framework-api</artifactId>
> >       <version>4.2.0</version>
> >     </dependency>
> >     <dependency>
> > 	  <groupId>abc</groupId>
> > 	  <artifactId>abc</artifactId>
> > 	  <version>1.0.0</version>
> > 	  <type>jar</type>
> >     </dependency>
> >   </dependencies>
> >
> > The first dependency is resolved as it takes from the avalon
> repository
> > but the second one gives the problem.
> > I am having the jar file as
> {Merlin.home}\system\abc\jars\abc-1.0.0.jar.
> > Now for this I am having an entry in kernel.xml as follows:
> 
> *spit, snarl, spit, spit*
> 
> Within the Merlin system there are two repositories - one repository
is
> the Merlin internal system repository ${merlin.home}/system which is
> intended for exclusive use by the Merlin application.  The second
> repository (commonly referred to as the application repository) is
made
> available for application jar files such as your abc-1.0.0-jar - this
is
> located under ${merlin.repository).
> 
> Now - two things:
> 
>   (a) your existing setup should work assuming you have your
>       maven and merlin system repository in sync.
>   (b) but I'm going to suggest that you do something different
> 
> Before going further, what is the directory into which maven is
> installing your jar file following a build?
> 
> Stephen.
> 
> 
> > <repository>
> >   	<cache>D:\Merlin\system\abc\jars</cache>
> >    	<hosts>
> > 	<host path="http://www.dpml.net/"/>
> >       <host path="http://www.ibiblio.org/maven/"/>
> >      	</hosts>
> > </repository>
> 
> 
> 
> 
> 
> 
> > Harvinder
> >
> > -----Original Message-----
> > From: Stephen McConnell [mailto:[email protected]]
> > Sent: Friday, August 20, 2004 2:38 PM
> > To: 'Avalon framework users'; [email protected]
> > Subject: RE: How to use external jars in Merlin components?
> >
> >
> >
> >
> > Can you post the dependency declaration from your maven project.xml
> > file?
> >
> > Steve.
> >
> >
> >
> > > -----Original Message-----
> > > From: Harvinder Singh [mailto:[email protected]]
> > > Sent: 20 August 2004 21:19
> > > To: Avalon framework users
> > > Subject: RE: How to use external jars in Merlin components?
> > >
> > > Stephen,
> > >
> > > Thanks a lot for the info !!!
> > > Actually I had specified my dependent jar file in the project.xml
> and
> > the
> > > error occured
> > > while resolving build time dependencies itself.(hadn't reached
> > runtime)
> > > Another doubt which I have is that whether Maven also looks for
the
> > files
> > > whose names are of the type
> > > <name>-<version>.<type>.
> > > My jar file did not follow the particular naming standard so I
> changed
> > it
> > > to
> > > the above standard, but still the error persists.
> > > And regarding the repository, I had specified the particular cache
> > folder
> > > where my jar file is kept (in the cache directive in kernel.xml)
> > > But still it does not seem to pick the file up.
> > > Any thoughts ?
> > >
> > > Regards,
> > > Harvinder
> > >
> > > -----Original Message-----
> > > From: Stephen McConnell [mailto:[email protected]]
> > > Sent: Friday, August 20, 2004 12:09 PM
> > > To: 'Avalon framework users'; [email protected]
> > > Subject: RE: How to use external jars in Merlin components?
> > >
> > >
> > >
> > > Harvinder:
> > >
> > > Both maven and merlin use a repository of jar resources.  In you
> case
> > > you have both build and runtime dependencies to take of.  Build
time
> > > dependencies are declared in a project.xml and are managed by
maven.
> > I'm
> > > guessing that you have that one sorted out.  Once maven has
produced
> > the
> > > build artifact (a.k.a jar file) you need to include this in the
> > > repository used by the merlin runtime.
> > >
> > > If you you execute the following command you will see a bunch of
> > > properties listed that provide information about your runtime
> > > environment:
> > >
> > >  $ merlin -info
> > >
> > > The listing should include the value of 'merlin.repository'.  This
> > value
> > > is the directory that corresponds to the root of the repository
> cache
> > > directory within which merlin is looking for resources at runtime.
> > > Merlin (and maven) look for resources based on the following
> pattern:
> > >
> > >   [cache]/[group]/[type]s/[name]-[version].[type]
> > >
> > >
> > > If merlin does not locate the jar file in the repository it will
> look
> > > for the jar in the remote repositories associated with your
> > > configuration (see merlin.hosts value).  If the jar file cannot be
> > > located at any of the remote repositories you will get the error
you
> > > have mentioned below.  If the resource is not available on a
remote
> > > repository you either add it to your local cache, or, setup your
own
> > > local repository (accessible using file or http protocol) and
> include
> > > this in the set of remote repositories declared under the
> > 'merlin.hosts'
> > > property.
> > >
> > > Cheers, Steve.
> > >
> > >
> > > > -----Original Message-----
> > > > From: Harvinder Singh [mailto:[email protected]]
> > > > Sent: 20 August 2004 18:46
> > > > To: Avalon framework users
> > > > Subject: How to use external jars in Merlin components?
> > > >
> > > > All,
> > > >
> > > > I am able to build and run the tutorials in Merlin using Maven.
> > > > I even built a small component of my own and tested it.  It
works
> > > fine.
> > > > But now when I try to include some external jar files(on my
local
> > > machine)
> > > > for that component, the build fails.
> > > > After some googling I found out that I need to have an entry for
> the
> > > > external jar file in
> > > > the project.xml file used by Maven.
> > > > Also the path for that external jar file should be mentioned in
> > > kernel.xml
> > > > under repository directive.
> > > > I did all that but the build fails and gives the following error
:
> > > >
> > > > Attempting to download <jar file name>.
> > > > WARNING: Failed to download <jar file name>.
> > > > The build cannot continue because of the following unsatisfied
> > > dependency:
> > > > <jar file name>
> > > >
> > > > Can some one please help me out on this issue ? Has someone
faced
> > the
> > > > similar kind os issue?
> > > > Please revert back soon.
> > > >
> > > > Regards,
> > > > Harvinder
> > > >
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [email protected]
> > > > For additional commands, e-mail: [email protected]
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [email protected]
> > > For additional commands, e-mail: [email protected]
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [email protected]
> > For additional commands, e-mail: [email protected]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.