2

I am trying to integrate struts2 with the google appengine. I am following the steps from the codeproject link here

The code compiles fine but when I access the localhost:8888 it throws the following FileAccessException

WARNING: /
java.security.AccessControlException: access denied ("java.io.FilePermission" "jar:file:\E:\AppEngineSampleProject\war\WEB-INF\lib\struts2-core-2.3.14.2.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:383)
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:153)
at java.util.jar.JarFile.<init>(JarFile.java:90)
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:942)
at org.apache.struts2.dispatcher.ng.PrepareOperations.createActionContext(PrepareOperations.java:77)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:78)
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)

My struts.xml file is

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.action.excludePattern" value="/_ah/.*"/>
    <constant name="struts.devMode" value="false" />
    <constant name="struts.configuration.xml.reoload" value="false"></constant>
    <package
      name="default"
      extends="struts-default">
        <default-action-ref name="index"/>
        <action name="index" class="org.hanbo.sample.HelloWorld">
                <result name="success">/jsp/HelloWorld.jsp</result>    
            </action>
        </package>
    </struts>

And my web.xml file is

<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

    <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.hanbo.sample.GaePrepareAndExecuteFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <listener>
        <listener-class>com.struts2.gae.listener.OgnlListener</listener-class>
    </listener>
    <welcome-file-list>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>

</web-app>

I have already tried to put

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

but the exception is still there. Please help.

t0mkaka
  • 1,843
  • 2
  • 17
  • 21
  • not sure about Google app but have you [read](https://developers.google.com/appengine/kb/java?csw=1#readfile) – Umesh Awasthi Sep 04 '13 at 10:51
  • @UmeshAwasthi Yeah I have read that. The exception is for a jar file which will always be in war/WEB-INF/lib folder. It doesn't specifically says that but I have tried copying it elsewhere and the error persists. – t0mkaka Sep 04 '13 at 11:03
  • is it only application deployed there or do you have any other application there? your log show that `DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:383)` is trying to find about permission and its getting failed so i only suspect it to be some permission issue. – Umesh Awasthi Sep 04 '13 at 11:09
  • I didn't get u. There is one more blank appengine application in the workspace. But other than that there is not. – t0mkaka Sep 04 '13 at 11:14
  • Did you find a solution to this problem? – Alex Bitek Nov 19 '13 at 20:07
  • No, I actually forgot about it in the mess of things. I will check again. – t0mkaka Nov 20 '13 at 06:00
  • @t0mkaka See http://stackoverflow.com/a/20458635/313113 – Alex Bitek Dec 29 '13 at 11:05

3 Answers3

0

As a first step YOU COULD TRY this:

BUT BE AWARE ITS VERY UNSAFE AND JUST TO SEE IF IT IS THE REASON FOR YOUR CURRENT PROBLEM! MAY EVEN JUST TRY IT WHILE BEEING OFFLINE AND IMEDIATLY REMOVE IT AFTER THE TEST!

go to where your JRE is installed = {JRE_HOME} then go to this subfolder:

/lib/security/java.policy (e.g. {JRE_HOME}/lib/security/java.policy)

Inside this file add: grant { permission java.security.AllPermission; };

This will allow any programm executed with your JVM to do basicially ANYTHING!

So if it should work you know it has something to do with your java-permissions that you have to read about and configure according to your needs.

IN ANY CASE YOUR NEEDS WILL NEVER BE TO GRANT ABOVE GENERAL PERMISSION SO MAKE SURE TO NOT LEAVE THE ABOVE ENTRY IN YOUR java.policy FILES AFTER A QUICK CHECK IF ITS THAT!

JBA
  • 2,769
  • 5
  • 24
  • 40
  • How can you do that on the Google AppEngine? You don't have access to JVM there and it's a Cloud ;-) – Lukasz Lenart Sep 05 '13 at 07:26
  • Oh i am realy sorry i kind off overread this part of your question :( Unfortunately i dont know the google AppEngine and a quick web search indicates youre storing your files in a legitime folder to access them (https://developers.google.com/appengine/kb/java?hl=de#readfile). Sorry i couldnt help you :( – JBA Sep 05 '13 at 07:32
  • I will try to dig in over the weekend or delete this answer, try to set the other prop like this as well: struts.configuration.xml.reload=false (you already have this) struts.devMode = false (you already have this) struts.i18n.reload=false – JBA Sep 05 '13 at 07:41
0

I think the best option here is to implement your own version of FileManager and override messing methods, i.e. fileNeedsReloading() should always return false.

Check the docs:
http://struts.apache.org/release/2.3.x/docs/webxml.html
http://struts.apache.org/release/2.3.x/docs/plugins.html

Alex Bitek
  • 6,529
  • 5
  • 47
  • 77
Lukasz Lenart
  • 987
  • 7
  • 14
0

As suggested by @Lukasz Lenart the way to get arround the

WARNING: / java.security.AccessControlException: access denied ("java.io.FilePermission" "jar:file:\E:\AppEngineSampleProject\war\WEB-INF\lib\struts2-core-2.3.14.2.jar" "read")

is to create a custom plugin that overrides the default FileManager and FileManagerFactory implementations.

For how to do that see my answer to the question

Community
  • 1
  • 1
Alex Bitek
  • 6,529
  • 5
  • 47
  • 77