dncolomer
dncolomer

Reputation: 83

java.lang.NoClassDefFoundError: Could not initialize class com.hp.hpl.jena.query.Query

I am playing a little bit around with Jena, and I set up a Java Google Web Application project in Eclipse. I downloaded the Jena 2.0 libraries, and added them to the Build Path of the project, and also to the /war/WEB-INFO/lib/ folder.

My simple servlet tries to instantiate a Query using the following line of code:

...
Query query = QueryFactory.create(queryString);
...

So, there are no compilation errors, and as I said, the libarries are both in the Build Path and in the lib folder under WEB-INF (in the war dir).

When I Run the webapp and execute the servlet, I get the following Exception:

java.lang.NoClassDefFoundError: Could not initialize class com.hp.hpl.jena.query.Query
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:78)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
    at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
    at nyx.servlets.PeripheralServlet.extractPlace(PeripheralServlet.java:102)
    at nyx.servlets.PeripheralServlet.doCreate(PeripheralServlet.java:83)

The servlet class is PeripheralServlet.java, and the line 102 in the method extractPlace() is the one above where I try to instantiate the Query object.

Could anyone give me a clue on what my problem might be? To me, it looks like a missing jar inclusion or something on that line, but as I said, I included all the jars from Jena to both the Build Path of the project and to the lib folder under WEB-INF.

EDIT:

The weird thing is that the QueryFactory it actually gives no error, and both Query and QueryFactory are in the same Jena package right?

EDIT2:

After repeating the process from scratch and making sure only the needed jars are included, once now, I get the following exception:

java.lang.StackOverflowError
  at java.util.regex.Pattern$Curly.match(Pattern.java:3744)
  at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
  at java.util.regex.Pattern$Branch.match(Pattern.java:4114)
  at java.util.regex.Pattern$Branch.match(Pattern.java:4112)
  at java.util.regex.Pattern$GroupTail.match(Pattern.java:4227)
  at java.util.regex.Pattern$Curly.match0(Pattern.java:3782)
  at java.util.regex.Pattern$Curly.match(Pattern.java:3744)
  at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168)
  at java.util.regex.Pattern$Start.match(Pattern.java:3055)
  at java.util.regex.Matcher.search(Matcher.java:1105)
  at java.util.regex.Matcher.find(Matcher.java:535)
  at com.google.appengine.tools.development.LocalEnvironment.getServerName(LocalEnvironment.java:302)
  at com.google.appengine.tools.development.DevAppServerImpl.getCurrentAppContext(DevAppServerImpl.java:372)
  ...
  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:82)
  at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
  at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:704)
  at org.slf4j.impl.JCLLoggerFactory.getLogger(JCLLoggerFactory.java:64)
  ...

If I reload the page after this, I get again the original exception. I have been doing some research, and I found some related problems dating back to 2009, and so Jena version is 2.6. Assuming we are in 2013 and Jena has evolved to its 2.10 version, I guess it is not so relevant.

Upvotes: 1

Views: 2721

Answers (2)

LDIG
LDIG

Reputation: 1

I have the same problem with ModelFactory.createDefaultModel(); The jars come from the last Jena (2.11.0) and AppEngine 1.8.4 .

XercesImpl was having problems, so I removed it from the build path. But still I found very strange that the error is at runtime and no compilation warning is issued.

Upvotes: 0

Roman C
Roman C

Reputation: 1

Add the following jar to classpath

arq-2.8.1-SHAPSHOT.jar

Upvotes: 0

Related Questions