You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by toby cabot <to...@caboteria.org> on 2005/08/10 23:44:59 UTC

reference to ServerInfo from inside a j2ee app?

Hi Folks,

I'm working on getting web authentication to work, and it's mostly
there thanks to whoever wrote the "demo" application.  Thanks for
that, I learned a lot from looking at it.

Now I'd like to start the various gbeans in geronimo-application.xml
instead of relying on the ones in the org/apache/geronimo/Secure plan.
It mostly works, but the problem is getting a reference to ServerInfo.
If I crib from the demo app, like so:

    <gbean name="hello-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
        <attribute name="realmName">hello-realm</attribute>
        <reference name="LoginModuleConfiguration">
            <name>hello-login-chain</name>
        </reference>
        <reference name="ServerInfo">
            <module>org/apache/geronimo/System</module>
            <name>ServerInfo</name>
        </reference>
    </gbean>

I get this in the log:

17:03:49,034 DEBUG main [org.apache.geronimo.gbean.runtime.GBeanSingleReference] Waiting to start geronimo.server:J2EEApplication=hello,J2EEModule=null,J2EEServer=geronimo,j2eeType=SecurityRealm,name=hello-realm because no targets are running for reference ServerInfo matching the patternspatterns geronimo.server:J2EEApplication=hello,J2EEModule=org/apache/geronimo/System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo 

... and the hello-realm gbean is stuck in the starting state.  Note
that it's looking for ServerInfo with "J2EEApplication=hello" (which
is the name of my application) whereas the real ServerInfo has
"J2EEApplication=null".  I also tried swapping the module and name
elements with:

<gbean-name>geronimo.server:J2EEApplication=null,J2EEModule=org/apache/geronimo/System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo</gbean-name>

... then it works, but this seems much more brittle to me than using
the module and the name.  It works in the module/name case if I deploy
the gbean descriptors in a standalone descriptor file rather than in
the ear.

I'm wondering if in the module/name case Geronimo should try the
current application first, and if that fails try J2EEApplication=null.
If that sounds like a good idea I'd be willing to take a stab at it if
someone could point me to roughly the code that's doing the
translation from module/name to gbean name.

Thanks,
Toby

Re: reference to ServerInfo from inside a j2ee app?

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 10, 2005 at 06:12:04PM -0400, Aaron Mulder wrote:
> 	There are a lot more elements you can use in your reference:
> 
> http://chariotsolutions.com/geronimo/web-plan.html#figure-web-gbean-name
> 
> 	(It's at the very bottom of the page if the anchor doesn't work 
> for you).  In this case, it sounds like you want to add:
> 
> <application>null</application>

Cool, thanks, that looks like the ticket.  Looking forward to buying a
copy of the book when it becomes available.

Re: reference to ServerInfo from inside a j2ee app?

Posted by Aaron Mulder <am...@alumni.princeton.edu>.
	There are a lot more elements you can use in your reference:

http://chariotsolutions.com/geronimo/web-plan.html#figure-web-gbean-name

	(It's at the very bottom of the page if the anchor doesn't work 
for you).  In this case, it sounds like you want to add:

<application>null</application>

Aaron

On Wed, 10 Aug 2005, toby cabot wrote:
> Hi Folks,
> 
> I'm working on getting web authentication to work, and it's mostly
> there thanks to whoever wrote the "demo" application.  Thanks for
> that, I learned a lot from looking at it.
> 
> Now I'd like to start the various gbeans in geronimo-application.xml
> instead of relying on the ones in the org/apache/geronimo/Secure plan.
> It mostly works, but the problem is getting a reference to ServerInfo.
> If I crib from the demo app, like so:
> 
>     <gbean name="hello-realm" class="org.apache.geronimo.security.realm.GenericSecurityRealm">
>         <attribute name="realmName">hello-realm</attribute>
>         <reference name="LoginModuleConfiguration">
>             <name>hello-login-chain</name>
>         </reference>
>         <reference name="ServerInfo">
>             <module>org/apache/geronimo/System</module>
>             <name>ServerInfo</name>
>         </reference>
>     </gbean>
> 
> I get this in the log:
> 
> 17:03:49,034 DEBUG main [org.apache.geronimo.gbean.runtime.GBeanSingleReference] Waiting to start geronimo.server:J2EEApplication=hello,J2EEModule=null,J2EEServer=geronimo,j2eeType=SecurityRealm,name=hello-realm because no targets are running for reference ServerInfo matching the patternspatterns geronimo.server:J2EEApplication=hello,J2EEModule=org/apache/geronimo/System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo 
> 
> ... and the hello-realm gbean is stuck in the starting state.  Note
> that it's looking for ServerInfo with "J2EEApplication=hello" (which
> is the name of my application) whereas the real ServerInfo has
> "J2EEApplication=null".  I also tried swapping the module and name
> elements with:
> 
> <gbean-name>geronimo.server:J2EEApplication=null,J2EEModule=org/apache/geronimo/System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo</gbean-name>
> 
> ... then it works, but this seems much more brittle to me than using
> the module and the name.  It works in the module/name case if I deploy
> the gbean descriptors in a standalone descriptor file rather than in
> the ear.
> 
> I'm wondering if in the module/name case Geronimo should try the
> current application first, and if that fails try J2EEApplication=null.
> If that sounds like a good idea I'd be willing to take a stab at it if
> someone could point me to roughly the code that's doing the
> translation from module/name to gbean name.
> 
> Thanks,
> Toby
> 

