[ 
https://issues.apache.org/jira/browse/CXF-3949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13163472#comment-13163472
 ] 

metatech commented on CXF-3949:
-------------------------------

Daniel,
I did not install CXF manuallly, it got installed by default in the ServiceMix 
4.3 distribution.
The problem is, I think, that the CXF bundle gets installed a few milliseconds 
too early, before the JSR 311 is completely installed, which means that the 
OSGi framework does not wait for the JSR 311 bundle to become available, but 
ignores this dependency and installs the CXF bundle without it.
In Felix 3.0.9 (provided in SMX 4.3), manually executing a OSGI refresh of both 
bundles does not help, because the class ModuleImpl caches the dependencies (in 
member variable "m_cachedRequirements"), and the only way to update the 
dependencies is to uninstall/install the bundle, which cannot be practically 
performed if many other bundles depend on it.
Regarding the change of the start-level, I experienced that it does not work in 
all cases, but that it merely reduces the window of the race condition, see my 
comment in https://issues.apache.org/jira/browse/SMX4-744.
The ideal solution would be that the optional features of the CXF bundle are 
delivered as separate optional bundles, but I understand that this will create 
a higher complexity for the CXF distribution.
Regards.
                
> NoClassDefFoundError when using CXF JAX-RS in OSGi environment
> --------------------------------------------------------------
>
>                 Key: CXF-3949
>                 URL: https://issues.apache.org/jira/browse/CXF-3949
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.3.2
>         Environment: ServiceMix 4.3
>            Reporter: metatech
>   Original Estimate: 8h
>  Remaining Estimate: 8h
>
> When using the CXF JAX-RS implementation in an OSGi environment, the CXF 
> implementation might fail to initialize properly.
> The problem is non-consistently reproduceable, but more likely to occur on 
> machines with high parallelism (due to several cores/threads).
> The CXF bundle ("org.apache.cxf.bundle") has a dependency on the JSR 311 API 
> JAR ("org.apache.servicemix.specs.jsr311-api-1.1").
> But the dependency is marked as "resolution=optional" in the OSGi headers of 
> the CXF bundle manifest.
> As a result, if the JSR-311 bundle is not yet fully started when the CXF 
> bundle is started, OSGi does not "wire" these packages into the imports of 
> the CXF bundle:
> javax.ws.rs
> javax.ws.rs.core
> javax.ws.rs.ext
> The error is the following : 
> java.lang.NoClassDefFoundError: Could not initialize class 
> org.apache.cxf.jaxrs.utils.JAXRSUtils
> See similar error DOSGI-1
> I guess that these packages are marked as optional because CXF can be used in 
> an environment where no JAX-RS is available, and it works fine as long as the 
> application does not use this API.  However, when an application is known to 
> use the API, the dependency marked as "optional" is not correct.
> Long-term solution : split CXF bundle into smaller bundles (like Jetty).
> Workaround : edit the manifest of the CXF bundle, and remove the 
> "resolution=optional" for the packages which are known to be used by the 
> application.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to