geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <>
Subject Re: Custom LoginModule classloading issue in gernimo 2.0.2
Date Wed, 19 Dec 2007 00:15:09 GMT

On Dec 18, 2007, at 2:07 PM, Brian Dellert wrote:

> Thanks for the prompt response.
> Could you elaborate a bit on how to "Deploy this plan into your  
> geronimo server", or point me to some documentation which describes  
> how to package and deploy a "config module"?  I'm relatively new to  
> geronimo, and haven't deployed artifacts other than ear files, war  
> files, etc.  Thanks.

Yup, my response was a bit hard to follow ... even the plan I told  
you to modify is hard to find in 2.0.2 unless you build geronimo  
yourself.   I tried this out using a new moduleId of o.a.g.configs/ 
server-security-config2/2.0.2/car. Here's the plan with a few  
comments marked with "DAJ" about what to change:

<?xml version="1.0" encoding="UTF-8"?>
<!--Licensed to the Apache Software Foundation (ASF) under one or more
     contributor license agreements.  See the NOTICE file distributed  
     this work for additional information regarding copyright ownership.
     The ASF licenses this file to You under the Apache License,  
Version 2.0
     (the "License"); you may not use this file except in compliance  
     the License.  You may obtain a copy of the License at

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     See the License for the specific language governing permissions and
     limitations under the License.-->
<!--$Rev: 554977 $ $Date: 2007-07-10 08:32:56 -0700 (Tue, 10 Jul  
2007) $-->
<module xmlns="">
<!--DAJ Change the module ID to something related to your project -->
<!--DAJ include a dependency on your jar here; you'll need to put  
your jar somewhere in the geronimo repo so this will point to  
something that exists.  This would look just like what you tried in  
the geronimo-application.xml -->

<!--DAJ include your security realm gbean here -->

   <gbean name="CredentialStore"  
     <xml-attribute name="credentialStore">
       <credential-store xmlns=" 
         <!--uncomment this and the default subject in the jettty  
console plan gives you admin console permissions-->
         <!--<realm name="geronimo-admin">

<!--DAJ you may want to replace this with something related to your  
installation for non-toy admin console security -->
   <!--Default security realm using properties files-->
   <gbean name="properties-login"  
     <attribute name="options">usersURI=var/security/
     <attribute name="loginDomainName">geronimo-admin</attribute>
   <gbean name="geronimo-admin"  
     <attribute name="realmName">geronimo-admin</attribute>
     <reference name="LoginModuleConfiguration">
     <reference name="ServerInfo">
   <gbean name="properties-login"  
     <attribute name="controlFlag">REQUIRED</attribute>
     <reference name="LoginModule">
   <gbean name="geronimo-default"  
     <attribute name="keystoreName">geronimo-default</attribute>
     <attribute name="keystorePath">var/security/keystores/geronimo- 
     <attribute name="keystorePassword">secret</attribute>
     <attribute name="keyPasswords">geronimo=secret</attribute>
     <reference name="ServerInfo">

This will end up as a file named say mysecurity-plan.xml.

Deploy this using the console "deploy new" page, unchecking the  
"Start app after install" checkbox.

Stop geronimo.
Edit var/config/config.xml so you  have:
<module load="false" name="org.apache.geronimo.configs/server- 
<!-- replace this with the actual moduleId you used in the plan -->
<module name="org.apache.geronimo.configs/server-security- 

at the end.

Edit var/config/ to include lines

(again using the actual moduleId from your plan)

Now you should be able to start geronimo and it will use your  
security config instead of the supplied one.

You should be able to deploy the plan using the command line tool but  
I didn't try that.  Note that you can have only one of the original  
config and your replacement running at once since they have security  
realms with the same name (they are supposed to replace each other).

Hope this helps and please ask if there are more problems
david jencks

