uimafit in a servlet

41 views
Skip to first unread message

Lee Becker

unread,
Aug 26, 2013, 2:38:07 AM8/26/13
to uimafi...@googlegroups.com
I am trying to run some analysis engines in a servlet (specifically a Google App Engine servlet), and I've noticed that during a call to AnalysisEngineFactory.createPrimitiveDescription() I hit some file permission exceptions (for details see stack trace below).  It seems that during creation of the type system (TypeSystemDescriptionFactory.createTypeSystemDescription()), there is code trying to read/access a directory it doesn't have access to.  Is there some way that I can modify some property so that it can get the info it needs within the confines of a the Servlet sandbox?  Alternatively is there some other way to initialize the typesystem?

Also, I'm not sure if it changes things, but at the moment I am just using the type system defined by cleartk-typesystem.  Could some of this be circumvented if I had my own typesystem file that included the ClearTK ones?

Thanks in advance for the info,
Lee


HTTP ERROR 500

Problem accessing /preprocess. Reason:

    access denied ("java.io.FilePermission" "/Users/leebecker/Documents/workspace/langid" "read")

Caused by:

java.security.AccessControlException: access denied ("java.io.FilePermission" "/Users/leebecker/Documents/workspace/langid" "read")
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
	at java.security.AccessController.checkPermission(AccessController.java:559)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
	at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:289)
	at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
	at java.io.File.isDirectory(File.java:797)
	at java.io.File.toURL(File.java:654)
	at org.apache.uima.resource.impl.RelativePathResolver_impl.setDataPath(RelativePathResolver_impl.java:105)
	at org.apache.uima.resource.impl.RelativePathResolver_impl.<init>(RelativePathResolver_impl.java:78)
	at org.apache.uima.resource.impl.RelativePathResolver_impl.<init>(RelativePathResolver_impl.java:50)
	at org.apache.uima.resource.impl.ResourceManager_impl.<init>(ResourceManager_impl.java:119)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:127)
	at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:148)
	at org.apache.uima.impl.UIMAFramework_impl._newDefaultResourceManager(UIMAFramework_impl.java:332)
	at org.apache.uima.UIMAFramework.newDefaultResourceManager(UIMAFramework.java:992)
	at org.apache.uima.util.CasCreationUtils.mergeTypeSystems(CasCreationUtils.java:999)
	at org.uimafit.factory.TypeSystemDescriptionFactory.createTypeSystemDescription(TypeSystemDescriptionFactory.java:163)
	at com.hapara.analytics.nlp.PreprocessServlet.init(PreprocessServlet.java:35)
	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
	at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
	at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:409)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Richard Eckart de Castilho

unread,
Aug 26, 2013, 2:49:10 AM8/26/13
to uimafi...@googlegroups.com
Hi Lee,

you can use one of the TypeSystemDescriptionFactory.createTypeSystemDescription() that take an argument to explicitly specify which file/location to read the type system from. Then you'll have to pass this tsd to all the factory calls as back in the uutuc days. That may not help you though.

It doesn't seem to the uimaFIT that accesses the file system, but rather the UIMA RelativePathResolver. It includes the System property "user.dir" per default in its resolving process. Can you set "user.dir" to null in your setup?

See: org.apache.uima.resource.impl.RelativePathResolver_impl.<init>(RelativePathResolver_impl.java:78)

Cheers,

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

Lee Becker

unread,
Aug 26, 2013, 5:22:29 AM8/26/13
to uimafi...@googlegroups.com

On Mon, Aug 26, 2013 at 6:49 PM, Richard Eckart de Castilho <richard...@gmail.com> wrote:
It doesn't seem to the uimaFIT that accesses the file system, but rather the UIMA RelativePathResolver. It includes the System property "user.dir" per default in its resolving process. Can you set "user.dir" to null in your setup?

See: org.apache.uima.resource.impl.RelativePathResolver_impl.<init>(RelativePathResolver_impl.java:78)

Hi Richard,

