gpt4 book ai didi

java - Struts + GAE java.security.AccessControlException : access denied of struts2-core-2. 3.15.3.jar

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:27:53 25 4
gpt4 key购买 nike

我在 GAE 中使用 struts。我正在使用 GAE 1.8 和 struts 2.3.15 jar 文件。

在我的申请中我遇到了这个异常

java.security.AccessControlException: access denied ("java.io.FilePermission" "jar:file:\E:\eclipse\Shaun\Convergent\war\WEB-INF\lib\struts2-core-2.3.15.3.jar" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:431)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.util.zip.ZipFile.<init>(ZipFile.java:205)
at java.util.zip.ZipFile.<init>(ZipFile.java:144)
at java.util.jar.JarFile.<init>(JarFile.java:152)
at java.util.jar.JarFile.<init>(JarFile.java:89)
at com.opensymphony.xwork2.util.fs.JarEntryRevision.needsReloading(JarEntryRevision.java:76)
at com.opensymphony.xwork2.util.fs.DefaultFileManager.fileNeedsReloading(DefaultFileManager.java:66)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:394)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:169)
at com.opensymphony.xwork2.config.ConfigurationManager.needReloadContainerProviders(ConfigurationManager.java:215)
at com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:179)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:73)
at org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:968)
at org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext(PrepareOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:86)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.convergent.auth.AuthorizationFilter.doFilter(AuthorizationFilter.java:32)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.convergent.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:48)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
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:63)
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.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:368)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:351)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
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:97)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:485)
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.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
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)

我做了很多搜索,有人说从 sturts.xml 文件中删除这个属性值

<constant name="struts.devMode" value="true" />

有人说将值从 true 更改为 false。我做到了,但没有用。请给出解决方案。我还更改了 jar 文件并使用了 2.1.8 版本,但是在这个版本中我在服务器启动时遇到了异常

java.lang.NoSuchMethodError: com.opensymphony.xwork2.config.ConfigurationManager.addConfigurationProvider(Lcom/opensymphony/xwork2/config/ConfigurationProvider;)V
at org.apache.struts2.dispatcher.Dispatcher.init_DefaultProperties(Dispatcher.java:310)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:411)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.listener.StrutsListener.contextInitialized(StrutsListener.java:45)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:467)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
at org.mortbay.jetty.Server.doStart(Server.java:224)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:249)
at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:306)
at com.google.appengine.tools.development.AutomaticInstanceHolder.startUp(AutomaticInstanceHolder.java:26)
at com.google.appengine.tools.development.AbstractModule.startup(AbstractModule.java:79)
at com.google.appengine.tools.development.Modules.startup(Modules.java:88)
at com.google.appengine.tools.development.DevAppServerImpl.doStart(DevAppServerImpl.java:254)
at com.google.appengine.tools.development.DevAppServerImpl.access$000(DevAppServerImpl.java:47)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:212)
at com.google.appengine.tools.development.DevAppServerImpl$1.run(DevAppServerImpl.java:210)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:210)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:277)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:48)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:219)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:210)

我还在使用以下带有 struts jar 文件的 jar 文件

ognl-3.0.6.jar
sitemesh-2.4.2.jar
struts2-sitemesh-plugin-2.2.3.1.jar
xwork-core-2.3.15.3.jar

请指导我。

最佳答案

根据我的调查

java.security.AccessControlException: access denied ("java.io.FilePermission" "jar:file:\E:\eclipse\Shaun\Convergent\war\WEB-INF\lib\struts2-core-2.3.15.3.jar" "read")

异常发生在尝试在 Google App Engine for Windows 上运行 Struts 2 应用程序时。

我在尝试将应用程序移植到 GAE 时在 Windows 上遇到了同样的问题,但我无法在 GNU/Linux 下重现它,也无法在使用 appcfg.sh --oauth2 update dist/myapp

为了在适用于 Windows 的 Google App Engine 下运行时解决这个问题我找到的唯一可行的解​​决方案是实现 custom plugin / extension point实现以下接口(interface) com.opensymphony.xwork2.FileManagercom.opensymphony.xwork2.FileManagerFactory

在插件中实现上述接口(interface)的类会覆盖 Struts 2 默认实例化的实现,即 DefaultFileManagerDefaultFileManagerFactory

custom file plugin我创建了三个主要组件:

  1. struts-plugin.xml文件指定插件中的 FileManager 和 FileManagerFactory 实现应作为默认实现
  2. Struts2FileManagerFactoryOnGAE , FileManagerFactory 接口(interface)的自定义实现,其中 DefaultFileManagerFactory 实现的唯一变化是类名
  3. Struts2FileManagerOnGAE ,自定义 FileManager 实现,我在其中进行了必要的更改,即 fileNeedsReloading() 方法和内部应返回 false,而 support() 方法应返回 true。

另外,在 WEB-INF/web.xml 里面我添加的应用程序: <init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
</init-param>

因为我使用 Ant 作为构建系统,所以我为自定义文件插件创建了新目标,编译并复制插件的 jar 到最终工件:https://gitlab.com/alibitek-java/Struts-GAE/blob/master/build.xml

您可以在以下位置查看我的测试应用程序的源代码:https://gitlab.com/alibitek-java/Struts-GAE/tree/master

如果你想尝试一下,你可以运行:

ant dev_appserver

在 build.xml 中设置您的 Google App Engine SDK 的路径后或者你可以在这里看到它 http://struts-gae.appspot.com/jsp/index.jsp

应用程序的作用是:您需要猜测生成的随机数,尝试几次后它会显示提示,当您猜到数字时它会显示您猜了多少次

关于java - Struts + GAE java.security.AccessControlException : access denied of struts2-core-2. 3.15.3.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20331872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com