> - Brian
> ----- Original Message ----- From: "David Jencks"  
> <>
> To: <>
> Sent: Tuesday, December 18, 2007 4:38 PM
> Subject: Re: Custom LoginModule classloading issue in gernimo 2.0.2
>> My guess is that Aaron is right and this is an openejb bug.
>> The only way I can think to fix it is to replace the server- 
>> security- config module with one that is identical except also  
>> including the  jar containing your login module as a dependency  
>> and the security  realm configuration you want.  Deploy this plan  
>> into your geronimo  server. Also, while geronimo is stopped, add a  
>> line like
>> org.apache.geronimo.configs/server-security-config/2.0.2/ 
>> car=com.myco/ myserver-security-config/1.0/car
>> and another similar line without the 2.0.2 to var/config/  
>> (where com.myco/myserver-security- 
>> config/ 1.0/car is the moduleId of your replacement plan).  When  
>> you restart geronimo the realm should work.
>> I actually recommend doing this for any non-toy geronimo   
>> installation. The provided server-security-config is really an   
>> example that's easy to set up, but on a real installation you   
>> probably want access to the admin console controlled by your   
>> enterprise security system, not a couple of property files stuck  
>> in a  geronimo directory.
>> let us know how this works
>> david jencks
>> On Dec 18, 2007, at 12:46 PM, Aaron Mulder wrote:
>>> It's curious that, from the error, it appears to be looking for the
>>> security realm in the OpenEJB class loader (which I guess is  
>>> receiving
>>> the remote call) instead of the application's class loader.  Perhaps
>>> the context class loader should be set by e.g.
>>> EjbDaemon.processAuthRequest?
>>> Thanks,
>>>        Aaron
>>> On Dec 18, 2007 2:55 PM, Brian Dellert <> wrote:
>>>> Hi.
>>>> I have created a simple custom login module which uses the   
>>>> principal created
>>>> by the standard PropertiesFileLoginModule and adds a principal  
>>>> containing a
>>>> group (which is looked up in a DB).  I have configured a  
>>>> security  realm in
>>>> the geronimo-application.xml contained in my application ear  
>>>> file including
>>>> both of these login modules as follows:
>>>>     <gbean name="my-realm"
>>>> class=""
>>>>            xsi:type="dep:gbeanType"
>>>> xmlns:dep=""
>>>>            xmlns:xsi="">
>>>>         <attribute name="realmName">my-realm</attribute>
>>>>         <reference name="ServerInfo">
>>>>             <name>ServerInfo</name>
>>>>         </reference>
>>>>         <xml-reference name="LoginModuleConfiguration">
>>>>             <log:login-config
>>>> xmlns:log="">
>>>>                 <log:login-module control-flag="REQUISITE"
>>>> wrap-principals="false">
>>>>                     <log:login-domain-name>my-properties-file</
>>>> log:login-domain-name>
>>>>                     <log:login-module-  
>>>> class> 
>>>> gi nModule</log:login-module-class>
>>>>                     <log:option
>>>> name="usersURI">var/security/</log:option>
>>>>                     <log:option
>>>> name="groupsURI">var/security/</log:option>
>>>>                 </log:login-module>
>>>>                 <log:login-module control-flag="OPTIONAL"
>>>> wrap-principals="false">
>>>>                     <log:login-domain-name>my-sql-role</ 
>>>> log:login- domain-name>
>>>>                     <log:login-module-  
>>>> class></  
>>>> log:login-module-class>
>>>>                     <log:option name="roleSelect">SELECT username,
>>>> group_name FROM user_groups WHERE username=?</log:option>
>>>>                     <log:option
>>>> name="dataSourceApplication">null</log:option>
>>>>                     <log:option name="dataSourceName">MyPool</ 

