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/15 15:11:26 UTC

Problems using Jena-OSGi

  Hello,

   while updating our OSGi-based software to Jena 3.* we experience some tricky errors.
  The following 3 test scenarios were run on a Ubuntu Linux 12.04, 64bit, Java 1.8.0.

Test 1

- Using standard Karaf 3.0.5
- Jena-OSGi built from Git including new patches for: https://github.com/apache/jena/pull/126
- Jena-OSGi deployed in unmodified state containing the embedded Xerces 2.11 dependency
- There is a Xerces 2.11 version placed in "$Karaf/lib/endorsed". A related error was reported:

    https://github.com/sgtp/SemScape/issues/6

   but Xerces is mandatory for Karaf 3.0.5, it won't start otherwise.

2016-03-15 14:02:02,140 | ERROR | qlUpdateService) | impl                             | 120 - eu.link
smart.metadata.impl - 0.0.1.SNAPSHOT | [SparqlQueryManager(8)] The activate method has thrown an exce
ption
java.lang.VerifyError: (class: org/apache/xerces/impl/dv/xs/AbstractDateTimeDV, method: <clinit> signature: ()V) Bad 
type in putfield/putstatic
         at org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.<clinit>(Unknown Source)[:]
         at org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.createBuiltInTypes(Unknown Source)[:]
         at org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(Unknown Source)[:]
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_05]
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_05]
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_05]
         at java.lang.reflect.Constructor.newInstance(Constructor.java:408)[:1.8.0_05]
         at java.lang.Class.newInstance(Class.java:433)[:1.8.0_05]
         at org.apache.xerces.impl.dv.ObjectFactory.newInstance(Unknown Source)[:]
         at org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(Unknown Source)[:]
         at org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(Unknown Source)[:]
         at org.apache.jena.datatypes.xsd.XSDDatatype.<init>(XSDDatatype.java:238)
         at org.apache.jena.datatypes.xsd.XSDDatatype.<init>(XSDDatatype.java:250)
         at org.apache.jena.datatypes.xsd.impl.XSDFloat.<init>(XSDFloat.java:49)
         at org.apache.jena.datatypes.xsd.XSDDatatype.<clinit>(XSDDatatype.java:62)
         at org.apache.jena.sparql.graph.NodeConst.<clinit>(NodeConst.java:39)
         at org.apache.jena.sparql.lang.ParserBase.<init>(ParserBase.java:63)
         at org.apache.jena.sparql.lang.SPARQLParserBase.<init>(SPARQLParserBase.java:49)

Leads to:

2016-03-15 14:02:02,162 | ERROR | qlUpdateService) | impl                             | 120 - eu.linksmart.metadata.impl 
- 0.0.1.SNAPSHOT | [SparqlQueryManager(8)] The activate method has thrown an exception
java.lang.NoClassDefFoundError: Could not initialize class org.apache.jena.sparql.graph.NodeConst
         at org.apache.jena.sparql.lang.ParserBase.<init>(ParserBase.java:63)
         at org.apache.jena.sparql.lang.SPARQLParserBase.<init>(SPARQLParserBase.java:49)
         at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11Base.<init>(SPARQLParser11Base.java:22)
         at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.<init>(SPARQLParser11.java:4974)
         at org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:92)
         at org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
         at org.apache.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
         at org.apache.jena.query.QueryFactory.parse(QueryFactory.java:147)


Test 2

- Removed Xerces from Jena-OSGi bundle
- Added Import-package directive for those packages in Jena-OSGi
- Apparently there is no problem with missing packages, the only permanent error:

2016-03-15 14:21:40,382 | ERROR | qlUpdateService) | impl                             | 120 - eu.linksmart.metadata.impl 
- 0.0.1.SNAPSHOT | [SparqlQueryManager(8)] The activate method has thrown an exception
java.lang.NullPointerException
         at org.apache.jena.query.ARQ.isTrue(ARQ.java:620)
         at org.apache.jena.sparql.lang.ParserBase.<init>(ParserBase.java:307)
         at org.apache.jena.sparql.lang.SPARQLParserBase.<init>(SPARQLParserBase.java:49)
         at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11Base.<init>(SPARQLParser11Base.java:22)
         at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.<init>(SPARQLParser11.java:4974)
         at org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:92)
         at org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
         at org.apache.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
         at org.apache.jena.query.QueryFactory.parse(QueryFactory.java:147)
         at org.apache.jena.query.QueryFactory.create(QueryFactory.java:79)
         at org.apache.jena.query.QueryFactory.create(QueryFactory.java:52)
         at org.apache.jena.query.QueryFactory.create(QueryFactory.java:40)

Test 3	
	
- Using Karaf 4.0.4
- It seems o.k. with this version to remove Xerces 2.11 from "$Karaf/lib/endorsed"
- Same error, ARQ does not seem to be configured correctly:

[SparqlQueryManager(4)] The activate method has thrown an exception
java.lang.NullPointerException
	at org.apache.jena.query.ARQ.isTrue(ARQ.java:620)
	at org.apache.jena.sparql.lang.ParserBase.<init>(ParserBase.java:307)
	at org.apache.jena.sparql.lang.SPARQLParserBase.<init>(SPARQLParserBase.java:49)
	at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11Base.<init>(SPARQLParser11Base.java:22)
	at org.apache.jena.sparql.lang.sparql_11.SPARQLParser11.<init>(SPARQLParser11.java:4974)
	at org.apache.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:92)
	at org.apache.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:52)
	at org.apache.jena.sparql.lang.SPARQLParser.parse(SPARQLParser.java:34)
	at org.apache.jena.query.QueryFactory.parse(QueryFactory.java:147)
	at org.apache.jena.query.QueryFactory.create(QueryFactory.java:79)
	at org.apache.jena.query.QueryFactory.create(QueryFactory.java:52)
	at org.apache.jena.query.QueryFactory.create(QueryFactory.java:40)
	at eu.linksmart.metadata.service.impl.sparql.SparqlQueryServiceImpl.createQuery(SparqlQueryServiceImpl.java:109)


   Your help is highly appreciated!
    Best regards
   Jaro


-- 
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

Posted by Andy Seaborne <an...@apache.org>.
On 15/03/16 22:47, Jaroslav Pullmann wrote:
>
>    Hello Andy,
>
>> The error in tests 2 and 3 looks like it is because Jena initialization
>> has not happened.
>> The default is to use ServiceLoader which looks for META-INF/services/
>> org.apache.jena.system.JenaSubsystemLifecycle
>
>   Apparently there was an effort to fix this in the combined Jena-OSGI bundle
>   which META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle
>
>   configuration already lists the main subsystems in the appropriate order:
>
>      org.apache.jena.system.InitJenaCore
>      org.apache.jena.riot.system.InitRIOT
>      org.apache.jena.sparql.system.InitARQ
>      org.apache.jena.tdb.sys.InitTDB

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.



>
>   I am wondering whether and how Jena v3 is used in OSGi environments so far?

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.

>
>   > Or you can inject a different procedure with JenaSystem.setSubsystemRegistry
>
>   This seems the only option to explicitly debug and configure the initialization in an OSGi runtime.
>   Thanks for the reference!
>     Jaro
>
>


Re: Problems using Jena-OSGi

Posted by Jaroslav Pullmann <ja...@fit.fraunhofer.de>.
  Hello Andy,

> The error in tests 2 and 3 looks like it is because Jena initialization 
> has not happened.
> The default is to use ServiceLoader which looks for META-INF/services/ 
> org.apache.jena.system.JenaSubsystemLifecycle

 Apparently there was an effort to fix this in the combined Jena-OSGI bundle 
 which META-INF/services/org.apache.jena.system.JenaSubsystemLifecycle

 configuration already lists the main subsystems in the appropriate order:

    org.apache.jena.system.InitJenaCore
    org.apache.jena.riot.system.InitRIOT
    org.apache.jena.sparql.system.InitARQ
    org.apache.jena.tdb.sys.InitTDB

 I am wondering whether and how Jena v3 is used in OSGi environments so far?

 > Or you can inject a different procedure with JenaSystem.setSubsystemRegistry

 This seems the only option to explicitly debug and configure the initialization in an OSGi runtime. 
 Thanks for the reference!
   Jaro
 
-- 
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

Posted by Andy Seaborne <an...@apache.org>.
(I am not an OSGi user)

On 15/03/16 14:11, Jaroslav Pullmann wrote:
>
>   Hello,
>
>    while updating our OSGi-based software to Jena 3.* we experience some
> tricky errors.
>   The following 3 test scenarios were run on a Ubuntu Linux 12.04,
> 64bit, Java 1.8.0.
>
> Test 1

java.lang.VerifyError : somekinfd of version-of-jar problem but I cant' 
see what

> Test 2
>
> - Removed Xerces from Jena-OSGi bundle
> - Added Import-package directive for those packages in Jena-OSGi
> - Apparently there is no problem with missing packages, the only
> permanent error:
>
> 2016-03-15 14:21:40,382 | ERROR | qlUpdateService) |
> impl                             | 120 - eu.linksmart.metadata.impl -
> 0.0.1.SNAPSHOT | [SparqlQueryManager(8)] The activate method has thrown
> an exception
> java.lang.NullPointerException
>          at org.apache.jena.query.ARQ.isTrue(ARQ.java:620)

> Test 3
>
> - Using Karaf 4.0.4
> - It seems o.k. with this version to remove Xerces 2.11 from
> "$Karaf/lib/endorsed"
> - Same error, ARQ does not seem to be configured correctly:
>
> [SparqlQueryManager(4)] The activate method has thrown an exception
> java.lang.NullPointerException
>      at org.apache.jena.query.ARQ.isTrue(ARQ.java:620)
...

The error in tests 2 and 3 looks like it is because Jena initialization 
has not happened.

http://jena.apache.org/documentation/notes/system-initialization.html


The default is to use ServiceLoader which looks for META-INF/services/ 
org.apache.jena.system.JenaSubsystemLifecycle

If your setup is a single jar then the contents of this from all modules 
needs to be combined:

For example, Fuseki, which is a combined jar, has:

org.apache.jena.tdb.sys.InitTDB
org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
org.apache.jena.system.InitJenaCore
org.apache.jena.query.text.InitJenaText
org.apache.jena.query.spatial.InitJenaSpatial

It's done in the POM during shading with:

  <transformer 
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" 
/>

Is an equivalent for OSGi?

Or you can inject a different procedure with JenaSystem.setSubsystemRegistry

	Andy