Thanks for the prompt response.  I'm not sure how to set this property in my launch file.  It currently looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2e.Maven2LaunchConfigurationType">
<booleanAttribute key="M2_DEBUG_OUTPUT" value="false"/>
<stringAttribute key="M2_GOALS" value="appengine:devserver"/>
<booleanAttribute key="M2_NON_RECURSIVE" value="false"/>
<booleanAttribute key="M2_OFFLINE" value="false"/>
<stringAttribute key="M2_PROFILES" value=""/>
<listAttribute key="M2_PROPERTIES"/>
<stringAttribute key="M2_RUNTIME" value="EMBEDDED"/>
<booleanAttribute key="M2_SKIP_TESTS" value="false"/>
<intAttribute key="M2_THREADS" value="1"/>
<booleanAttribute key="M2_UPDATE_SNAPSHOTS" value="false"/>
<booleanAttribute key="M2_WORKSPACE_RESOLUTION" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${project_loc}"/>
</launchConfiguration>


However, when I manually set user.dir like this:
System.setProperty("user.dir", "");

I get complaints about java.rmi.server.UID.  I'm worried that UIMA may be using classes I don't have access to.

HTTP ERROR 500

Problem accessing /preprocess. Reason:

    java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.

Caused by:

java.lang.NoClassDefFoundError: java.rmi.server.UID is a restricted class. Please see the Google  App Engine developer's guide for more details.
	at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
	at org.apache.uima.impl.UimaContext_ImplBase.<init>(UimaContext_ImplBase.java:129)
	at org.apache.uima.impl.RootUimaContext_impl.<init>(RootUimaContext_impl.java:41)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance_(Runtime.java:127)
	at com.google.appengine.tools.development.agent.runtime.Runtime.newInstance(Runtime.java:148)
	at org.apache.uima.impl.UIMAFramework_impl._newUimaContext(UIMAFramework_impl.java:383)
	at org.apache.uima.UIMAFramework.newUimaContext(UIMAFramework.java:1031)
	at org.apache.uima.resource.Resource_ImplBase.initialize(Resource_ImplBase.java:107)
	at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.initialize(AnalysisEngineImplBase.java:157)
	at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.initialize(AggregateAnalysisEngine_impl.java:127)
	at org.uimafit.factory.AnalysisEngineFactory.createAggregate(AnalysisEngineFactory.java:505)
	at org.uimafit.factory.AggregateBuilder.createAggregate(AggregateBuilder.java:200)
	at com.hapara.analytics.nlp.PreprocessServlet.init(PreprocessServlet.java:56)
	at javax.servlet.GenericServlet.init(GenericServlet.java:212)
	at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:440)
	at org.mortbay.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:339)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:61)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at com.google.appengine.tools.development.BackendServersFilter.doFilter(BackendServersFilter.java:97)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
	at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:94)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:409)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:326)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Richard Eckart de Castilho

unread,
Aug 26, 2013, 6:00:15 AM8/26/13
to uimafi...@googlegroups.com
I think it may be best to move this discussion to the UIMA users or possible even to the developers list.

The line that seems to be causing problems now is this:

uniqueIdentifier = new UID().toString();

UID is in the java.rmi.server package which you apparently do not have access to. You could raise a feature
request to make the developers aware of the problem and ask for removing unnecessary references to that
package. After all, afaik UIMA doesn't really do RMI.

Without wanting to make advertisements, you might get better results on alternative platforms, e.g. Heroku.
Although, it would be interesting to follow through with the use-case and fix UIMA to work on the App Engine.

Cheers,

-- Richard

Lee Becker

unread,
Aug 26, 2013, 6:06:55 AM8/26/13
to uimafi...@googlegroups.com
On Mon, Aug 26, 2013 at 10:00 PM, Richard Eckart de Castilho <richard...@gmail.com> wrote:
I think it may be best to move this discussion to the UIMA users or possible even to the developers list.

The line that seems to be causing problems now is this:

  uniqueIdentifier = new UID().toString();

UID is in the java.rmi.server package which you apparently do not have access to. You could raise a feature
request to make the developers aware of the problem and ask for removing unnecessary references to that
package. After all, afaik UIMA doesn't really do RMI.


Yeah, it seems that they were just using this package as a convenient way to generate a UUID.  I will post something on the UIMA users forum.
 
Without wanting to make advertisements, you might get better results on alternative platforms, e.g. Heroku.
Although, it would be interesting to follow through with the use-case and fix UIMA to work on the App Engine.

While it might be better for this use case to switch to Heroku, my company is very much tied to the App Engine infrastructure.

Thanks for your help,
Lee
Reply all
Reply to author
Forward
0 new messages