Hi All,
I'm working with some CEP extensions the provide NLP support and I want to
use Stanford NLP library with my extensions.
So I'm using following three dependencies
stanford-corenlp-3.4.jar
stanford-corenlp-3.4-models.jar
stanford-tregex-3.4.1.jar
I packaged my extension to a jar and also bundled above three dependencies
to a one osgi bundle since they contain similar packages.
But when my extension is being called I get the following exception.
Caused by:
org.wso2.carbon.event.processor.core.exception.ExecutionPlanConfigurationException:
Invalid query specified, Error creating
edu.stanford.nlp.time.TimeExpressionExtractorImpl
at
org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService.addExecutionPlanConfiguration(CarbonEventProcessorService.java:311)
at
org.wso2.carbon.event.processor.core.EventProcessorDeployer.processDeploy(EventProcessorDeployer.java:138)
... 50 more
Caused by:
edu.stanford.nlp.util.ReflectionLoading$ReflectionLoadingException: Error
creating edu.stanford.nlp.time.TimeExpressionExtractorImpl
at
edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:40)
at
edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(TimeExpressionExtractorFactory.java:57)
at
edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(TimeExpressionExtractorFactory.java:38)
at
edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.<init>(NumberSequenceClassifier.java:79)
at
edu.stanford.nlp.ie.NERClassifierCombiner.<init>(NERClassifierCombiner.java:67)
at
edu.stanford.nlp.pipeline.StanfordCoreNLP$6.create(StanfordCoreNLP.java:617)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85)
at
edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:267)
at
edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:129)
at
edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:125)
at
org.wso2.siddhi.extension.nlp.TokensRegexPatternTransformProcessor.initPipeline(TokensRegexPatternTransformProcessor.java:131)
at
org.wso2.siddhi.extension.nlp.TokensRegexPatternTransformProcessor.init(TokensRegexPatternTransformProcessor.java:72)
at
org.wso2.siddhi.core.query.processor.transform.TransformProcessor.initTransformProcessor(TransformProcessor.java:117)
at
org.wso2.siddhi.core.util.parser.StreamParser.updateQueryEventSourceOutDefinition(StreamParser.java:512)
at
org.wso2.siddhi.core.query.creator.BasicQueryCreator.updateQueryEventSourceList(BasicQueryCreator.java:46)
at
org.wso2.siddhi.core.query.creator.QueryCreator.init(QueryCreator.java:66)
at
org.wso2.siddhi.core.query.creator.BasicQueryCreator.<init>(BasicQueryCreator.java:40)
at
org.wso2.siddhi.core.query.creator.QueryCreatorFactiory.constructQueryCreator(QueryCreatorFactiory.java:40)
at org.wso2.siddhi.core.query.QueryManager.<init>(QueryManager.java:72)
at org.wso2.siddhi.core.SiddhiManager.addQuery(SiddhiManager.java:289)
at
org.wso2.siddhi.core.SiddhiManager.addExecutionPlan(SiddhiManager.java:304)
at
org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService.addExecutionPlanConfiguration(CarbonEventProcessorService.java:309)
... 51 more
Caused by: edu.stanford.nlp.util.MetaClass$ClassCreationException:
MetaClass couldn't create public
edu.stanford.nlp.time.TimeExpressionExtractorImpl(java.lang.String,java.util.Properties)
with args [sutime, {annotators=tokenize, ssplit, pos, lemma, ner, parse}]
at
edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:233)
at edu.stanford.nlp.util.MetaClass.createInstance(MetaClass.java:378)
at
edu.stanford.nlp.util.ReflectionLoading.loadByReflection(ReflectionLoading.java:38)
... 72 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at
edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:229)
... 74 more
Caused by: java.lang.RuntimeException: Error initializing binder 1
at edu.stanford.nlp.time.Options.<init>(Options.java:92)
at
edu.stanford.nlp.time.TimeExpressionExtractorImpl.init(TimeExpressionExtractorImpl.java:48)
at
edu.stanford.nlp.time.TimeExpressionExtractorImpl.<init>(TimeExpressionExtractorImpl.java:42)
... 79 more
*Caused by: java.lang.NullPointerException*
* at
de.jollyday.configuration.internal.DefaultConfigurationProvider.putConfiguration(DefaultConfigurationProvider.java:53)*
* at
de.jollyday.configuration.ConfigurationProviderManager.addInternalConfigurationProviderProperies(ConfigurationProviderManager.java:64)*
* at
de.jollyday.configuration.ConfigurationProviderManager.getConfigurationProperties(ConfigurationProviderManager.java:55)*
* at de.jollyday.HolidayManager.createManager(HolidayManager.java:274)*
* at de.jollyday.HolidayManager.getInstance(HolidayManager.java:194)*
* at edu.stanford.nlp.time.JollyDayHolidays.init(JollyDayHolidays.java:52)*
* at edu.stanford.nlp.time.Options.<init>(Options.java:90)*
* ... 81 more*
It seems to me that the library itself cannot locate some properties file.
I looked at the source of DefaultConfigurationProvider class from which the
exception is initiated.
InputStream stream = null;
try {
try {
stream =
HolidayManager.class.getClassLoader().getResource(CONFIG_FILE).openStream();
if (stream != null) {
properties.load(stream);
} else {
LOG.warning("Could not load default properties file '" + CONFIG_FILE + "'
from classpath.");
}
} finally {
if (stream != null) {
stream.close();
}
}
} catch (IOException e) {
throw new IllegalStateException("Could not load default properties from
classpath.", e);
}
Here it's trying to load a properties file called "jollyday.properties"" as
the CONFIG_FILE. I thinks that the exception is thrown since this file
cannot be seen.
So how should we handle this scenario such that the library can load this
file.
My pom file for the stanford-nlp-bundle is below.
<artifactId>stanford-nlp-bundle</artifactId>
<groupId>org.wso2.siddhi.extension.nlp</groupId>
<packaging>bundle</packaging>
<name>Stanford-NLP</name>
<version>1.0</version>
<description>This bundle exports packages from nlp jar
files</description>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.4</version>
<classifier>models</classifier>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-tregex</artifactId>
<version>3.4.1</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
edu.stanford.nlp.*; version="3.4",
de.jollyday.*; version="3.4"
</Export-Package>
<Import-Package>
*;resolution:=optional
</Import-Package>
<DynamicImport-Package>
*
</DynamicImport-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-tregex</artifactId>
<version>3.4.1</version>
<packaging>jar</packaging>
<file>${basedir}\lib\stanford-tregex-3.4.1.jar</file>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Highly appreciate any help to solve up this problem.
Thank You.
Malithi.
--
*Malithi Edirisinghe*
Senior Software Engineer
WSO2 Inc.
Mobile : +94 (0) 718176807
[email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev