"ClassNotFoundException: org.dkpro.tc.api.features.FeatureExtractor" when deploying on server

24 views
Skip to first unread message

Nicolai Erbs

unread,
Jan 22, 2017, 5:57:44 AM1/22/17
to dkpro-tc-users
Hi,

a ClassNotFoundException occurs when I deploy a war on Tomcat. I try to classify a single instance based on an existing model. In Eclipse, everything works fine: the model is generated and single instances can be classified. I'd assume that it shouldn't load the interface FeatureExtractor but the actual classes for the features.

I use DKPro TC version 0.9.0 without having mixed any mixed versions in the dependencies.

Many thanks,
Nicolai


java.lang.ClassNotFoundException: org.dkpro.tc.api.features.FeatureExtractor
 at java
.net.URLClassLoader$1.run(URLClassLoader.java:372)
 at java
.net.URLClassLoader$1.run(URLClassLoader.java:361)
 at java
.security.AccessController.doPrivileged(Native Method)
 at java
.net.URLClassLoader.findClass(URLClassLoader.java:360)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at java
.lang.ClassLoader.defineClass1(Native Method)
 at java
.lang.ClassLoader.defineClass(ClassLoader.java:760)
 at java
.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
 at java
.net.URLClassLoader.defineClass(URLClassLoader.java:455)
 at java
.net.URLClassLoader.access$100(URLClassLoader.java:73)
 at java
.net.URLClassLoader$1.run(URLClassLoader.java:367)
 at java
.net.URLClassLoader$1.run(URLClassLoader.java:361)
 at java
.security.AccessController.doPrivileged(Native Method)
 at java
.net.URLClassLoader.findClass(URLClassLoader.java:360)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at java
.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at org
.dkpro.tc.core.util.SaveModelUtils.loadExternalResourceDescriptionOfFeatures(SaveModelUtils.java:552)
 at org
.dkpro.tc.ml.uima.TcAnnotator.initialize(TcAnnotator.java:87)
 at org
.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:262)
 at org
.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initialize(PrimitiveAnalysisEngine_impl.java:169)
 at org
.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
 at org
.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
 at org
.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
 at org
.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
 at org
.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:429)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:373)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:186)
 at org
.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
 at org
.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
 at org
.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
 at org
.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:407)
 at org
.apache.uima.analysis_engine.asb.impl.ASB_impl.setup(ASB_impl.java:256)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initASB(AggregateAnalysisEngine_impl.java:429)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:373)
 at org
.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:186)
 at org
.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(AnalysisEngineFactory_impl.java:94)
 at org
.apache.uima.impl.CompositeResourceFactory_impl.produceResource(CompositeResourceFactory_impl.java:62)
 at org
.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
 at org
.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
 at org
.apache.uima.UIMAFramework.produceAnalysisEngine(UIMAFramework.java:448)
 at org
.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(AnalysisEngineFactory.java:205)
 at org
.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:227)
 at org
.apache.uima.fit.pipeline.SimplePipeline.runPipeline(SimplePipeline.java:260)


Johannes Daxenberger

unread,
Jan 23, 2017, 11:26:50 AM1/23/17
to Nicolai Erbs, dkpro-tc-users

Hi,

 

I haven’t tested, but I assume the respective DKPro TC module is missing a dependency? Is dkpro-tc-api-features explicitly declared in your project before deployment?

 

Best,

Johannes

--
You received this message because you are subscribed to the Google Groups "dkpro-tc-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dkpro-tc-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nicolai Erbs

unread,
Jan 23, 2017, 11:54:21 AM1/23/17
to dkpro-tc-users
Hi Johannes,

many thanks for your response. dkpro-tc-api-features is explicitely added as dependency and I even verified that it is present in the lib folder of the extracted war.

Best,
Nicolai

Nicolai Erbs

unread,
Jan 23, 2017, 5:54:38 PM1/23/17
to dkpro-tc-users
Hi,

I just solved this issue. The cause of this problem is how the URLClassLoader works which is given the url of the model as input. It tries to load the classes for the feature extractors from the directory with the stored model. In this directory, there are classes for the feature extractors but not for the underlying interfaces and abstract classes.  I assume it hasn't happened before because the model usually isn't loaded from a different directory.

A very nasty trick solved it: I copied the respective classes directly from the jars to the model and it worked.

Best,
Nicolai

Nicolai Erbs

unread,
Jan 24, 2017, 5:24:36 AM1/24/17
to dkpro-tc-users
Hi,

unfortunately, the issue has reappeared somewhere else. Loading the model works fine, but when the systems classifies another instance, the following exception occurs:


org.apache.uima.resource.ResourceInitializationException: Initialization of annotator class "org.dkpro.tc.ml.uima.TcAnnotator" failed.  (Descriptor: <unknown>)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:264)
at de.privalino.classification.knuddels.KnuddelsModelReuser.classify(KnuddelsModelReuser.java:152)
at de.privalino.classification.rest.GroomingRestService.doPost(GroomingRestService.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at de.privalino.classification.rest.CorsFilter.doFilter(CorsFilter.java:27)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.uima.resource.ResourceInitializationException
at org.dkpro.tc.ml.uima.TcAnnotator.initialize(TcAnnotator.java:103)
at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:262)
... 53 more
Caused by: java.lang.ClassCastException: class org.dkpro.tc.features.length.NrOfTokensPerSentence
at java.lang.Class.asSubclass(Class.java:3396)
at org.dkpro.tc.core.util.SaveModelUtils.loadExternalResourceDescriptionOfFeatures(SaveModelUtils.java:553)
at org.dkpro.tc.ml.uima.TcAnnotator.initialize(TcAnnotator.java:87)
... 54 more

Interestingly, the exception is not the same as the previous one. Any thoughts?

Best,
Nicolai 

Nicolai Erbs

unread,
Jan 24, 2017, 5:37:37 PM1/24/17
to dkpro-tc-users
Hi,

this issue has bothered me for several days now and I finally found a fix. The issue is due to different class loaders which load the same class. When trying to cast a class it fails, because it has been loaded with a different class loader. I updated to the snapshot version of DKPro TC and changed the class loader in SaveModelUtils. Line 552 now reads:

 Class<? extends Resource> feClass = Class.forName(name)
                    .asSubclass(Resource.class);
This has the drawback that the classes for the feature extractors need to be present. 
Reply all
Reply to author
Forward
0 new messages