You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by djb <db...@hotmail.com> on 2010/09/22 16:31:59 UTC

SMX Maven/feature deployment

Hi,

I can't for the life of me work out how to make a cxf-jaxrs project from
scratch.  The only documentation that exists seems to be 'type
features:install examples-cxf-jaxrs', which doesn't help someone trying to
learn SMX.

So,  I'm trying to take the example, move it to another directory, make
changes to it, and install it myself.  I am trying to install the cxf-jaxrs
example by adding it as a new 'feature' 

So.

Step 1.
Cut <feature> from apache-servicemix-4.2.0-features.xml

Step 2.
Paste <feature> to myfeatures.xml

Step 3.
Copy /examples/cxf-jaxrs to /mydir/test-cxf-jaxrs

Step 4.
features:addUrl file:myfeatures.xml

Step 5.
Change pom.xml:  
changed 
<artifactId>test-cxf-jaxrs</artifactId>
changed 
<Import-Package>org.apache.servicemix.examples.test.cxf.jaxrs</Import-Package>
changed 
<Export-Package>org.apache.servicemix.examples.test.cxf.jaxrs</Export-Package>

Step 6.
mvn install

Step 7.
features:install test-cxf-jaxrs

It actually does install, and works as before.  But changes to my new test
code don't change anything.  

Now, I know it has something to do with Maven repos, but Maven's
documentation is obfuscated.

What changes must I make to make the code go to a nice repository somewhere,
and have SMX load that code when I run Step 7? 

Is there an easier way than the undocumented features facility?

Please help...  

Regards,
Daniel  




-- 
View this message in context: http://servicemix.396122.n5.nabble.com/SMX-Maven-feature-deployment-tp2849796p2849796.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: SMX Maven/feature deployment

Posted by Adrian Trenaman <tr...@progress.com>.
Hi DJB,

I think a crash course in maven may be required! My solution to your 
problem is below.

ServiceMix (and the Karaf foundations upon which it now lies) is an 
awesome tool, but I think if you're going to be developing solutions for 
it then you should embrace Maven, even if it feels strange at the start. 
*Sigh* I remember embarking on Maven a few years ago after years of 
happy 'ant'ics. Hit me like a fast-moving train.

Spend a little time picking up the basics of Maven and you'll find that 
your adoption of ServiceMix will be a helluvalot easier :)

Best,
Ade
http://fusesource.com

---

1) In your example, you've specified a parent pom, with:

<parent>
<groupId>com.mhgad.za</groupId>
<artifactId>mhgapps</artifactId>
<version>4.2.0</version>
</parent>

But where is this pom coming from? Have you defined a parent pom but not 
actually included it? I have assumed that you errantly changed from the 
parent from the ServiceMix examples. That parent is actually quite 
useful, as it declares the version numbers of useful dependencies: 
either you reuse this POM from the examples, or, you write your own 
parent, or you put all your Maven versions, repositories and whatever 
directly into your pom. For me, I just changed your code to use the 
example POM.

<parent>
<groupId>org.apache.servicemix.examples</groupId>
<artifactId>examples</artifactId>
<version>4.2.0</version>
</parent>


2) With this in place, I ran mvn install correctly :)

3) I then kicked off servicemix, and added your features URL file:

karaf@root> features:addUrl 
file:///Users/ade/Documents/current/20100923-helpdjb/features/custom-features.xml

4) When I list the features, I can see your feature! It's marked in 
'repo-0', because your features descriptor doesn't give a name for the 
feature repository. So, ServiceMix just makes one up.

karaf@root> features:list | grep my-cxf
[uninstalled] [4.2.0      ] my-cxf-jaxrs                         repo-0

5) When I tried to install your feature for the first time, I got a 
stack overflow!! This is because your feature includes itself, so we end 
up with a recursive nightmare. While a feature shouldn't refer to 
itself, ServiceMix should detect the error - I'll raise a bug on the 
Karaf community. Your features file now looks like this:

<features>
<repository>mvn:org.apache.servicemix.nmr/apache-servicemix-nmr/1.2.0/xml/features</repository>
<repository>mvn:org.apache.camel.karaf/apache-camel/2.2.0/xml/features</repository>
<repository>mvn:org.apache.felix.karaf/apache-felix-karaf/1.4.0/xml/features</repository>

<feature name="my-cxf-jaxrs" version="4.2.0">
<bundle>mvn:org.springframework/spring-beans/2.5.6.SEC01</bundle>
<bundle>mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.commons-httpclient/3.1_4</bundle>
<bundle>mvn:com.mhgad.za/my-cxf-jaxrs/4.2.0</bundle>
</feature>
</features>

6) Now when I install your feature, it installs fine!

  karaf@root> features:install my-cxf-jaxrs


