You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Jaroslav Pullmann <ja...@fit.fraunhofer.de> on 2016/03/20 08:44:38 UTC

Re: Problems using Jena-OSGi / Resolved thanks to OSGi ServiceLoader Mediator

  Hello Andy, 

 > Can you debug enough to see if ARQ.init is bing called from InitARQ?> 
> The NPE can come from getContext() returning null
> and getContext() is not null if ARQ.init has been called because 
> defaultSettings() unconditionally creates a Context object.

 you were right! Apparently the ServiceProvider mechanism and OSGi do not play nicely.

 - I followed the hint on "Service Loader Consumer":

  http://blog.osgi.org/2013/02/javautilservicel oader-in-osgi.html

- used Karaf 4.0.5 providing OSGi v5 APIs along with "OSGi ServiceLoader Mediator" specification

- installed Apache Aries SPI Fly bundle, the reference implementation: 
  http://mvnrepository.com/artifact/org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/1.0.8

- enhanced Jena-Osgi pom according to "spi-fly-example-provider-consumer-bundle"

    http://aries.apache.org/modules/spi-fly.html#examples
    http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
    
    <build>
		  <plugins>
			  <plugin>
				  <groupId>org.apache.felix</groupId>
				  <artifactId>maven-bundle-plugin</artifactId>
				  <configuration>
					  <instructions>
						  ...
						  <SPI-Consumer>*</SPI-Consumer>
						  <SPI-Provider>*</SPI-Provider>
						  ...
					  </instructions>
				  </configuration>
			  </plugin>			
		  </plugins>
	  </build>
        
  
- and, voilà (logging via a bundle Activator with JenaSystem.DEBUG_INIT enabled): 

  JenaSystem.init - start
    InitJenaCore
    InitRIOT
    InitARQ
    InitTDB
  Init: JenaInitLevel0
  Init: InitJenaCore
  JenaCore.init - start
  JenaCore.init - finish
  Init: InitRIOT
  RIOT.init - start
  RIOT.init - finish
  Init: InitARQ
  ARQ.init - start
  ARQ.init - finish
  Init: InitTDB
  TDB.init - start
  TDB.init - finish
  JenaSystem.init - finish
  Jena-Osgi bundle configured!

 
> We know that it is only a small %-age of the downloads.  There is a good 
> chance that people are also packaging their own setups because the 
> bundles are right for them.
> 
> Having feedback and fixes is essential to keep a module usable.

  I am glad to use Jena, and now even more ;o) Many thanks for  you support.

  Best regards 
 Jaroslav

 
 

-- 
Jaroslav Pullmann
Fraunhofer Institute for Applied Information Technology FIT
Web Compliance Center: http://imergo.com/ · http://imergo.de/
Schloss Birlinghoven, D-53757 Sankt Augustin, Germany
Phone: +49-2241-142623 · Fax: +49-2241-142065 




Re: Problems using Jena-OSGi / Resolved thanks to OSGi ServiceLoader Mediator

Posted by Andy Seaborne <an...@apache.org>.
Jaroslav,

Would it be possible for you to create a pull request against he current 
codebase for this?  Having someone who understands OSGi make this change 
is better than having someone who does no use OSGi day-to-day.

	Andy

On 20/03/16 07:44, Jaroslav Pullmann wrote:
>    Hello Andy,
>
>   > Can you debug enough to see if ARQ.init is bing called from InitARQ?>
>> The NPE can come from getContext() returning null
>> and getContext() is not null if ARQ.init has been called because
>> defaultSettings() unconditionally creates a Context object.
>
>   you were right! Apparently the ServiceProvider mechanism and OSGi do not play nicely.
>
>   - I followed the hint on "Service Loader Consumer":
>
>    http://blog.osgi.org/2013/02/javautilservicel oader-in-osgi.html
>
> - used Karaf 4.0.5 providing OSGi v5 APIs along with "OSGi ServiceLoader Mediator" specification
>
> - installed Apache Aries SPI Fly bundle, the reference implementation:
>    http://mvnrepository.com/artifact/org.apache.aries.spifly/org.apache.aries.spifly.dynamic.bundle/1.0.8
>
> - enhanced Jena-Osgi pom according to "spi-fly-example-provider-consumer-bundle"
>
>      http://aries.apache.org/modules/spi-fly.html#examples
>      http://svn.apache.org/repos/asf/aries/trunk/spi-fly/spi-fly-examples/spi-fly-example-provider-consumer-bundle/pom.xml
>
>      <build>
> 		  <plugins>
> 			  <plugin>
> 				  <groupId>org.apache.felix</groupId>
> 				  <artifactId>maven-bundle-plugin</artifactId>
> 				  <configuration>
> 					  <instructions>
> 						  ...
> 						  <SPI-Consumer>*</SPI-Consumer>
> 						  <SPI-Provider>*</SPI-Provider>
> 						  ...
> 					  </instructions>
> 				  </configuration>
> 			  </plugin>			
> 		  </plugins>
> 	  </build>
>
>
> - and, voilà (logging via a bundle Activator with JenaSystem.DEBUG_INIT enabled):
>
>    JenaSystem.init - start
>      InitJenaCore
>      InitRIOT
>      InitARQ
>      InitTDB
>    Init: JenaInitLevel0
>    Init: InitJenaCore
>    JenaCore.init - start
>    JenaCore.init - finish
>    Init: InitRIOT
>    RIOT.init - start
>    RIOT.init - finish
>    Init: InitARQ
>    ARQ.init - start
>    ARQ.init - finish
>    Init: InitTDB
>    TDB.init - start
>    TDB.init - finish
>    JenaSystem.init - finish
>    Jena-Osgi bundle configured!
>
>
>> We know that it is only a small %-age of the downloads.  There is a good
>> chance that people are also packaging their own setups because the
>> bundles are right for them.
>>
>> Having feedback and fixes is essential to keep a module usable.
>
>    I am glad to use Jena, and now even more ;o) Many thanks for  you support.
>
>    Best regards
>   Jaroslav
>
>
>
>