使用 SAX 解析器进行 XSD 验证时出现 java.security.AccessControlException
我在我的 Google App Engine Web 应用程序中编写了一个 SAX 解析器。因为我尝试使用 xsd 验证我的 xml 文件。但是当我的代码试图访问该 xsd 时,我遇到了访问控制异常。
<代码> java.security.AccessControlException:访问被拒绝(java.io.FilePermission \WEB-INF\ApplicationResponse.xsd 读取) 在 java.security.AccessControlContext.checkPermission(AccessControlContext.java:264) 在 java.security.AccessController.checkPermission(AccessController.java:427) 在 java.lang.SecurityManager.checkPermission(SecurityManager.java:532) 在 com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166) 在 java.lang.SecurityManager.checkRead(SecurityManager.java:871) 在 java.io.FileInputStream.(FileInputStream.java:100) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.xsdToXMLInputSource(XMLSchemaLoader.java:830) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:708) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:554) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2459) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1807) 在 com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705) 在 com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330) 在 com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779) 在 com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794) 在com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) 在 com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) 在 com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) 在com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242) 在 sax.SAXLocalNameCount.parse(SAXLocalNameCount.java:220) 在 com.sms2mint.InterfaceServlet.doGet(InterfaceServlet.java:54)
请让我知道如何调试这个? 我尝试将 xsd 放在类、webcontent、/WEB-INF 中,但没有帮助。还在 appengine-web.xml 中将其声明为资源文件,但无济于事。
I have written an SAX parser in my Google App Engine Web application. in that I try to validate my xml file with an xsd. But I am getting an access control exception when my code is tyring to access that xsd.
java.security.AccessControlException: access denied (java.io.FilePermission \WEB-INF\ApplicationResponse.xsd read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.FileInputStream.(FileInputStream.java:100)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.xsdToXMLInputSource(XMLSchemaLoader.java:830)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.processJAXPSchemaSource(XMLSchemaLoader.java:708)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:554)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2459)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1807)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:330)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:779)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1794)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at sax.SAXLocalNameCount.parse(SAXLocalNameCount.java:220)
at com.sms2mint.InterfaceServlet.doGet(InterfaceServlet.java:54)
Please let me know how to debug this?
I have tried to place the xsd in classes, webcontent, /WEB-INF but didn't help. Also declared this as a resource file in appengine-web.xml also but no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据:
http://code.google.com/appengine/docs/java /jrewhitelist.html
FileInputStream 应该是白名单读取器函数。您在开发环境中是否遇到此访问问题(在这种情况下,您的开发环境是什么?有报告称,使用 Eclipse 插件的人遇到类似问题,在重新启动 Eclipse、清理并重新构建项目后解决),或者在已部署的应用程序中?
您如何指定文件的路径?你可以包含代码吗?
According to:
http://code.google.com/appengine/docs/java/jrewhitelist.html
The FileInputStream should be a white-listed reader function. Are you having this access problem in the development environment (in which case what is your development environment? There have been reports of similar issues with people using the Eclipse plugin that resolved after restarting eclipse, cleaning, and re-building the project), or in a deployed application?
How are you specifying the path to your file? Can you include code?