On 30/06/2020 23:11, Martynas Jusevičius wrote:
Andy,

where do you put JenaSystem.init() in unit tests, for example?

Using 3.16.0-SNAPSHOT, I've changed the test code a little and started
getting this - though only when I attempt to debug the ConstraintTest
class:

com.atomgraph.spinrdf.constraints.ConstraintTest  Time elapsed: 0.419
sec  <<< ERROR!
java.lang.NoClassDefFoundError:
org/apache/jena/sparql/engine/main/StageGenerator
at org.apache.jena.tdb.sys.InitTDB.start(InitTDB.java:29)
at org.apache.jena.sys.JenaSystem.lambda$init$2(JenaSystem.java:117)
at java.util.ArrayList.forEach(ArrayList.java:1257)
at org.apache.jena.sys.JenaSystem.forEach(JenaSystem.java:192)
at org.apache.jena.sys.JenaSystem.forEach(JenaSystem.java:169)
at org.apache.jena.sys.JenaSystem.init(JenaSystem.java:115)
at 
com.atomgraph.spinrdf.constraints.ConstraintTest.<clinit>(ConstraintTest.java:51)

The call is in a static initializer:

public class ConstraintTest
{

     static
     {

You check everything is available with:

           JenaSystem.DEBUG_INIT = true;

         JenaSystem.init();
     }

Or is this unrelated to the JenaSystem.init()?


Unrelated.

It is as if there is a missing jar.

    Andy


Most of the time JenaSystem.init() happens automatically because it is in a static block of every major entry point class - but Java class initialization, and the fact that initialization of recursive class is switched off by off when one class is loading, makes it complicated even though thread-safe. "static final X = new Object" can be null!

(RDFLangauges/Lang is particular hard because there is a mutual dependency that predates the full JenaSystem.init).


POM:

         <dependency>
             <groupId>org.apache.jena</groupId>
             <artifactId>apache-jena-libs</artifactId>
             <version>3.16.0-SNAPSHOT</version>
             <type>pom</type>
         </dependency>

On Mon, Jun 29, 2020 at 11:40 PM Martynas Jusevičius
<[email protected]> wrote:

On Mon, Jun 29, 2020 at 6:34 PM Andy Seaborne <[email protected]> wrote:



On 29/06/2020 14:47, Martynas Jusevičius wrote:
Hi,

I've got a class that is initialized with Jena's registered languages:

And how/when is that called?

I presume you don't use Jena initialization mechanism.

https://jena.apache.org/documentation/notes/system-initialization

You're right, I've missed that. JenaSystem.init() wasn't being called.

One thing as a general measure: call "JenaSystem.init()" early in statup
before requests come in.

Yes. I was wondering where that could be in a webapp. But then I found
the FusekiServerEnvironmentInit (ServletContextListener) and
implemented the same and now it looks like the problem went away.
https://github.com/apache/jena/blob/master/jena-fuseki2/jena-fuseki-webapp/src/main/java/org/apache/jena/fuseki/webapp/FusekiServerEnvironmentInit.java

Reply via email to