Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] start jetty with policy has errors

1) Never use the AllPermission, it totally defeats the purpose of
using the security manager.
2) on that note, if you don't need the security manager, don't use it,
its a pita :)
3) getPolicy is the permission that allows a codebase to be able to
get the system Policy object.  You webapp should never need to get the
Policy object, but the jetty code will need to, specifically the
JettyPolicy object
4) I had a couple of different tmp dir options in place, you should
choose the one you want to work with.  If you create a work directory
in your jetty distribution directory then your webapp will be unpacked
there and you should use that location for the codebase.
5) the general rule of thumb to remember is that for a permission to
be granted every codebase represented in the stracktrace needs to have
been granted that permission


good luck!
jesse

--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx



On Tue, Aug 2, 2011 at 22:53, zhiwei chen <zhiweik@xxxxxxxxx> wrote:
> Thank you, jesse mcconnell.
> With your help, I start jetty now.
> But there are still something trouble me.
> What does this line mean(permission java.security.SecurityPermission
> "getPolicy";) in jetty.policy?
> When I use this line,.war files will unpacked to /tmp directory(if I changed
> this line to "permisson java.security.AllPermission",my app.war will be
> unpacked to ${jetty.home}/work directory.BWT, I mkdir ${jetty.home}/work).
>  My temp-dirs.policy has these lines:
> grant codeBase "file:${java.io.tmpdir}${/}" {
>    permission java.io.FilePermission "${jetty.home}${/}webapps${/}-", "read,
> write"; // Ought to go up a specific codebases
>    permission java.io.FilePermission "${java.io.tmpdir}${/}-", "read";
>    permission java.util.PropertyPermission
> "org.eclipse.jetty.util.log.class", "read";
>    permission java.util.PropertyPermission
> "org.eclipse.jetty.util.log.IGNORED", "read";
>    permission java.util.PropertyPermission
> "org.eclipse.jetty.util.log.stderr.DEBUG", "read";
> };
> But my app still can't read and write ${jetty.home}${/}webapps${/}hello.txt
>  file.
> And, If I unpacked app.war to /tmp, is jetty-work.policy still be used? When
> I modify jetty-work.policy,there are nothing happened.
>
> On Wed, Jul 27, 2011 at 8:46 PM, Jesse McConnell <jesse.mcconnell@xxxxxxxxx>
> wrote:
>>
>> looks like you have to grant some permissions
>>
>> see:
>> http://download.oracle.com/javase/6/docs/technotes/guides/security/PolicyFiles.html
>>
>> cheers,
>> jesse
>>
>> --
>> jesse mcconnell
>> jesse.mcconnell@xxxxxxxxx
>>
>>
>>
>> On Wed, Jul 27, 2011 at 04:41, zhiwei chen <zhiweik@xxxxxxxxx> wrote:
>> > hi,erveryone.
>> > I use jetty(jetty-distribution-7.4.3.v20110701.tar.gz),and open-jdk1.6
>> > under
>> > ubuntu.
>> > I modified ${jetty.home}/start.ini,the start.ini content is:
>> > OPTIONS=Server,jsp,jmx,resources,websocket,ext,policy
>> > etc/jetty.xml
>> > etc/jetty-policy.xml
>> > etc/jetty-deploy.xml
>> > etc/jetty-webapps.xml
>> > etc/jetty-contexts.xml
>> > etc/jetty-testrealm.xml
>> > other files of jetty use default files
>> > in jetty-distribution-7.4.3.v20110701.tar.gz
>> > but when I start jetty with ${jetty.home}/bin/jetty.sh start
>> > there are some messages in ${jetty.home}/logs/2011_07_27.stderrout.log:
>> > 2011-07-27 17:37:41.177:INFO::jetty-7.4.3.v20110701
>> > 2011-07-27 17:37:41.222:INFO::Deployment monitor
>> > /home/zhiwei/jetty-distribution-7.4.3.v20110701/webapps at interval 1
>> > 2011-07-27 17:37:41.260:INFO::Deployment monitor
>> > /home/zhiwei/jetty-distribution-7.4.3.v20110701/contexts at interval 1
>> > 2011-07-27 17:37:41.288:INFO::Deployable added:
>> > /home/zhiwei/jetty-distribution-7.4.3.v20110701/contexts/javadoc.xml
>> > 2011-07-27 17:37:41.324:INFO::started
>> >
>> > o.e.j.s.h.ContextHandler{/javadoc,file:/home/zhiwei/Downloads/jetty-distribution-7.4.3.v20110701/javadoc}
>> > 2011-07-27 17:37:41.324:INFO::Deployable added:
>> > /home/zhiwei/jetty-distribution-7.4.3.v20110701/contexts/test.xml
>> > 2011-07-27 17:37:41.483:INFO::Extract
>> >
>> > jar:file:/home/zhiwei/jetty-distribution-7.4.3.v20110701/webapps/test.war!/
>> > to /tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp
>> > 2011-07-27 17:37:41.793:WARN::Config error at <Call
>> > class="org.eclipse.jetty.util.log.Log" name="debug"><Arg>executing
>> > jetty-web.xml</Arg></Call> java.lang.reflect.InvocationTargetException
>> > 2011-07-27 17:37:41.794:WARN::Failed startup of context
>> >
>> > o.e.j.w.WebAppContext{/,file:/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/},/home/zhiwei/jetty-distribution-7.4.3.v20110701/webapps/test.war
>> > java.lang.reflect.InvocationTargetException
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.util.TypeUtil.call(TypeUtil.java:536)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:689)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:373)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:311)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:273)
>> > at
>> >
>> > org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:88)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:423)
>> > at
>> >
>> > org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1203)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:449)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
>> > at
>> > org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:482)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:137)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:50)
>> > at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:601)
>> > at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
>> > at org.eclipse.jetty.util.Scanner.scan(Scanner.java:394)
>> > at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:329)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:114)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:543)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:218)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:41)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:50)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
>> > at org.eclipse.jetty.server.Server.doStart(Server.java:258)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1197)
>> > at java.security.AccessController.doPrivileged(Native Method)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1120)
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.start.Main.invokeMain(Main.java:469)
>> > at org.eclipse.jetty.start.Main.start(Main.java:612)
>> > at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
>> > at org.eclipse.jetty.start.Main.main(Main.java:79)
>> > Caused by:
>> > java.lang.ExceptionInInitializerError
>> > at org.eclipse.jetty.util.log.Log.initStandardLogging(Log.java:103)
>> > at org.eclipse.jetty.util.log.Log.initialized(Log.java:85)
>> > at org.eclipse.jetty.util.log.Log.debug(Log.java:171)
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.util.TypeUtil.call(TypeUtil.java:536)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:689)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:373)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:311)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:273)
>> > at
>> >
>> > org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:88)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:423)
>> > at
>> >
>> > org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1203)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:449)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
>> > at
>> > org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:482)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:137)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:50)
>> > at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:601)
>> > at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
>> > at org.eclipse.jetty.util.Scanner.scan(Scanner.java:394)
>> > at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:329)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:114)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:543)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:218)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:41)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:50)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
>> > at org.eclipse.jetty.server.Server.doStart(Server.java:258)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1197)
>> > at java.security.AccessController.doPrivileged(Native Method)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1120)
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.start.Main.invokeMain(Main.java:469)
>> > at org.eclipse.jetty.start.Main.start(Main.java:612)
>> > at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
>> > at org.eclipse.jetty.start.Main.main(Main.java:79)
>> > Caused by:
>> > java.security.AccessControlException: access denied
>> > (java.util.PropertyPermission org.eclipse.jetty.util.log.DEBUG read)
>> > at
>> >
>> > java.security.AccessControlContext.checkPermission(AccessControlContext.java:393)
>> > at
>> > java.security.AccessController.checkPermission(AccessController.java:553)
>> > at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
>> > at
>> > java.lang.SecurityManager.checkPropertyAccess(SecurityManager.java:1302)
>> > at java.lang.System.getProperty(System.java:705)
>> > at org.eclipse.jetty.util.log.StdErrLog.<clinit>(StdErrLog.java:39)
>> > at org.eclipse.jetty.util.log.Log.initStandardLogging(Log.java:103)
>> > at org.eclipse.jetty.util.log.Log.initialized(Log.java:85)
>> > at org.eclipse.jetty.util.log.Log.debug(Log.java:171)
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.util.TypeUtil.call(TypeUtil.java:536)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.call(XmlConfiguration.java:689)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:373)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:311)
>> > at
>> >
>> > org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:273)
>> > at
>> >
>> > org.eclipse.jetty.webapp.JettyWebXmlConfiguration.configure(JettyWebXmlConfiguration.java:88)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:423)
>> > at
>> >
>> > org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1203)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:586)
>> > at
>> > org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:449)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
>> > at
>> > org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:482)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:135)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:137)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:50)
>> > at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:601)
>> > at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:531)
>> > at org.eclipse.jetty.util.Scanner.scan(Scanner.java:394)
>> > at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:329)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:114)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:543)
>> > at
>> >
>> > org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:218)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AggregateLifeCycle.doStart(AggregateLifeCycle.java:41)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:50)
>> > at
>> >
>> > org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90)
>> > at org.eclipse.jetty.server.Server.doStart(Server.java:258)
>> > at
>> >
>> > org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:58)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1197)
>> > at java.security.AccessController.doPrivileged(Native Method)
>> > at
>> > org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1120)
>> > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> > at
>> >
>> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>> > at
>> >
>> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> > at java.lang.reflect.Method.invoke(Method.java:616)
>> > at org.eclipse.jetty.start.Main.invokeMain(Main.java:469)
>> > at org.eclipse.jetty.start.Main.start(Main.java:612)
>> > at org.eclipse.jetty.start.Main.parseCommandLine(Main.java:265)
>> > at org.eclipse.jetty.start.Main.main(Main.java:79)
>> > 2011-07-27 17:37:41.836:INFO::Started
>> > SelectChannelConnector@0.0.0.0:8080
>> > STARTING
>> > and when I visit http://localhost:8080/ ,it display:
>> >
>> > HTTP ERROR: 503
>> >
>> > Problem accessing /. Reason:
>> >
>> >     Service Unavailable
>> >
>> > ________________________________
>> > Powered by Jetty://
>> > _______________________________________________
>> > jetty-users mailing list
>> > jetty-users@xxxxxxxxxxx
>> > https://dev.eclipse.org/mailman/listinfo/jetty-users
>> >
>> >
>> _______________________________________________
>> jetty-users mailing list
>> jetty-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>


Back to the top