Google app engine 在Appengine上使用org.apache.lucene时出现问题

Google app engine 在Appengine上使用org.apache.lucene时出现问题,google-app-engine,lucene,guice,google-cloud-endpoints,Google App Engine,Lucene,Guice,Google Cloud Endpoints,嗨,在我的上一个项目中,我使用lucene分析器在appengine上生成关键字。现在我想在我的新项目中再次使用它,但它似乎受到GAE的限制。我试图将版本设置回我在上一个项目中使用的版本,但它不再起作用。我得到以下错误: java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google App Engine develop

嗨,在我的上一个项目中,我使用lucene分析器在appengine上生成关键字。现在我想在我的新项目中再次使用它,但它似乎受到GAE的限制。我试图将版本设置回我在上一个项目中使用的版本,但它不再起作用。我得到以下错误:

    java.lang.NoClassDefFoundError: java.lang.management.ManagementFactory is a restricted class. Please see the Google  App Engine developer's guide for more details.
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.reject(Runtime.java:51)
[INFO]  at org.apache.lucene.util.RamUsageEstimator.<clinit>(RamUsageEstimator.java:223)
[INFO]  at org.apache.lucene.util.ArrayUtil.<clinit>(ArrayUtil.java:32)
[INFO]  at java.lang.Class.forName0(Native Method)
[INFO]  at java.lang.Class.forName(Class.java:190)
[INFO]  at com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
[INFO]  at com.google.appengine.tools.development.agent.runtime.Runtime.checkRestricted(Runtime.java:64)
[INFO]  at org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl.<init>(CharTermAttributeImpl.java:33)
[INFO]  at org.apache.lucene.analysis.tokenattributes.PackedTokenAttributeImpl.<init>(PackedTokenAttributeImpl.java:40)
[INFO]  at org.apache.lucene.util.AttributeFactory$1.createInstance(AttributeFactory.java:140)
[INFO]  at org.apache.lucene.util.AttributeFactory$StaticImplementationAttributeFactory.createAttributeInstance(AttributeFactory.java:103)
[INFO]  at org.apache.lucene.util.AttributeSource.addAttribute(AttributeSource.java:222)
[INFO]  at org.apache.lucene.analysis.standard.StandardTokenizer.<init>(StandardTokenizer.java:182)
[INFO]  at org.apache.lucene.analysis.de.GermanAnalyzer.createComponents(GermanAnalyzer.java:194)
[INFO]  at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:144)
java.lang.NoClassDefFoundError:java.lang.management.ManagementFactory是一个受限类。有关更多详细信息,请参阅谷歌应用程序引擎开发者指南。
[信息]位于com.google.appengine.tools.development.agent.runtime.runtime.reject(runtime.java:51)
[信息]位于org.apache.lucene.util.RamUsageEstimator.(RamUsageEstimator.java:223)
[信息]位于org.apache.lucene.util.ArrayUtil.(ArrayUtil.java:32)
[信息]位于java.lang.Class.forName0(本机方法)
[信息]位于java.lang.Class.forName(Class.java:190)
[信息]位于com.google.appengine.tools.development.agent.runtime.RuntimeHelper.checkRestricted(RuntimeHelper.java:70)
[信息]位于com.google.appengine.tools.development.agent.runtime.runtime.checkRestricted(runtime.java:64)
[信息]位于org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl.(CharTermAttributeImpl.java:33)
[信息]位于org.apache.lucene.analysis.tokenattributes.packedtokenattributempl.(packedtokenattributempl.java:40)
[信息]位于org.apache.lucene.util.AttributeFactory$1.createInstance(AttributeFactory.java:140)
[信息]位于org.apache.lucene.util.AttributeFactory$StaticImplementationAttributeFactory.createAttributeInstance(AttributeFactory.java:103)
[信息]位于org.apache.lucene.util.AttributeSource.addAttribute(AttributeSource.java:222)
[信息]位于org.apache.lucene.analysis.standard.StandardTokenizer.(StandardTokenizer.java:182)
[信息]位于org.apache.lucene.analysis.de.GermanAnalyzer.createComponents(GermanAnalyzer.java:194)
[信息]位于org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:144)

有人知道我为什么会出现这个错误吗?

之所以会出现这个错误,是因为Lucene的
RamUsageEstimator
试图访问
ManagementFactory
类来确定VM的对象对齐方式
java.lang.management.ManagementFactory
限制在GAE上(可能是出于安全原因),并引发
NoClassDefFoundError

如果您查看and(提供目录实现的项目,允许您在Google App Engine上使用Lucene),您可以看到它们提供了一个替代的
RamUsageEstimator
,其中它们捕获了该异常:

我想如果你想在GEE上使用Lucene分析器,你应该考虑使用其中的一个“Lucene GAE”项目。 我不知道为什么在你以前的项目中它对你有效。也许你使用了一个lucene GAE项目,却忘了将其包含在新项目中