How to map RMIRegistry bindings to the java:comp/env/services ctx?
807567Jul 22 2008 — edited Jul 23 2008First of all: greetings. I'm new here and i hope this is the right place to get some answers.
For about 8 years i have been using my own J2EE compliant web server/servlet container. for a few very large commercial web applications. A few days ago I tried out SJSWS 7 and liked what i saw. Instead of drastically rewrite my own server i rather use SJSWS if possible. After some initial testing things are looking good. I will probably have 2 areas of concern (one of which i already spent 2 days on :-( ):
1. The web apps do not use EJB but rather RMI remote objects (stateless services). The servlets obtain references to those services using JNDI and the servlet container supplies a naming context where they are mapped to things like: java:comp/env/services/UserInformationService etc. The web.xml looks like this:
<resource-env-ref>
<description>This is a reference to the UserInformationService.</description>
<resource-env-ref-name>services/UserInformationService</resource-env-ref-name>
<resource-env-ref-type>com.irritum.polic.userinfo.UserInformationService</resource-env-ref-type>
</resource-env-ref>
and the webserver config has stuff like this:
<JNDI>
<Provider id="POLIC">
<Property name="java.naming.factory.initial">com.sun.jndi.rmi.registry.RegistryContextFactory</Property>
<Property name="java.naming.provider.url">rmi://localhost:8502</Property>
<Property name="java.naming.rmi.security.manager">true</Property>
</Provider>
</JNDI>
....
<Naming>
<LinkRef source="java:comp/env/services/UserInformationService"
target="com.irritum.polic.userinfo.UserInformationService"
provider="POLIC"/>
</Naming>
The target is the name used to bind the remote object in the app server (which is an rmi registry too). Well, the question now is how do i get my web apps to work in SJSWS 7. I tried about every thing i could using external JNDI resources but i don't seem to be able to map the references.
2. This will be great fun too: My system uses JAAS for authentication etc: so it has in its config stuff like:
<LoginModules>
<LoginModule class="com.irritum.polic.userinfo.UserInfoModule" flag="REQUISITE">
<Option name="java.naming.provider.url">rmi://localhost:8502</Option>
<Option name="java.naming.factory.initial">com.sun.jndi.rmi.registry.RegistryContextFactory</Option>
<Option name="java.naming.rmi.security.manager">true</Option>
<Option name="debug">false</Option>
</LoginModule>
</LoginModules>
<RemoteUserPrincipal class="com.irritum.polic.userinfo.UserPrincipal"/>
<RoleMapping>
<Principal name="user" class="com.irritum.polic.userinfo.RolePrincipal">
<Role name="user"/>
</Principal>
<Principal name="admin" class="com.irritum.polic.userinfo.RolePrincipal">
<Role name="admin"/>
</Principal>
<Principal name="sysop" class="com.irritum.polic.userinfo.RolePrincipal">
<Role name="sysop"/>
</Principal>
</RoleMapping>
I have not yet found how and where to do that in SJSWS but i have not looked for it that hard. (the role mappings are to map the roles from the web.xml to Principal classes.
I hope i will be enlightened soon especially to get access to my services .
Thanks in advance,
Peter