On 23/09/2010 18:47, djb wrote:
> Features code:
>
> http://servicemix.396122.n5.nabble.com/file/n2850786/features.zip
> features.zip
>
> Hi Adrian,
>
> Thanks for your taking a look. There's two folders in there:
>
> 1. test-cxf-jaxrs, which is my very naive 7 Step modification, as described
> before.
> 2. my-cxf-jaxrs, i've changed the package name, so that i'm no longer
> working with org.apache.servicemix.examples...
>
>
> If I type 'mvn install' for 1., it compiles to the target sub-directory, but
> when SMX feature:installs it, it takes the code from the original
> /examples/cxf-jaxrs/target directory  ( I presume ).
>
> If I type 'mvn install' for 2., it says my "pom is not found in repository:
> Unable to download the artifact from any repository". (The output should be
> the same for you).  So there is some Maven repo wizardry I need before it
> will recognise my new artifact name/group.  I understand it is because it
> has never heard of my package name before... but how do I tell Maven about
> it to say "Use the current directory"?  Why can't it just be like "javac -cp
> ."?  Why is Maven so strange?
>
> Thanks,
> Daniel
>
> ps. your work in making it easier to package/deploy will save people
> countless hours.
>    

Re: SMX Maven/feature deployment

Posted by djb <db...@hotmail.com>.
Features code:

http://servicemix.396122.n5.nabble.com/file/n2850786/features.zip
features.zip 

Hi Adrian,

Thanks for your taking a look. There's two folders in there:

1. test-cxf-jaxrs, which is my very naive 7 Step modification, as described
before.
2. my-cxf-jaxrs, i've changed the package name, so that i'm no longer
working with org.apache.servicemix.examples...  


If I type 'mvn install' for 1., it compiles to the target sub-directory, but
when SMX feature:installs it, it takes the code from the original
/examples/cxf-jaxrs/target directory  ( I presume ).

If I type 'mvn install' for 2., it says my "pom is not found in repository:
Unable to download the artifact from any repository". (The output should be
the same for you).  So there is some Maven repo wizardry I need before it
will recognise my new artifact name/group.  I understand it is because it
has never heard of my package name before... but how do I tell Maven about
it to say "Use the current directory"?  Why can't it just be like "javac -cp
."?  Why is Maven so strange?

Thanks,
Daniel

ps. your work in making it easier to package/deploy will save people
countless hours.  
-- 
View this message in context: http://servicemix.396122.n5.nabble.com/SMX-Maven-feature-deployment-tp2849796p2850786.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: SMX Maven/feature deployment

Posted by Adrian Trenaman <TR...@progress.com>.
Hi there,

I'm doing some work on Apache Karaf that should make it easier to package and deploy features; am hoping to complete this work over the next few weeks. In the meantime though, the features mechanism does work quite well, and I think you've got mostly the right idea. One thing I can't see from your example is the contents of your feature file: sounds to me like your features descriptor is referring to the the sample bundle, not your brand new bundle. This would explain why you're not seeing the new bundle's functionality. 

Can you clean and tar/zip your project so I can take a better look?

Cheers,
Ade

Adrian Trenaman
http://fusesource.com


----- Original Message -----
From: djb [mailto:dbrownell83@hotmail.com]
Sent: Wednesday, September 22, 2010 10:31 AM
To: users@servicemix.apache.org <us...@servicemix.apache.org>
Subject: SMX Maven/feature deployment


Hi,

I can't for the life of me work out how to make a cxf-jaxrs project from
scratch.  The only documentation that exists seems to be 'type
features:install examples-cxf-jaxrs', which doesn't help someone trying to
learn SMX.

So,  I'm trying to take the example, move it to another directory, make
changes to it, and install it myself.  I am trying to install the cxf-jaxrs
example by adding it as a new 'feature' 

So.

Step 1.
Cut <feature> from apache-servicemix-4.2.0-features.xml

Step 2.
Paste <feature> to myfeatures.xml

Step 3.
Copy /examples/cxf-jaxrs to /mydir/test-cxf-jaxrs

Step 4.
features:addUrl file:myfeatures.xml

Step 5.
Change pom.xml:  
changed 
<artifactId>test-cxf-jaxrs</artifactId>
changed 
<Import-Package>org.apache.servicemix.examples.test.cxf.jaxrs</Import-Package>
changed 
<Export-Package>org.apache.servicemix.examples.test.cxf.jaxrs</Export-Package>

Step 6.
mvn install

Step 7.
features:install test-cxf-jaxrs

It actually does install, and works as before.  But changes to my new test
code don't change anything.  

Now, I know it has something to do with Maven repos, but Maven's
documentation is obfuscated.

What changes must I make to make the code go to a nice repository somewhere,
and have SMX load that code when I run Step 7? 

Is there an easier way than the undocumented features facility?

Please help...  

Regards,
Daniel  




-- 
View this message in context: http://servicemix.396122.n5.nabble.com/SMX-Maven-feature-deployment-tp2849796p2849796.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.