Runtime error with JLanguageTool constructor from an Eclipse plugin

Hi,

I have a Java Eclipse plugin and I am having trouble some really simple
code.

I can do the following …
JLanguageTool langTool;
Language lang = Language.BRITISH_ENGLISH;

However I get a runtime error with the following…
JLanguageTool langTool = new JLanguageTool(Language.BRITISH_ENGLISH);

The following exception is thrown…
java.lang.NoClassDefFoundError: Could not initialize class
org.languagetool.tokenizers.SRXSentenceTokenizer

I unzipped your zip (from your homepage) to the root of my plugin and
added the jars and paths to the classpath.
Then I added the jar paths to the manifest.

I looked into the JLanguageTool.jar and I can see
org.languagetool.tokenizers.SRXSentenceTokenizer is in there.

I had originally unzipped your zip to my Eclipse plugins folder and
pointed the classpath there but had a runtime error with ‘JLanguageTool
langTool;’
So I unzipped it into the plugin root and at least was able to create an
instance of JLanguageTool after that.

Any ideas what is going wrong?
It looks like it could be a good tool for us,
So I would really like to resolve this.
Been messing around with it for a day now.

Any suggestions would be appreciated.

EllenJ

On Fr 18.01.2013, 06:37:24 you wrote:

However I get a runtime error with the following…
JLanguageTool langTool = new JLanguageTool(Language.BRITISH_ENGLISH);

The following exception is thrown…
java.lang.NoClassDefFoundError: Could not initialize class
org.languagetool.tokenizers.SRXSentenceTokenizer

That’s indeed strange, as both of these are in the same JAR. Maybe Eclipse
got confused and it might help to re-build the project? Does the complete
stacktrace reveal more information? Does the same thing happen when you
have a very simple class with just a main() method?

Another approach might be to try Maven, so that you just need to add the
dependency information to your pom.xml (see
http://www.languagetool.org/java-api/) and Maven will do the rest. I don’t
know about how the Maven/Eclipse integration though.

Regards
Daniel


http://www.danielnaber.de

Hi daniel,

thanks for the reply.
I cleaned the project but unfortunately got the same result.

I noticed that the 1st time I run this I get the following …
java.lang.ExceptionInInitializerError
java.lang.UnsupportedOperationException: This parser does not support specification “null” version “null”

After that I get the NoClassDefFoundError exception each time …
java.lang.NoClassDefFoundError: Could not initialize class org.languagetool.tokenizers.SRXSentenceTokenizer

From looking at the JLanguageTool constructor it looks like it is able to get all the rules (and even the disambiguator and tagger) but falters on the Tokeniser class.

Any ideas?
Ellen

More Info…

I can do the following …
JLanguageTool langTool1;
Language lang = Language.ENGLISH;

Disambiguator disambiguator = lang.getDisambiguator();
Tagger tagger = lang.getTagger();
Tokenizer wordTokenizer = lang.getWordTokenizer();
SentenceTokenizer SENTENCE_TOKENIZER = new SentenceTokenizer();

However, I get the error on the following call …
Tokenizer sentenceTokenizer = lang.getSentenceTokenizer();

I have looked in the Language code and do not see any reference to SRXSentenceTokenizer - so this is very strange.

Stacktrace…

Caused by: java.lang.ExceptionInInitializerError
at org.languagetool.language.English.getSentenceTokenizer(English.java:68)

Caused by: java.lang.UnsupportedOperationException: This parser does not support specification “null” version “null”
at javax.xml.parsers.SAXParserFactory.setSchema(Unknown Source)
at net.sourceforge.segment.srx.io.Srx2SaxParser.(Srx2SaxParser.java:179)
at org.languagetool.tokenizers.SRXSentenceTokenizer.createSrxDocument(SRXSentenceTokenizer.java:60)
at org.languagetool.tokenizers.SRXSentenceTokenizer.(SRXSentenceTokenizer.java:47)
… 79 more

Even more info …
I created a simple Jave application and was able to use your sample code with no problems at all.

Does LanguageTool work with Eclipse plugins?
Is there some extra setup required?

I made a simple Eclipse plugin and had the same problems.
I can zip this up and send it if that would be helpful.
Suspect it is an issue with class paths

On Mo 21.01.2013, 08:06:26 you wrote:

I made a simple Eclipse plugin and had the same problems.
I can zip this up and send it if that would be helpful.
Suspect it is an issue with class paths

This might be the solution:

Regards
Daniel


http://www.danielnaber.de

No joy