You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@james.apache.org by Eduardo Luque Sola <el...@aplicatec.com> on 2008/01/29 15:11:53 UTC

lauch james from java application

Hi, i am trying to launch james as a service in my java application but
i don't know how to embbebed it (do not run with run.sh). I need to run
it from a main java class. 

Help me please with some code example ... Thank you a lot


Re: lauch james from java application

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Jan 31, 2008 4:35 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
>
> Robert Burrell Donkin wrote:
> > On Jan 30, 2008 7:45 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
> >> Robert Burrell Donkin wrote:
> >>> On Jan 29, 2008 2:11 PM, Eduardo Luque Sola <el...@aplicatec.com> wrote:
> >>>> Hi, i am trying to launch james as a service in my java application but
> >>>> i don't know how to embbebed it (do not run with run.sh). I need to run
> >>>> it from a main java class.
> >>> if you're using the latest code then the spring deployment is probably
> >>> the way to go
> >> and in this case it would be required to put all libraries onto your
> >> classpath which after build have landed in
> >> spring-deployment/target/james-server*/lib
> >>
> >> To launch James the Spring-way, just put into your main method
> >>
> >>          Resource containerResource = new
> >> ClassPathResource("beans-base-config.xml");
> >>          Resource applicationResource = new
> >> ClassPathResource("james-assembly.xml");
> >>          AvalonApplicationContext context = new
> >> AvalonApplicationContext(containerResource, applicationResource);
> >>
> >> and put the xml files onto the classpath.
> >
> > maybe we should encapsulate this in a launcher
>
> there are launchers generated for Windows and Unix (run.bat + run.sh) at
> build time.
>
> they simply build the classpath and invoke
>
> http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java?view=markup
>
> which is basically simply those three lines I quoted.
>
> Since the original poster wanted to start from his/her own application,
> he probably wants to skip the launcher part.
>
> Or did you refer to something more advanced like in phoenix-deployment?

dunno :-)

just tossing the idea around

- robert

Re: lauch james from java application

Posted by Bernd Fondermann <bf...@brainlounge.de>.
Robert Burrell Donkin wrote:
> On Jan 30, 2008 7:45 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
>> Robert Burrell Donkin wrote:
>>> On Jan 29, 2008 2:11 PM, Eduardo Luque Sola <el...@aplicatec.com> wrote:
>>>> Hi, i am trying to launch james as a service in my java application but
>>>> i don't know how to embbebed it (do not run with run.sh). I need to run
>>>> it from a main java class.
>>> if you're using the latest code then the spring deployment is probably
>>> the way to go
>> and in this case it would be required to put all libraries onto your
>> classpath which after build have landed in
>> spring-deployment/target/james-server*/lib
>>
>> To launch James the Spring-way, just put into your main method
>>
>>          Resource containerResource = new
>> ClassPathResource("beans-base-config.xml");
>>          Resource applicationResource = new
>> ClassPathResource("james-assembly.xml");
>>          AvalonApplicationContext context = new
>> AvalonApplicationContext(containerResource, applicationResource);
>>
>> and put the xml files onto the classpath.
> 
> maybe we should encapsulate this in a launcher

there are launchers generated for Windows and Unix (run.bat + run.sh) at 
build time.

they simply build the classpath and invoke

http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/src/main/java/org/apache/james/container/spring/Main.java?view=markup

which is basically simply those three lines I quoted.

Since the original poster wanted to start from his/her own application, 
he probably wants to skip the launcher part.

Or did you refer to something more advanced like in phoenix-deployment?

NOTE: I will improve this particular code on the way to an OSGi deployment.

   Bernd

Re: lauch james from java application

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Jan 30, 2008 7:45 AM, Bernd Fondermann <bf...@brainlounge.de> wrote:
> Robert Burrell Donkin wrote:
> > On Jan 29, 2008 2:11 PM, Eduardo Luque Sola <el...@aplicatec.com> wrote:
> >> Hi, i am trying to launch james as a service in my java application but
> >> i don't know how to embbebed it (do not run with run.sh). I need to run
> >> it from a main java class.
> >
> > if you're using the latest code then the spring deployment is probably
> > the way to go
>
> and in this case it would be required to put all libraries onto your
> classpath which after build have landed in
> spring-deployment/target/james-server*/lib
>
> To launch James the Spring-way, just put into your main method
>
>          Resource containerResource = new
> ClassPathResource("beans-base-config.xml");
>          Resource applicationResource = new
> ClassPathResource("james-assembly.xml");
>          AvalonApplicationContext context = new
> AvalonApplicationContext(containerResource, applicationResource);
>
> and put the xml files onto the classpath.

maybe we should encapsulate this in a launcher

- robert

Re: lauch james from java application

Posted by Bernd Fondermann <bf...@brainlounge.de>.
Robert Burrell Donkin wrote:
> On Jan 29, 2008 2:11 PM, Eduardo Luque Sola <el...@aplicatec.com> wrote:
>> Hi, i am trying to launch james as a service in my java application but
>> i don't know how to embbebed it (do not run with run.sh). I need to run
>> it from a main java class.
> 
> if you're using the latest code then the spring deployment is probably
> the way to go

and in this case it would be required to put all libraries onto your 
classpath which after build have landed in 
spring-deployment/target/james-server*/lib

To launch James the Spring-way, just put into your main method

         Resource containerResource = new 
ClassPathResource("beans-base-config.xml");
         Resource applicationResource = new 
ClassPathResource("james-assembly.xml");
         AvalonApplicationContext context = new 
AvalonApplicationContext(containerResource, applicationResource);

and put the xml files onto the classpath.

but please note, this code is not contained in an official release yet 
and not heavily tested.

   Bernd


Re: lauch james from java application

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Jan 29, 2008 2:11 PM, Eduardo Luque Sola <el...@aplicatec.com> wrote:
> Hi, i am trying to launch james as a service in my java application but
> i don't know how to embbebed it (do not run with run.sh). I need to run
> it from a main java class.

if you're using the latest code then the spring deployment is probably
the way to go

if you're using the last release then you'll need to use pheonix
programmatically. read
http://excalibur.apache.org/framework/index.html.

> Help me please with some code example ... Thank you a lot

FYI you'll probably find better answers more quickly if you post
questions such as this to the james user list

- robert