>>>> log:option>
>>>>                 </log:login-module>
>>>>             </log:login-config>
>>>>         </xml-reference>
>>>>     </gbean>
>>>> Further, I have packaged the
>>>> "" class  
>>>> in  a jar file
>>>> (my-login-module-1.0.jar).  I have tried the following  
>>>> approaches  to get
>>>> this login module to load:
>>>>    - Added my-login-module-1.0.jar to the root of my ear file.
>>>>    - Added my-login-module-1.0.jar to the root of my ear file  
>>>> and  added this
>>>> jar file to the MANIFEST classpath of an ejb-jar file which is   
>>>> also in the
>>>> ear file.
>>>>    - Added my-login-module-1.0.jar to the geronimo repository by  
>>>> placing it
>>>> in the repository/my/company/my-login-module/1.0/my-login-  
>>>> module-1.0.jar
>>>>      and added the following dependency to the dependency list  
>>>> in the
>>>> environment section of my geronimo-application.xml file:
>>>>            <dependency>
>>>>                 <groupId></groupId>
>>>>                 <artifactId>my-login-module</artifactId>
>>>>                 <version>1.0</version>
>>>>                 <type>jar</type>
>>>>             </dependency>
>>>> I am attempting to connect/authenicate in a remote JVM by  
>>>> setting  up the
>>>> JNDI context and performing an EJB lookup as follows:
>>>>   Properties p = new Properties();
>>>>   p.put(Context.INITIAL_CONTEXT_FACTORY,
>>>>   "org.openejb.client.RemoteInitialContextFactory");
>>>>   p.put(Context.PROVIDER_URL, "ejbd://localhost:4201");
>>>>   p.put("openejb.authentication.realmName", "my-realm");
>>>>   p.put(Context.SECURITY_PRINCIPAL, "my_username");
>>>>   p.put(Context.SECURITY_CREDENTIALS, "my_password");
>>>>   InitialContext ctx = new InitialContext(p);
>>>>   Object obj = ctx.lookup("MyBusinessBeanRemote");
>>>> In all cases, I get the following error:
>>>> Caused by: unable to find
>>>> LoginModule class:  
>>>> in
>>>> classloader org.apache.geronimo.configs/openejb/2.0.2/car
>>>> [INFO]  at
>>>> 808)
>>>> [INFO]  at
>>>> (
>>>> [INFO]  at
>>>> [INFO]  at  
>>>> Method)
>>>> [INFO]  at
>>>> (
>>>> [INFO]  at
>>>> [INFO]  at
>>>> (
>>>> [INFO]  at
>>>> org.apache.geronimo.openejb.GeronimoSecurityService.login  
>>>> (
>>>> [INFO]  at
>>>> org.apache.openejb.server.ejbd.AuthRequestHandler.processRequest  
>>>> (
>>>> [INFO]  at
>>>> org.apache.openejb.server.ejbd.EjbDaemon.processAuthRequest  
>>>> (
>>>> [INFO]  at
>>>> org.apache.openejb.server.ejbd.EjbDaemon.service( 
>>>> 130)
>>>> [INFO]  at
>>>> org.apache.openejb.server.ejbd.EjbDaemon.service(
>>>> [INFO]  at
>>>> org.apache.openejb.server.ejbd.EjbServer.service(
>>>> [INFO]  at
>>>> org.apache.openejb.server.ServiceLogger.service 
>>>> ( 73)
>>>> [INFO]  at
>>>> org.apache.openejb.server.ServiceAccessController.service  
>>>> (
>>>> [INFO]  at
>>>> org.apache.openejb.server.ServiceDaemon$ 
>>>> 117)
>>>> [INFO]  at
>>>> I know that the dependency is getting at least recognized at ear  
>>>> deployment
>>>> time since, if I remove the login module jar file from the geronimo
>>>> repository, the deployment of the ear fails.
>>>> The only way I have been able to get the class to load is by   
>>>> placing it in
>>>> the lib/ext directory of my JRE installation, which doesn't  
>>>> seem  like the
>>>> correct approach.  I am using geronimo 2.0.2 on Windows XP and  
>>>> the 1.6.0_03
>>>> Sun JVM.  Any help with resolving this issue, and getting  
>>>> geronimo to
>>>> correctly load this login module class, would be greatly   
>>>> appreciated. If
>>>> any additional information is needed, please let me know.  Thanks.
>>>> - Brian

View raw message