stucco / relation-extractor

Extract relationships between cyber security entities within unstructured text
Other
23 stars 9 forks source link

Can't run the tests (Could not create JAXB context) #2

Open hgasmi opened 6 years ago

hgasmi commented 6 years ago

I got an error when trying to run the tests (mvn test -Dmaven.test.skip=false). Could you please help?

Initializing JollyDayHoliday for sutime with classpath:edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml Sep 12, 2018 11:45:59 AM de.jollyday.util.XMLUtil unmarshallConfiguration WARNING: Could not create JAXB context using the current threads context classloader. Defaulting to ObjectFactory classloader. Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 9.569 sec <<< FAILURE! testGetGraph(gov.ornl.stucco.RelationExtractorTest) Time elapsed: 9.531 sec <<< ERROR! 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.(NumberSequenceClassifier.java:79) at edu.stanford.nlp.ie.NERClassifierCombiner.(NERClassifierCombiner.java:68) at edu.stanford.nlp.pipeline.AnnotatorImplementations.ner(AnnotatorImplementations.java:99) at edu.stanford.nlp.pipeline.StanfordCoreNLP$6.create(StanfordCoreNLP.java:627) at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85) at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:292) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:129) at edu.stanford.nlp.pipeline.StanfordCoreNLP.(StanfordCoreNLP.java:125) at gov.ornl.stucco.entity.EntityLabeler.(EntityLabeler.java:26) at gov.ornl.stucco.RelationExtractorTest.testGetGraph(RelationExtractorTest.java:107) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) 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, {customAnnotatorClass.cyberentity=gov.ornl.stucco.entity.CyberEntityAnnotator, annotators=tokenize, ssplit, pos, cyberheuristics, cyberentity, lemma, ner, parse, customAnnotatorClass.cyberheuristics=gov.ornl.stucco.entity.heuristics.CyberHeuristicAnnotator}] 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) ... 40 more Caused by: java.lang.reflect.InvocationTargetException at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) at edu.stanford.nlp.util.MetaClass$ClassFactory.createInstance(MetaClass.java:229) ... 42 more Caused by: java.lang.RuntimeException: Error initializing binder 1 at edu.stanford.nlp.time.Options.(Options.java:92) at edu.stanford.nlp.time.TimeExpressionExtractorImpl.init(TimeExpressionExtractorImpl.java:45) at edu.stanford.nlp.time.TimeExpressionExtractorImpl.(TimeExpressionExtractorImpl.java:39) ... 47 more Caused by: java.lang.IllegalStateException: Cannot instantiate configuration. at de.jollyday.impl.XMLManager.init(XMLManager.java:286) at de.jollyday.HolidayManager.createManager(HolidayManager.java:278) at de.jollyday.HolidayManager.getInstance(HolidayManager.java:194) at edu.stanford.nlp.time.JollyDayHolidays.init(JollyDayHolidays.java:52) at edu.stanford.nlp.time.Options.(Options.java:90) ... 49 more Caused by: java.lang.IllegalStateException: Cannot parse holidays XML file. at de.jollyday.util.XMLUtil.unmarshallConfiguration(XMLUtil.java:80) at de.jollyday.impl.XMLManager.init(XMLManager.java:284) ... 53 more Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory not found

Results :

Tests in error: testGetGraph(gov.ornl.stucco.RelationExtractorTest): Error creating edu.stanford.nlp.time.TimeExpressionExtractorImpl

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

testak commented 6 years ago

It looks like a dependency of the project is not installed. Please run the following commands from the relation-extraction project directory before trying to run the test:

mvn scm:checkout -Dmodule.name=entity-extractor
cd entity-extractor
mvn clean install
cd ..
mvn clean package

Let me know if that helps.

hgasmi commented 6 years ago

Thanks, testak but what I am getting is a runtime error when I run the tests, not a compilation issue. I already installed the dependency and the code is compiling fine. Are you able to run the test fine?

testak commented 6 years ago

Which branch of the relation-extractor are you working with?

It appears I need to update the expected output within the test. However, when I run the tests on both develop and master branches I get an AssertionError because the expected output does not match the actual output of the test. Here is a section of my output that starts with initializing JollyDayHoliday:

Initializing JollyDayHoliday for sutime with classpath:edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
Oct 03, 2018 8:43:22 AM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Ignoring inactive rule: null
Oct 03, 2018 8:43:22 AM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Ignoring inactive rule: temporal-composite-8:ranges
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.holidays.sutime.txt
Adding annotator parse
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ...done [0.5 sec].
Annotating 'My Doc'...
Annotating with heuristic cyber labels ... 
Annotating with cyber labels ... 
Loading relationship patterns from 'src/main/resources/patterns_relations_abbrev.json'...
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 16.491 sec <<< FAILURE!
testGetGraph(gov.ornl.stucco.RelationExtractorTest)  Time elapsed: 16.459 sec  <<< FAILURE!
java.lang.AssertionError
    at gov.ornl.stucco.RelationExtractorTest.testGetGraph(RelationExtractorTest.java:111)

I understand you are seeing your error at runtime, but according to your output it's due to a missing class, which is a dependency for Stanford's CoreNLP library used by the entity-extractor:

Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory not found
hgasmi commented 6 years ago

I am working on master. I did make sure the dependency is installed but I am still getting the same error.

C:\IEcode\stucco-entity-extractor>mvn clean install [INFO] Scanning for projects... [INFO] [INFO] ------------------< gov.ornl.stucco:entity-extractor >------------------ [INFO] Building entity-extractor 1.0.0 [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ entity-extractor --- [INFO] Deleting C:\IEcode\stucco-entity-extractor\target [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ entity-extractor --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 6 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ entity-extractor --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 12 source files to C:\IEcode\stucco-entity-extractor\target\classes [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default) @ entity-extractor --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 12 source files to C:\IEcode\stucco-entity-extractor\target\classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ entity-extractor --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ entity-extractor --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ entity-extractor --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ entity-extractor --- [INFO] Building jar: C:\IEcode\stucco-entity-extractor\target\entity-extractor-1.0.0.jar [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ entity-extractor --- [INFO] Installing C:\IEcode\stucco-entity-extractor\target\entity-extractor-1.0.0.jar to C:\Users\Houssem.m2\repository\gov\ornl\stucco\entity-extractor\1.0.0\entity-extractor-1.0.0.jar [INFO] Installing C:\IEcode\stucco-entity-extractor\pom.xml to C:\Users\Houssem.m2\repository\gov\ornl\stucco\entity-extractor\1.0.0\entity-extractor-1.0.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.950 s [INFO] Finished at: 2018-10-05T11:56:27+03:00 [INFO] ------------------------------------------------------------------------

hgasmi commented 6 years ago

Fixed the error. It was happening because the jaxb libraries are not included by default in java 9 and 10. So I added them to the pom and it worked fine. Now am I getting the assertion error you mentioned above. Did you get anywhere with it?