Hi

I'm not an OSGi expert and perhaps someone can confirm or contradict my answer

Usually it is not to good idea to have more bundles in system exporting the 
same package, but the situation you describe
is a well known pattern. Importing packages exported by the same bundle should 
be usually avoided but is allowed
if an implementation and its corresponding API are combined into the same 
bundle. In this case, the API packages must be
listed amongst the export packages /and/ amongst the import packages. This 
configuration is interpreted in a special way
by the OSGi framework: it actually means that the API packages will either be 
exported /or/ imported at run time (but
not both).

The reason for this special configuration is that, in a complex OSGi 
application, it is possible that an API package
might be provided by more than one bundle. But you do not want multiple copies 
of an API to be exported into OSGi,
because that can lead to technical problems like class cast exceptions. When a 
package is listed both in the exports and
in the imports, the OSGi resolver proceeds as follows

  * First of all, the resolver checks whether the package has already been 
exported from another bundle. If so, the
    resolver imports the package, but /does not export it/.
  * Otherwise, the resolver uses the local API package and exports this 
package, but it /does not import the package/.

I suppose your both bundles use the above pattern. If you want to force usage 
of the package from the bundle
TcSoaCoreLoose you must ensure this bundle is started first -- the packages 
from this bundle will be exported before the
bundle TcSoaClient will be resolved and the resolver will use the already 
exported packages instead of using the
packages from TcSoaClient

Regards
Krzysztof




 