moving demo security config out of geronimo (was Re: reference to ServerInfo from inside a j2ee app?)

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 10, 2005 at 02:59:32PM -0700, David Jencks wrote:
> BTW, the "secure" configuration should really be part of the demo app,  
> in its plan :-)  Would you be interested in patching up moving it  
> there?

http://issues.apache.org/jira/browse/GERONIMO-1069

Sorry for the delay, hope this is still relevant.

Toby

Re: reference to ServerInfo from inside a j2ee app?

Posted by toby cabot <to...@caboteria.org>.
On Wed, Aug 10, 2005 at 02:59:32PM -0700, David Jencks wrote:
... useful info, thanks ...
> BTW, the "secure" configuration should really be part of the demo app,  
> in its plan :-)  Would you be interested in patching up moving it  
> there?

You mean remove o/a/g/Secure from the set of configurations that get
assembled at build time?  Sure, I'll take a stab at that.  Can you
think of other apps/code that inherit from that configuration?  I'd
need to fix them, too.

Re: reference to ServerInfo from inside a j2ee app?

Posted by David Jencks <da...@yahoo.com>.
On Aug 10, 2005, at 2:44 PM, toby cabot wrote:

> Hi Folks,
>
> I'm working on getting web authentication to work, and it's mostly
> there thanks to whoever wrote the "demo" application.  Thanks for
> that, I learned a lot from looking at it.
>
> Now I'd like to start the various gbeans in geronimo-application.xml
> instead of relying on the ones in the org/apache/geronimo/Secure plan.
> It mostly works, but the problem is getting a reference to ServerInfo.
> If I crib from the demo app, like so:
>
>     <gbean name="hello-realm"  
> class="org.apache.geronimo.security.realm.GenericSecurityRealm">
>         <attribute name="realmName">hello-realm</attribute>
>         <reference name="LoginModuleConfiguration">
>             <name>hello-login-chain</name>
>         </reference>
>         <reference name="ServerInfo">
>             <module>org/apache/geronimo/System</module>
>             <name>ServerInfo</name>
>         </reference>
>     </gbean>
>
> I get this in the log:
>
> 17:03:49,034 DEBUG main  
> [org.apache.geronimo.gbean.runtime.GBeanSingleReference] Waiting to  
> start  
> geronimo.server: 
> J2EEApplication=hello,J2EEModule=null,J2EEServer=geronimo,j2eeType=Secu 
> rityRealm,name=hello-realm because no targets are running for  
> reference ServerInfo matching the patternspatterns  
> geronimo.server:J2EEApplication=hello,J2EEModule=org/apache/geronimo/ 
> System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo
>
> ... and the hello-realm gbean is stuck in the starting state.  Note
> that it's looking for ServerInfo with "J2EEApplication=hello" (which
> is the name of my application) whereas the real ServerInfo has
> "J2EEApplication=null".  I also tried swapping the module and name
> elements with:
>
> <gbean-name>geronimo.server:J2EEApplication=null,J2EEModule=org/ 
> apache/geronimo/ 
> System,J2EEServer=geronimo,j2eeType=GBean,name=ServerInfo</gbean-name>
>
> ... then it works, but this seems much more brittle to me than using
> the module and the name.  It works in the module/name case if I deploy
> the gbean descriptors in a standalone descriptor file rather than in
> the ear.
>
> I'm wondering if in the module/name case Geronimo should try the
> current application first, and if that fails try J2EEApplication=null.
> If that sounds like a good idea I'd be willing to take a stab at it if
> someone could point me to roughly the code that's doing the
> translation from module/name to gbean name.

I'd like to think a bit more about whether this is appropriate before I  
agree.  You can include an <application>null</application> element to  
specify the app.  One reason I hesitate to say "great idea" is that  
currently we are explicitly constructing a gbean name from what you  
supply + the context of the configuration (which is where the  
application name you see comes from).  Your suggestion would require  
querying the deployment context and kernel for an existing gbean of  
that name.  This would mean you'd have to install gbeandatas for every  
gbean in a configuration during the install phase rather than the  
addGBeans phase and it would impede constructing references between  
modules when one module is not deployed yet.

I guess we could query in the current configuration/DeploymentContext  
and then construct a gbean with application name "null"  This would  
require only rewriting all the deployers to register gbeandatas during  
the install phase and changing the service builder to do queries on the  
current deployment context.  I'm still not sure this is a good idea.

BTW, the "secure" configuration should really be part of the demo app,  
in its plan :-)  Would you be interested in patching up moving it  
there?

thanks
david jencks

>
> Thanks,
> Toby
>