If you look in the file ‘browser.config’ under the ‘src/home’ folder in the
‘home’ module, you’ll see the section
org.apache.river.examples.browser {
serverExporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
new BasicILFactory());
serviceInvocationConstraints=InvocationConstraints.EMPTY;
proxyPermissions = new Permission[] {
new RuntimePermission("accessClassInPackage.com.sun.proxy"),
new java.lang.reflect.ReflectPermission("newProxyInPackage.*")
};
servicePreparer =
new BasicProxyPreparer(false, new
BasicMethodConstraints(serviceInvocationConstraints),
proxyPermissions );
leasePreparer =
new BasicProxyPreparer(false, new
BasicMethodConstraints(serviceInvocationConstraints),
proxyPermissions );
}
The ‘proxyPermissions’ field defines the permissions that will be granted to
any dynamically-loaded proxies after proxy verification. For instance, the
proxy that’s retrieved from Reggie. Notice that one of the permissions is
‘accessClassInPackage.com.sun.proxy’. Which is the permission that’s missing
in the exception you posted below (sorry about the format - retrieved it from
the digest).
When the browser loads up, it gets a number of configuration entries, based on
the component identifier. To retrieve the entries from ‘browser.config’, the
component identifier should be ‘org.apache.river.examples.browser’ (notice the
component id on the configuration block.
However, if you take a look at ‘Browser.java’, line 144, you’ll see
static final String BROWSER = Browser.class.getPackage().getName();
…so it’s taking its component id from the package name of the ‘Browser’ class.
Is that one of the packages you changed? I suspect that because it’s now
looking for the configuration entries under a different component id, it’s not
finding them in ‘browser.config’, so it’s defaulting to an empty permissions
set.
Which means… change the component id in your ‘browser.config’ to match your new
package name, and you should be OK.
Hope this helps,
Greg Trasuk
> Hello, I am evaluating JINI for use in a personal project. The apache example
> builds and works perfectly, but when I use it as a point of departure for my
> own project, I am getting an AccessControlException when using the Browser.
> (Text below.) Perhaps a push in the right direction will help me to
> understand the issue. I started with the example project and changed the
> package from org.apache.river.examples.browser.Browser to
> com.myproject.river. . . . I changed all references in the config files to
> the new package name. Also modified the POM. Everything looks like it should
> work. The browser builds and runs, but when I select the registrar from the
> pulldown (which became visible when I started the infrastructure services),
> the application crashes and gives AccessControlException (below). It is able
> to see the infrastructure service, but when I select it, the exception is
> thrown. When I inspect the manifest of my Browser jar file, it is identical
> except that the entry class is different, as intended. Again, all I did was
> change the package name, the maven build, and the references to it in the
> .config files. Any help appreciated. I am very interested in JINI for its
> multicast discovery which will simplify configuration of my application for
> end users who may not be tech savvy. C:\Users\Chris\workspace\my-browser>java
> -Djava.security.manager -Djava.security.policy=server.policy
> -Djava.rmi.server.useCodebaseOnly=false -jar lib/start.jar
> start-browser.config Jun 01, 2016 7:00:06 PM
> com.myproject.river.examples.browser.Browser failure INFO: call to lookup
> service failed java.security.AccessControlException: access denied
> ("java.lang.RuntimePermissio n" "accessClassInPackage.com.sun.proxy") at
> java.security.AccessControlContext.checkPermission(Unknown Source) at
> java.security.AccessController.checkPermission(Unknown Source) at
> java.lang.SecurityManager.checkPermission(Unknown Source) at
> java.lang.SecurityManager.checkPackageAccess(Unknown Source) at
> sun.reflect.misc.ReflectUtil.checkPackageAccess(Unknown Source) at
> sun.reflect.misc.ReflectUtil.checkPackageAccess(Unknown Source) at
> java.io.ObjectOutputStream.writeProxyDesc(Unknown Source) at
> java.io.ObjectOutputStream.writeClassDesc(Unknown Source) at
> java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source) at
> java.io.ObjectOutputStream.writeObject0(Unknown Source) at
> java.io.ObjectOutputStream.writeObject(Unknown Source) at
> com.sun.jini.jeri.internal.runtime.Util.marshalValue(Util.java:176) at
> net.jini.jeri.BasicInvocationHandler.marshalArguments(BasicInvocation
> Handler.java:1182) at
> net.jini.jeri.BasicInvocationHandler.invokeRemoteMethodOnce(BasicInvo
> cationHandler.java:778) at
> net.jini.jeri.BasicInvocationHandler.invokeRemoteMethod(BasicInvocati
> onHandler.java:659) at
> net.jini.jeri.BasicInvocationHandler.invoke(BasicInvocationHandler.ja va:528)
> at com.sun.jini.reggie.$Proxy6.notify(Unknown Source) at
> com.sun.jini.reggie.RegistrarProxy.notify(RegistrarProxy.java:139) at
> com.myproject.river.examples.browser.Browser.update(Browser.java:1301) ...