ctakes-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Finan, Sean" <Sean.Fi...@childrens.harvard.edu>
Subject RE: jcasPool problem
Date Thu, 16 Feb 2017 16:14:39 GMT
Hi Alaa,

I have no idea what is causing your error using caspool.  Ctakes and uima both suffer from
a lack of descriptive error output.

Here is something that was used a while ago for testing. The trick is that the cas pool is
just used for storage of reusable cas objects.  The Java ExecutorService handles the actual
thread maintenance.  caspool is like jcaspool.  

public class ParallelXcasDeserializer {

   static private final Logger LOGGER = Logger.getLogger( "ParallelXcasDeserializer" );
   static private final int PROCESS_COUNT = 10;
   static private final CasPool CAS_POOL = createCasPool( PROCESS_COUNT );

   static private CasPool createCasPool( final int processCount ) {
      try {
         final AnalysisEngineDescription fastPipelineDesc = ClinicalPipelineFactory.getFastPipeline();
         final AnalysisEngine fastPipeline = AnalysisEngineFactory.createEngine( fastPipelineDesc
);
         return new CasPool( processCount, fastPipeline );
      } catch ( UIMAException | MalformedURLException multE ) {
         LOGGER.error( multE.getMessage() );
      }
      return null;
   }

   static private final class XCasDeserializer implements Runnable {
      private final String _xcasFilePath;
      private XCasDeserializer( final String xcasFilePath ) {
         _xcasFilePath = xcasFilePath;
      }
      @Override
      public void run() {
         final CAS cas = CAS_POOL.getCas();
         try ( InputStream xCasStream = new FileInputStream( _xcasFilePath ) ) {
            XCASDeserializer.deserialize( xCasStream, cas );
            final JCas jCas = cas.getJCas();
            OntologyConceptUtil.getCuis( jCas ).forEach( LOGGER::info );
         } catch ( IOException | SAXException | CASException multE ) {
            LOGGER.error( multE.getMessage() );
         }
         CAS_POOL.releaseCas( cas );
      }
   }

   public static void main( final String... args ) {
      if ( CAS_POOL == null ) {
         LOGGER.error( "Couldn't create CAS Pool, exiting" );
         System.exit( 1 );
      }
      final Path inputDir = Paths.get( args[ 0 ] );
      final ExecutorService executor = Executors.newFixedThreadPool( PROCESS_COUNT );
      try ( DirectoryStream<Path> filePaths = Files.newDirectoryStream( inputDir ) )
{
         for ( Path filePath : filePaths ) {
            executor.execute( new XCasDeserializer( filePath.toString() ) );
         }
      } catch ( IOException ioE ) {
         LOGGER.error( ioE.getMessage() );
      }
      executor.shutdown();
   }

}

-----Original Message-----
From: Alaa al Barari [mailto:alaa.albarari@gmail.com] 
Sent: Thursday, February 16, 2017 7:33 AM
To: dev@ctakes.apache.org
Subject: jcasPool problem

Hi,

anyone used jcasPool before ? is it working with you ? any ideas, insights ....  I have this
issue :
aggregateBuilder = Pipeline.getAggregateBuilder(); pipeline = aggregateBuilder.createAggregate();
jCasPool = new JCasPool(10, pipeline);


then

JCas jcas = jCasPool.getJCas(0);
jcas.setDocumentText(text);
pipeline.process(jcas);

but it throws the following exception when calling second block of code twice :

Info:   Annotator processing failed.
Severe:   org.apache.uima.analysis_engine.AnalysisEngineProcessException:
Annotator processing failed.
at
org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:391)
at
org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:296)
at
org.apache.uima.analysis_engine.asb.impl.ASB_impl$AggregateCasIterator.processUntilNextOutputCas(ASB_impl.java:567)
at
org.apache.uima.analysis_engine.asb.impl.ASB_impl$AggregateCasIterator.<init>(ASB_impl.java:409)
at
org.apache.uima.analysis_engine.asb.impl.ASB_impl.process(ASB_impl.java:342)
at
org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.processAndOutputNewCASes(AggregateAnalysisEngine_impl.java:267)
at
org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:267)
at
org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:280)
at com.whatever.getCode(Manager.java:217)
at com.whatever.analyzeText(Manager.java:122)
at com.whatever.analyzeCode(GenericResource.java:56)
at sun.reflect.GeneratedMethodAccessor220.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:125)
at
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
at
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:91)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:346)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:341)
at
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:101)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:224)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:198)
at
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:946)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:323)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:372)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:335)
at
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:208)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:274)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at
org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at
org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at
org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at
org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at
org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at
org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at
org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at
org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at
org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at
org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at
org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at
org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:766)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5241)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5163)
at
org.apache.ctakes.dictionary.lookup2.concept.JdbcConceptFactory.getStringCodesWithDesc(JdbcConceptFactory.java:409)
at
org.apache.ctakes.dictionary.lookup2.concept.JdbcConceptFactory.createConcept(JdbcConceptFactory.java:294)
at
org.apache.ctakes.dictionary.lookup2.concept.AbstractConceptFactory.createConcepts(AbstractConceptFactory.java:37)
at
org.apache.ctakes.dictionary.lookup2.concept.UmlsJdbcConceptFactory.createConcepts(UmlsJdbcConceptFactory.java:55)
at
org.apache.ctakes.dictionary.lookup2.ae.AbstractJCasTermAnnotator.process(AbstractJCasTermAnnotator.java:179)
at
org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
at
org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:375)
Mime
View raw message