Re: Looking for simple servlet-to-javaspace example
Gregg Wonderly <[email protected]>
| Newsgroups | gmane.comp.java.sun.jini |
|---|---|
| Message-ID | <[email protected]> |
Logan, Patrick wrote:
> Thanks. That may come in handy sometime.
>
> At this point I specifically need to use a servlet running in Tomcat
> installed in Jboss.
Okay, as has been said here several different times, various J2EE appservers are
less than friendly about how they manage codebases and permissions, because they
are not tailored to allow "random" configurations to be deployed inside of them.
So, there are specific things that you will need to address. Using
AllPermission to allow further investigation is probably okay. But you'll need
to understand what the limits are and how you can work within those, if security
will be important to your deployment.
> Ignoring Jboss for now, if I found some information on Jini for Tomcat
> and/or the servlet specification generally, I should be able to
> translate that into Jboss terms if necessary.
One of the key businesses of Jini is the fact that the security manager must be
enabled. If you have this turned on in the JVM, and you can't control the
permission settings assigned to Jini classes/instances, you will be plagued with
errors that will frustrate you to no end.
> Along the lines of what permissions are needed for a specific servlet to
> basically lookup a javaspace and do writes and takes?
The exact permissions are "none" to do writes and takes unless you've configured
Outrigger's exporter's invocation layer factory with a permission. If you did
specify a permission for inbound calls, then a permission grant for each method
that you want to allow access to, is required. There are, of course other
permissions required to use Jini's remote invocation infrastructure. This
includes endpoint related "socket" permissions, property access permissions, and
other associated bits and pieces. Last week, on the list, there was discussion
about two different tools which allow you to "discover" what permissions are
being required in a running system for the legs of code executed.
> So this is somewhat of a step toward a "production" setup... Not wide
> open, still as simple as possible, and focused on the servlet itself
> rather than the entire tomcat installation.
The other problematic situation is the annotations on exported objects. What
I've found to work the best for me in these kinds of situations is to create a
PreferredClassLoader that points at the URLs your service can be loaded from,
and the annotation to return for that service.
In your servlets initialization, you would create the PreferredClassLoader, and
then create an instance of your service from that classLoader with
PreferredClassLoader pcl = new PreferredClassLoader( urls,
getClass().getClassLoader(), annos, needDlPerm );
Class cls = Class.forName( svcClassName, true, pcl );
svc = cls.newInstance(...);
Gregg Wonderly
--------------------------------------------------------------------------
Getting Started: http://www.jini.org/wiki/Category:Getting_Started
Community Web Site: http://jini.org
jini-users Archive: http://archives.java.sun.com/archives/jini-users.html
Unsubscribing: email "signoff JINI-USERS" to [email protected]