Hi Tim, 

The most likely cause seems to be that the model file represented by 
"sentenceModelPath" can't be found. You need to make sure that the binary model 
file is on the class path, which it probably is in your Eclipse environment, 
but not in the test server environement. Or you can try get the InputStream for 
the resource file like so: 
InputStream fstream = this.getClass().getResourceAsStream(sentenceModelPath);

HTH. 

Cheers, 

Martin
 


Am 29.12.2014 um 21:54 schrieb Tim Hearn <[email protected]>:

> Hi everyone,
> 
> I'm relatively new to OpenNLP software.  For my project I am using the
> Sentence detector feature of opennlp.  When I run the project on my local
> tomcat server through eclipse, the sentence detector feature works great.
> However, when I do a build (through ant) and put it on an internal test
> server, I get the following exception(OpenNLPEvaluator.java is a class
> which I wrote):
> 
> ...
> caused by:  Java.lang.NoClassDefFoundError:opennlpmodel/MaxentModel
> ... OpenNLPEvaluator.loadSentenceModel(OpenNLPEvaluator.java:223)
> 
> ...
> caused by: java.lang.ClassNotFoundException: opennlp.model.MaxentModel
> 
> The lines it fails at:
> 
> OpenNLPEvaluator.java
> 
> 219 InputStream modelIn = null;
> 220 try {
> 221 salsa.getSystemLogger().info("Loading NLP sentence model...");
> 222 modelIn = new FileInputStream(sentenceModelPath);
> 223 SentenceModel sentenceModel = new SentenceModel(modelIn);
> 224 sentenceDetector = new SentenceDetectorME(sentenceModel);
> 225 }
> 226 catch (IOException ex) {
> 227 salsa.getSystemLogger().debug("OpenNLP sentence model failed to load");
> 228 ex.printStackTrace();
> 229 return false;
> 230 }
> 231 finally {
> 232 try {
> 233 modelIn.close();
> 234
> 235 }
> 236 catch (IOException ignored) { }
> 237 }
> 
> It fails at line 223, which is when I try to create a SentenceModel
> object.  All three of the opennlp jars are in my class path, build path,
> and build.xml file.  Can anyone point me in the right direction as to how
> to fix this issue?

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to