Skip to content

Missconfiguration Issue

UltimaPhoenix edited this page Jul 5, 2015 · 1 revision

Restricted class in Google App Engine

Lucene accesses to some classes that are restricted in Google App Engine. LAE includes a modified class that should solve this problem, by the way in some scenarious you may still have this problem. Don't be afraid, you can manually fix it.

Cause

Your application throws this error:

java.lang.NoClassDefFoundError: sun.misc.Unsafe is a restricted class. Please see the Google App Engine developer's guide for more details.
	at com.google.appengine.runtime.Request.process-d666b3e9e6f6979d(Request.java)
	at sun.misc.Unsafe.<clinit>(Unsafe.java)
	at java.lang.reflect.Method.invoke(Method.java:43)
	at org.apache.lucene.util.RamUsageEstimator.<clinit>(RamUsageEstimator.java:171)
	at org.apache.lucene.index.BufferedDeletes.<clinit>(BufferedDeletes.java:50)
	at org.apache.lucene.index.DocumentsWriter.<init>(DocumentsWriter.java:137)
	at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1161)
	at com.googlecode.lucene.IndexServlet.doPost(IndexServlet.java:66)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
	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 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.headerComplete(HttpConnection.java:923)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:449)
	at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:455)
	at com.google.tracing.TraceContext.runInContext(TraceContext.java:695)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:333)
	at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:325)
	at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:453)
	at java.lang.Thread.run(Thread.java:679)

Solution

Add into your appengine-web.xml:

<appengine-web-app>
....
    <class-loader-config>
        <priority-specifier filename="luceneappengine-[LAE Version].jar"/>
    </class-loader-config>
....
</appengine-web-app>

WARNING: If you are using a SNAPSHOT version using Maven you must add the specific jar name, you can see the specific jar name typing on command line 'mvn clean package && ls -lR target/ | grep luceneappengine'

Deprecated Solution

Copy the modified RamUsageEstimator into your app engine project in a redefined package named org.apache.lucene.util