one set of solutions: http://njbartlett.name/2010/08/30/osgi-readiness-loading-classes.html
-------- Original Message -------- Subject: pivot + osgi : class loading? From: Andrei Pozolotin <[email protected]> To: [email protected] Date: Fri 13 May 2011 10:35:37 PM CDT > > *Greg, *hello; > > > 1) I am hitting in the following issue while trying to run pivot > in osgi environment: > > this example > http://pivot.apache.org/tutorials/labels-and-image-views.html > > |<||Window| |title||=||"Labels"| |maximized||=||"true"| > | ||xmlns:bxml||=||"http://pivot.apache.org/bxml"| > | ||xmlns||=||"org.apache.pivot.wtk"||>| > | ||<||BoxPane| |styles||=||"{padding:4, > verticalAlignment:'center'}"||>| > | ||<||ImageView| |image||=||"/clock.png"||/>| > | ||<||Label| |text||=||"What time is it?"||/>| > | ||</||BoxPane||>| > |</||Window||>| > > > 2) in terms of |ImageView| properties, it is getting translated by > BXMLSerializer into a call |*setImage(String imageName)*| , > which fails to locate resource: > > |||ImageView :: > /** > * Sets the image view's image by {@linkplain > ClassLoader#getResource(String) > * resource name}. > * > * @param imageName > * The resource name of the image to set. > * > * @see #setImage(URL) > */ > * public final void setImage(String imageName) { > * if (imageName == null) { > throw new IllegalArgumentException("imageName is null."); > } > > * ClassLoader classLoader = > Thread.currentThread().getContextClassLoader(); > setImage(classLoader.getResource(imageName.substring(1))); > * } > > |2) note that in my case the pivot package classes and > [AWT-EventQueue-0] event queues are instantiated in osgi host > class loader > > > http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html > but the actual call to |setImage(String imageName)| is executed in > osgi plugin class loader; > > just to give you an example, when this snipped gets executed > inside osgi plugin bundle: > > // class loader used by pivot > ClassLoader loader = > Thread.currentThread().getContextClassLoader(); > URL urlPivot = loader.getResource(""); > * log.info("urlPivot : {} ", urlPivot); > * > // class loader used by plugin bundle > URL urlOSGI = getClass().getResource(""); > * log.info("urlOSGI : {}", urlOSGI); > * > it produces this log: > > 22:08:46.876 [AWT-EventQueue-0] INFO > com.carrotgarden.core.LoginComponent - urlPivot : > > file:/home/user1/Workspaces/github/carrot-tester/carrot-test-osgi-ws/carrot-test-osgi-pivot-host/target/test-classes/ > > > 22:08:46.876 [AWT-EventQueue-0] INFO > com.carrotgarden.core.LoginComponent - urlOSGI : > bundle://7.0:1/com/carrotgarden/core/ > > as you can see, > * urlPivot : > > file:/home/user1/Workspaces/github/carrot-tester/carrot-test-osgi-ws/carrot-test-osgi-pivot-host/target/test-classes/ > > *resolves back to osgi host class loader which is not visible by > the the client plugin > > and > * urlOSGI : bundle://7.0:1/com/carrotgarden/core/ > *resolves inside calling osgi bundle name space as expected; > > > 3) am I missing something obvious? > why do you use current class loading approach in pivot? > are you open to change this? > what would your recommend instead? > > > Thank you, > > Andrei. >
