Hi Hendy,
Two quick questions.
Freeman
Hendy Irawan wrote:
Since I made it work ultimately, I want to share how I did it.

   1. From ServiceMix shell: `feature install web`
   2. From ServiceMix shell: `feature install cxf-osgi`
   3. CXF extension must be correct in META-INF/spring/beans.xml (include
cxf-extension-jaxrs-binding, cxf-extension-http, osgi/cxf-extension-osgi,
exclude cxf-servlet)
   4. add `META-INF/services/` JAX-RS delegate. From
http://rjrojas.blogspot.com/2008/09/restful-web-services-using-iona-fuse.html:
Note: JAX-RS needs to know what JAX-RS implementation would be used.
This
is done by creating a file called "javax.ws.rs.ext.RuntimeDelegate" in the
META-INF/services directory. The contents of the file specify the name of
the class performing this implementation
(org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl).
Why you need add this file yourself? I think in the cxf bundle jar already have this services file for you.
   5. Jettison is needed
   6. Embed jsr311-api
I'm not sure what you mean embed jsr311-api? Install jsr311-osgi-api bundle doesn't work for you? Cxf bundle doesn't include jsr311-api , but import javax.ws.rs package as optional resolution, I just think install jsr311-osgi-api bundle should work.
What I still don't like is that I need to embed jsr311-api... Shouldn't this
be in CXF bundle?

On Sun, Nov 30, 2008 at 1:55 PM, Hendy Irawan <[EMAIL PROTECTED]>wrote:

By the way, I have no problem using JAX-WS in ServiceMix4, thanks to
ServiceMix+CXF's excellent built-in support (I do get occasional "cannot
start bundle due to (unspecified) constraints" so I clear the data/cache
directory often)

My problem is when using JAX-RS...
http://rjrojas.blogspot.com/2008/09/restful-web-services-using-iona-fuse.htmlgives
 example of CXF+SMX4+JAX-RS however it uses Spring-DM OSGi service
reference in JAX-RS server's <serviceBeans>, my app directly refers to a
JAX-RS-annotated bean, probably this is the cause... (however in a pure Java
/ non-OSGi setting, it works well)

Thank you.

PS: I should've changed the subject... And sorry for cross-posting, because
I think now this is related more to ServiceMix than Felix.


On Sun, Nov 30, 2008 at 1:43 PM, Hendy Irawan <[EMAIL PROTECTED]>wrote:

Thanks David, that's exactly what I'm trying to do.

Frustrated with trying to assemble my own CXF OSGi jar(s), ...

Then I used cxf-bundle with Felix... however it requires a lot of
dependencies.. especially external dependencies (I take from SpringSource)
because a lot of dependencies of cxf-bundle are not OSGi bundles but simple
Java jars.

Even with all dependencies satisfied, I still get:
java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
that until now I cannot resolve. Note that the jaxb JARs from CXF
(jaxb-api, jaxb-impl, jaxb-xjc) are not OSGi bundles, therefore I use the
ones from SpringSource.

Frustrated with com.sun.xml.bind.v2 problem, I tried ServiceMix 4, this
time I use the FUSE version because of a broken link in Apache ServiceMix 4
web site* (my bad, actually)

My app uses JAX-RS and this doesn't just work in ServiceMix 4 so I had to
download jsr311-api-0.8 OSGified from Roberto Rojas'
http://rjrojas.blogspot.com/2008/09/restful-web-services-using-iona-fuse.html

This time, I got a "better" error, which is ClassNotFoundException on
jaxa.ws.rs.Path. It turns out I have to do a "osgi refresh" on the
cxf-bundle JAR everytime making a change on my manifest or deploying a new
library. (why is this? Shouldn't FileMonitor do this for me?)

The current state, is I'm getting two different errors, depending on which
bundle I try to refresh.

If I refresh cxf-bundle (#91 on my list), I get:

servicemix osgi> refresh 91
servicemix osgi> Nov 30, 2008 1:40:46 PM
org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be /Test
Exception in thread "SpringOsgiExtenderThread-88"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'restServer': Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.NoClassDefFoundError: Could
not initialize class javax.ws.rs.core.MediaType
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:276)
        at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:145)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.NoClassDefFoundError: Could
not initialize class javax.ws.rs.core.MediaType
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275)
        ... 15 more

However if I refresh my own bundle (#34), I get:

servicemix osgi> refresh 34
servicemix osgi> Nov 30, 2008 1:41:34 PM
org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be /Test
Exception in thread "SpringOsgiExtenderThread-90"
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'restServer': Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.NoClassDefFoundError: Could
not initialize class org.apache.cxf.jaxrs.utils.JAXRSUtils
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1278)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
        at
org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:276)
        at
org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:145)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property 'serviceBeans'
threw exception; nested exception is java.lang.NoClassDefFoundError: Could
not initialize class org.apache.cxf.jaxrs.utils.JAXRSUtils
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:104)
        at
org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1275)
        ... 15 more

Same error, different offending class, one is from package
org.apache.cxf.jaxrs.utils and one is from package javax.ws.rs.core, both
packages are Import-Package-ed from in app's manifest.

What a chronology... I hope you're willing to help me debug this problem.
Thank you.


* http://servicemix.apache.org/SMX4/runtime.html contains broken link
"You can grab a download of the minimum ServiceMix 4 Runtime 
here<http://people.apache.org/repo/m2-snapshot-repository/org/apache/servicemix/runtime/org.apache.servicemix.runtime.minimum/4.0-SNAPSHOT/org.apache.servicemix.runtime.minimum-4.0-SNAPSHOT.tar.gz>."
It probably should just point to
http://servicemix.apache.org/SMX4/download.html or SMX4KNL (?)


On Sun, Nov 30, 2008 at 3:23 AM, David Bosschaert <
[EMAIL PROTECTED]> wrote:

Hi Hendy,

Not sure what you're exactly trying to do but just to let you know
that CXF is already available as an OSGi bundle. E.g. you may want to
take a look at cxf-minimal:
 http://svn.apache.org/repos/asf/cxf/trunk/distribution/bundle/minimal/

If you want to get an easy dsitribution of CXF running inside an OSGi
container, have a look at ServiceMix 4
(http://servicemix.apache.org/SMX4/download.html). When you start SMX4
it will actually launch Felix and run all the functionality in that as
OSGi bundles. This includes CXF.

Cheers,

David

--
Best regards,
Hendy Irawan
http://hendyirawan.com/






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to