You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Stian Soiland-Reyes (JIRA)" <ji...@apache.org> on 2016/11/07 00:46:59 UTC

[jira] [Created] (JENA-1258) Context key is null (ARQConstants.registryFunctions) via NodeFmtLib

Stian Soiland-Reyes created JENA-1258:
-----------------------------------------

             Summary: Context key is null (ARQConstants.registryFunctions) via NodeFmtLib
                 Key: JENA-1258
                 URL: https://issues.apache.org/jira/browse/JENA-1258
             Project: Apache Jena
          Issue Type: Bug
          Components: ARQ
    Affects Versions: Jena 3.1.1
            Reporter: Stian Soiland-Reyes


This small test, with no ARQ.init(), causes a problem in initializers:

{code}
    @Test
    public void testName() throws Exception {
        Node node = NodeFactory.createLiteral("Hello world", "en");
        assertEquals("\"Hello world\"@en", NodeFmtLib.str(node));
    }
{code}

It fails with:

{code}


java.lang.ExceptionInInitializerError
at org.apache.jena.riot.out.NodeFmtLib.<clinit>(NodeFmtLib.java:55)
at org.apache.commons.rdf.jena.TestNodeStuff.testName(TestNodeStuff.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.jena.sparql.ARQException: Context key is null
at org.apache.jena.sparql.util.Context._put(Context.java:102)
at org.apache.jena.sparql.util.Context.set(Context.java:94)
at org.apache.jena.sparql.function.FunctionRegistry.set(FunctionRegistry.java:74)
at org.apache.jena.sparql.function.FunctionRegistry.init(FunctionRegistry.java:48)
at org.apache.jena.query.ARQ.init(ARQ.java:592)
at org.apache.jena.sparql.system.InitARQ.start(InitARQ.java:29)
at org.apache.jena.system.JenaSystem.lambda$init$2(JenaSystem.java:119)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:194)
at org.apache.jena.system.JenaSystem.forEach(JenaSystem.java:171)
at org.apache.jena.system.JenaSystem.init(JenaSystem.java:117)
at org.apache.jena.sparql.ARQConstants.<clinit>(ARQConstants.java:35)
... 25 more
{code}

closer debugging reveals that it is trying to set a context with the static {{ARQConstants.registryFunctions}} which is still null:

{code}
Thread [main] (Suspended (breakpoint at line 102 in Context))	
	owns: Object  (id=65)	
	owns: Class<T> (org.apache.jena.system.JenaSystem) (id=61)	
	owns: Object  (id=66)	
	Context._put(Symbol, Object) line: 102	
	Context.set(Symbol, Object) line: 94	
	FunctionRegistry.set(Context, FunctionRegistry) line: 74	
	FunctionRegistry.init() line: 48	
	ARQ.init() line: 592	
	InitARQ.start() line: 29	
	JenaSystem.lambda$init$2(JenaSubsystemLifecycle) line: 119	
	2009221452.accept(Object) line: not available	
	ArrayList<E>.forEach(Consumer<? super E>) line: 1249	
	JenaSystem.forEach(Consumer<JenaSubsystemLifecycle>, Comparator<JenaSubsystemLifecycle>) line: 194	
	JenaSystem.forEach(Consumer<JenaSubsystemLifecycle>) line: 171	
	JenaSystem.init() line: 117	
	ARQConstants.<clinit>() line: 35	
	NodeFmtLib.<clinit>() line: 55	
	TestNodeStuff.testName() line: 17	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 62	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43	
	Method.invoke(Object, Object...) line: 498	
	FrameworkMethod$1.runReflectiveCall() line: 50	
	FrameworkMethod$1(ReflectiveCallable).run() line: 12	
	FrameworkMethod.invokeExplosively(Object, Object...) line: 47	
	InvokeMethod.evaluate() line: 17	
	BlockJUnit4ClassRunner(ParentRunner<T>).runLeaf(Statement, Description, RunNotifier) line: 325	
	BlockJUnit4ClassRunner.runChild(FrameworkMethod, RunNotifier) line: 78	
	BlockJUnit4ClassRunner.runChild(Object, RunNotifier) line: 57	
	ParentRunner$3.run() line: 290	
	ParentRunner$1.schedule(Runnable) line: 71	
	BlockJUnit4ClassRunner(ParentRunner<T>).runChildren(RunNotifier) line: 288	
	ParentRunner<T>.access$000(ParentRunner, RunNotifier) line: 58	
	ParentRunner$2.evaluate() line: 268	
	BlockJUnit4ClassRunner(ParentRunner<T>).run(RunNotifier) line: 363	
	JUnit4TestReference.run(TestExecution) line: 86	
	TestExecution.run(ITestReference[]) line: 38	
	RemoteTestRunner.runTests(String[], String, TestExecution) line: 459	
	RemoteTestRunner.runTests(TestExecution) line: 678	
	RemoteTestRunner.run() line: 382	
	RemoteTestRunner.main(String[]) line: 192	
{code}

Workaround: 

{code}
ARQ.init(); // or JenaSystem.init()
{code}

before using NodeFmtLib.

Should NodeFactory ensure {{JenaSystem.init()}}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)