On 19.06.2015 15:09, Nagesh wrote:
> Hello,
>
> I have added Import-Package statement in manifest.mf and its work fine. Now
> I come across some unusual situation as below
>
> I am getting below runtime exception
>
> Caused by: java.lang.ClassNotFoundException:
> com.teamcenter.services.loose.core.DataManagementService not found by
> TcSoaClient [1136]
>
> to resolve this I have added com.teamcenter.services.loose.core to
> Import-Package statement in TcSoaClient's manifest.mf file. (note package in
> bold letter) 
> Please check its manifest.mf
>
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.7.0
> Created-By: 14.0-b16 (Sun Microsystems Inc.)
> Implementation-Title: Teamcenter Services Client
> Implementation-Version: 8000.3.0, September 16, 2010
> Implementation-Vendor: Siemens PLM Software, Inc.
> Bundle-ManifestVersion: 2
> Bundle-Name: Teamcenter Services Client
> Bundle-SymbolicName: *TcSoaClient*
> Bundle-Version: 8000.3.0
> TC-Version: V8000.3.0.20100916.00
> Bundle-ClassPath: .
> Bundle-Vendor: Siemens PLM Software, Inc.
> Bundle-Localization: plugin
> Bundle-ActivationPolicy: lazy
> Require-Bundle: com.teamcenter.rac.external,com.teamcenter.SecuritySer
>  vices,tcgatewaystubs,TcSoaCommon
> *Export-Package:* com.teamcenter.schemas,com.teamcenter.schemas.soa,com.
>  teamcenter.schemas.soa._2006_03,com.teamcenter.schemas.soa._2006_03.e
>  xceptions,com.teamcenter.services,com.teamcenter.services.internal,co
>  m.teamcenter.services.internal.loose,com.teamcenter.services.internal
>  .loose.core,com.teamcenter.services.internal.loose.core._2006_03,com.
>  teamcenter.services.internal.loose.core._2007_05,com.teamcenter.servi
>  ces.internal.loose.core._2007_12,com.teamcenter.services.internal.loo
>  se.core._2008_03,com.teamcenter.services.internal.loose.core._2008_06
>  ,com.teamcenter.services.internal.loose.core._2010_09,com.teamcenter.
>  services.loose,*com.teamcenter.services.loose.core*,com.teamcenter.serv
>  ices.loose.core._2006_03,com.teamcenter.services.loose.core._2007_01,
>  com.teamcenter.services.loose.core._2007_06,com.teamcenter.services.l
>  oose.core._2007_12,com.teamcenter.services.loose.core._2008_03,com.te
>  amcenter.services.loose.core._2008_06,com.teamcenter.services.loose.c
>  ore._2009_04,com.teamcenter.services.loose.core._2010_04,com.teamcent
>  er.soa,com.teamcenter.soa.client,com.teamcenter.soa.client.model,com.
>  teamcenter.soa.internal,com.teamcenter.soa.internal.client,com.teamce
>  nter.soa.internal.client.model
> *Import-Package:*
> com.teamcenter.schemas.soa._2006_03.exceptions,*com.teamcenter.services.loose.core*,
> com.teamcenter.services.loose.core._2006_03,
> com.teamcenter.services.loose.core._2007_01,
> com.teamcenter.services.loose.query,com.teamcenter.services.loose.query._2006_03,
> com.teamcenter.services.loose.query._2007_06,com.teamcenter.services.strong.core,
> com.teamcenter.services.strong.core._2007_01,javax.xml.datatype
>
>
> TcSoaClient jar export same package (com.teamcenter.services.loose.core)
> which I have added in import-package.
>
> package com.teamcenter.services.loose.core is exist in TcSoaClient.jar and
> in another jar TcSoaCoreLoose(I want to import
> com.teamcenter.services.loose.core from this second jar)
>
> Have a look of manifest.mf of  TcSoaCoreLoose
>
> Manifest-Version: 1.0
> Ant-Version: Apache Ant 1.7.0
> Created-By: 14.0-b16 (Sun Microsystems Inc.)
> Implementation-Title: Teamcenter Services TcSoaCore Loose Client
> Implementation-Version: 8000.3.0, September 16, 2010
> Implementation-Vendor: Siemens PLM Software, Inc.
> Bundle-ManifestVersion: 2
> Bundle-Name: Teamcenter Services TcSoaCore Loose Client
> Bundle-SymbolicName: *TcSoaCoreLoose*
> Bundle-Version: 8000.3.0
> TC-Version: V8000.3.0.20100916.00
> Bundle-ClassPath: .
> Bundle-Vendor: Siemens PLM Software, Inc.
> Bundle-Localization: plugin
> Bundle-ActivationPolicy: lazy
> Require-Bundle: com.teamcenter.rac.external,TcSoaCommon,TcSoaClient,Tc
>  SoaCoreTypes
> *Export-Package:* com.teamcenter.services,com.teamcenter.services.intern
>  al,com.teamcenter.services.internal.loose,com.teamcenter.services.int
>  ernal.loose.core,com.teamcenter.services.internal.loose.core._2007_01
>  ,com.teamcenter.services.internal.loose.core._2007_06,com.teamcenter.
>  services.internal.loose.core._2007_09,com.teamcenter.services.interna
>  l.loose.core._2008_06,com.teamcenter.services.internal.loose.core._20
>  09_10,com.teamcenter.services.internal.loose.core._2010_04,com.teamce
>  nter.services.internal.loose.core._2010_09,com.teamcenter.services.lo
>  ose,*com.teamcenter.services.loose.core*,com.teamcenter.services.loose.
>  core._2006_03,com.teamcenter.services.loose.core._2007_01,com.teamcen
>  ter.services.loose.core._2007_06,com.teamcenter.services.loose.core._
>  2007_09,com.teamcenter.services.loose.core._2007_12,com.teamcenter.se
>  rvices.loose.core._2008_05,com.teamcenter.services.loose.core._2008_0
>  6,com.teamcenter.services.loose.core._2009_04,com.teamcenter.services
>  .loose.core._2009_10,com.teamcenter.services.loose.core._2010_04,com.
>  teamcenter.services.loose.core._2010_09
>
> How can I mention which package to import from which bundle in
> Import-Package statement. i.e. I want to force Import-Package statement to
> load package (com.teamcenter.services.loose.core) from second jar
> TcSoaCoreLoose.jar??
>
>
>
>
>
> --
> View this message in context: 
> http://servicemix.396122.n5.nabble.com/Not-able-to-deploy-example-apache-servicemix-5-4-0-examples-cxf-cxf-osgi-example-after-adding-my-web0-tp5722703p5722712.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.

-- 
Krzysztof Sobkowiak

JEE & OSS Architect
Apache Software Foundation Member
Apache ServiceMix <http://servicemix.apache.org/> Committer & PMC
Senior Solution Architect @ Capgemini SSC <http://www.pl.capgemini-sdm.com/en/>

Reply via email to