You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Aman Nanner/MxI Technologies <am...@mxi.com> on 2007/01/19 00:02:12 UTC

Accessing EJB via JNDI from a web application

Hi,

I'm running into an issue using the Geronimo 1.2 beta release.

I'm running a web application from which an EJB is being looked up via its
JNDI name as declared in the openejb-jar.xml descriptor that resides in the
EJB module.  In my web.xml for the web application, I have the EJB declared
as a reference.

The problem is that I get a NameNotFoundException by looking up the EJB via
the JNDI name.  However, if I look up the EJB via it's EJB reference, as
defined in the ejb-jar.xml, then the lookup succeeds.  I know that I should
be using the EJB reference to look up the EJB anways, but I've got a legacy
app that I'm trying to port to Geronimo that is littered with EJB lookups
using direct JNDI names.

Before I dive into the Geronimo source code, perhaps somebody knows for
sure that EJB JNDI lookups are supposed to fail from within a server
context (i.e. it will fail by design) and let me know?

Thanks,
Aman

__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by David Jencks <da...@yahoo.com>.
On Jan 24, 2007, at 2:35 PM, Aman Nanner/MxI Technologies wrote:

> Despite the following error in the log:
>
>>> ERROR [KernelContextGBean] Error adding binding for
>>> Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/
>>> ear,j2eeType=EjbBindings,name=EjbBindings
>
> it seems that the GBean does indeed get properly deployed.  However, I
> still cannot yet get it to find my JNDI bindings.
>
> On the website, I noticed that it says that 1.2beta has Global JNDI
> support....is that different from this Global JNDI plugin?

yes they are partly different.  1.2 has a read-write global jndi tree  
installed by default under java: if I understand the configuration  
correctly.  However it doesn't have facitilties for automatically  
binding anything into it.

The global jndi plugin has some gbeans  that scan for ejbs and  
datasources getting started and stopped and binds and unbinds them in  
response.  This is not included in geronimo and it's what I suggested  
you try out.  Unfortunately there seem to be problems.

I would try to start geronimo with debug enabled and trace through  
the binding to try to figure out what is going wrong.

unfortunately I don't have time to try it myself right now.

thanks
david jencks

> Thanks,
> Aman
>
>
> David Jencks <da...@yahoo.com> wrote on 01-24-2007 03:43:10 PM:
>
>>
>> On Jan 24, 2007, at 9:31 AM, Aman Nanner/MxI Technologies wrote:
>>
>>> So it seems there's a problem with the code in the EjbBindings.java
>>> file.
>>> Specifically, the GBeanInfoBuilder object that is created in the
>>> static
>>> initializer does not define the "homeContext" and "localHomeContext"
>>> attributes that are used in the constructor.  I change the static
>>> initializer to the following, and rebuilt the global-jndi-plugin,
>>> and now I
>>> don't get that constructor initialization error:
>>>
>>>     static {
>>>         GBeanInfoBuilder builder =
>>> GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
>>>         builder.addAttribute("homeContext", String.class, true,  
>>> true);
>>>         builder.addAttribute("localHomeContext", String.class,
>>> true, true);
>>>         builder.setConstructor(new String[]{"kernel", "homeContext",
>>> "localHomeContext"});
>>>         GBEAN_INFO = builder.getBeanInfo();
>>>     }
>>>
>>>
>>> However, now I get another error when the GBean is attempted to be
>>> deployed:
>>>
>>> ERROR [KernelContextGBean] Error adding binding for
>>> Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/
>>> ear,j2eeType=EjbBindings,name=EjbBindings
>>>
>>> It's hard to decipher what this error means.  I noticed that
>>> there's been
>>> no work done to the Global JNDI plugin since September 29th, 2006.
>>> Is this
>>> piece not yet ready to be used?
>>
>> Well, it's not part of anything that's in line to be released, but
>> Dain had it working at one point and I don't know of any changes
>> likely to break it.  However apparently there has been something that
>> broke it.
>>
>> I suspect a different solution may be more appropriate for the
>> openejb3 integration but I have no idea what at this point.
>>
>> If you can figure out any more info on what is going wrong here we
>> might be able to fix this...
>>
>> thanks
>> david jencks
>
> ______________________________________________________________________ 
> ____________
> * This message is intended only for the use of the individual or  
> entity to which it is addressed, and may contain information that  
> is privileged, confidential and exempt from disclosure under  
> applicable law. Unless you are the addressee (or authorized to  
> receive for the addressee), you may not use, copy or disclose the  
> message or any information contained in the message. If you have  
> received this message in error, please advise the sender by reply e- 
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>


Re: Accessing EJB via JNDI from a web application

Posted by Aman Nanner/MxI Technologies <am...@mxi.com>.
Despite the following error in the log:

> > ERROR [KernelContextGBean] Error adding binding for
> > Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/
> > ear,j2eeType=EjbBindings,name=EjbBindings

it seems that the GBean does indeed get properly deployed.  However, I
still cannot yet get it to find my JNDI bindings.

On the website, I noticed that it says that 1.2beta has Global JNDI
support....is that different from this Global JNDI plugin?

Thanks,
Aman


David Jencks <da...@yahoo.com> wrote on 01-24-2007 03:43:10 PM:

>
> On Jan 24, 2007, at 9:31 AM, Aman Nanner/MxI Technologies wrote:
>
> > So it seems there's a problem with the code in the EjbBindings.java
> > file.
> > Specifically, the GBeanInfoBuilder object that is created in the
> > static
> > initializer does not define the "homeContext" and "localHomeContext"
> > attributes that are used in the constructor.  I change the static
> > initializer to the following, and rebuilt the global-jndi-plugin,
> > and now I
> > don't get that constructor initialization error:
> >
> >     static {
> >         GBeanInfoBuilder builder =
> > GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
> >         builder.addAttribute("homeContext", String.class, true, true);
> >         builder.addAttribute("localHomeContext", String.class,
> > true, true);
> >         builder.setConstructor(new String[]{"kernel", "homeContext",
> > "localHomeContext"});
> >         GBEAN_INFO = builder.getBeanInfo();
> >     }
> >
> >
> > However, now I get another error when the GBean is attempted to be
> > deployed:
> >
> > ERROR [KernelContextGBean] Error adding binding for
> > Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/
> > ear,j2eeType=EjbBindings,name=EjbBindings
> >
> > It's hard to decipher what this error means.  I noticed that
> > there's been
> > no work done to the Global JNDI plugin since September 29th, 2006.
> > Is this
> > piece not yet ready to be used?
>
> Well, it's not part of anything that's in line to be released, but
> Dain had it working at one point and I don't know of any changes
> likely to break it.  However apparently there has been something that
> broke it.
>
> I suspect a different solution may be more appropriate for the
> openejb3 integration but I have no idea what at this point.
>
> If you can figure out any more info on what is going wrong here we
> might be able to fix this...
>
> thanks
> david jencks

__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by David Jencks <da...@yahoo.com>.
On Jan 24, 2007, at 9:31 AM, Aman Nanner/MxI Technologies wrote:

> So it seems there's a problem with the code in the EjbBindings.java  
> file.
> Specifically, the GBeanInfoBuilder object that is created in the  
> static
> initializer does not define the "homeContext" and "localHomeContext"
> attributes that are used in the constructor.  I change the static
> initializer to the following, and rebuilt the global-jndi-plugin,  
> and now I
> don't get that constructor initialization error:
>
>     static {
>         GBeanInfoBuilder builder =
> GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
>         builder.addAttribute("homeContext", String.class, true, true);
>         builder.addAttribute("localHomeContext", String.class,  
> true, true);
>         builder.setConstructor(new String[]{"kernel", "homeContext",
> "localHomeContext"});
>         GBEAN_INFO = builder.getBeanInfo();
>     }
>
>
> However, now I get another error when the GBean is attempted to be
> deployed:
>
> ERROR [KernelContextGBean] Error adding binding for
> Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/ 
> ear,j2eeType=EjbBindings,name=EjbBindings
>
> It's hard to decipher what this error means.  I noticed that  
> there's been
> no work done to the Global JNDI plugin since September 29th, 2006.   
> Is this
> piece not yet ready to be used?

Well, it's not part of anything that's in line to be released, but  
Dain had it working at one point and I don't know of any changes  
likely to break it.  However apparently there has been something that  
broke it.

I suspect a different solution may be more appropriate for the  
openejb3 integration but I have no idea what at this point.

If you can figure out any more info on what is going wrong here we  
might be able to fix this...

thanks
david jencks

>
>
> Aman Nanner/MxI Technologies <am...@mxi.com> wrote on 01-22-2007
> 01:22:13 PM:
>
>> I'm using the following GBean declaration in my geronimo- 
>> application.xml:
>>
>>     <sys:gbean name="EjbBindings"
>> class="org.apache.geronimo.gjndi.binding.EjbBindings">
>>         <attribute name="homeContext">remote</attribute>
>>         <attribute name="localHomeContext">local</attribute>
>>     </sys:gbean>
>>
>> I was looking at the source code for EjbBindings.xml where I see the
>> following code fragment:
>>
>>     static {
>>         GBeanInfoBuilder builder =
>> GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
>>         builder.setConstructor(new String[]{"kernel", "homeContext",
>> "localHomeContext"});
>>         GBEAN_INFO = builder.getBeanInfo();
>>     }
>>
>> Although looking at it now, I guess the "setConstructor" method is  
>> just
>> taking an array of String arguments that are the names of the  
>> attributes,
>> and that these are not references to attribute types.
>>
>> This is the error I get when I try to deploy my application with the
>> preceding GBean declaration:
>>
>>      [java]     at java.lang.Thread.run(Thread.java:595)
>>      [java] Caused by:
>> org.apache.geronimo.gbean.InvalidConfigurationException: Could not  
>> find a
>> valid constructor for G
>> Bean: org.apache.geronimo.gjndi.binding.EjbBindings
>>      [java]     at
>> org.apache.geronimo.gbean.GBeanInfoBuilder.
>> getConstructorTypes(GBeanInfoBuilder.java:500)
>>      [java]     at
>> org.apache.geronimo.gbean.GBeanInfoBuilder.
>> getBeanInfo(GBeanInfoBuilder.java:438)
>>      [java]     at
>>
> org.apache.geronimo.gjndi.binding.EjbBindings.<clinit> 
> (EjbBindings.java:106)
>
>>
>>
>> Any ideas of what could be wrong?
>>
>> David Jencks <da...@yahoo.com> wrote on 01-22-2007 12:20:15  
>> PM:
>>
>>>
>>> On Jan 22, 2007, at 6:46 AM, Aman Nanner/MxI Technologies wrote:
>>>
>>>> This GBean apparently takes a magic attribute "kernel" of type
>>>> "String"
>>>> (according to the source code definition, although the
>>>> documentation I've
>>>> seen says it should be of type Kernel).
>>>
>>> Its the actual kernel instance that geronimo is running in.   
>>> Where is
>>> the documentation that says its a String?
>>>
>>>> I can't find any examples on how a
>>>> GBean that takes magic attributes is declared within an application
>>>> module,
>>>> and I keep getting a constructor initialization error.  Is the  
>>>> magic
>>>> attribute supposed to be specified at all in the XML GBean
>>>> declaration?
>>>
>>> You don't specify anything about the magic attributes in xml, they
>>> are added (by magic :-) for you by the gbean infrastructure when the
>>> gbean instance is created.  Another magic attribute that is often
>>> useful is the classLoader of the module the gbean is deployed in.
>>>
>>> What is the error you are getting?
>>>
>>> thanks
>>> david jencks
>>>
>>>>
>>>>
>>>>
>>>>
>>>>              David Jencks
>>>>              <david_jencks@yah
>>>>
>>>> oo.com>                                                    To
>>>>                                        user@geronimo.apache.org
>>>>              01-18-2007
>>>> 08:24                                           cc
>>>>              PM
>>>>
>>>> Subject
>>>>                                        Re: Accessing EJB via JNDI
>>>> from a
>>>>              Please respond to         web application
>>>>              user@geronimo.apa
>>>>                   che.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:
>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> I'm running into an issue using the Geronimo 1.2 beta release.
>>>>>
>>>>> I'm running a web application from which an EJB is being looked up
>>>>> via its
>>>>> JNDI name as declared in the openejb-jar.xml descriptor that
>>>>> resides in the
>>>>> EJB module.  In my web.xml for the web application, I have the EJB
>>>>> declared
>>>>> as a reference.
>>>>>
>>>>> The problem is that I get a NameNotFoundException by looking up  
>>>>> the
>>>>> EJB via
>>>>> the JNDI name.  However, if I look up the EJB via it's EJB
>>>>> reference, as
>>>>> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
>>>>> I should
>>>>> be using the EJB reference to look up the EJB anways, but I've got
>>>>> a legacy
>>>>> app that I'm trying to port to Geronimo that is littered with EJB
>>>>> lookups
>>>>> using direct JNDI names.
>>>>>
>>>>> Before I dive into the Geronimo source code, perhaps somebody  
>>>>> knows
>>>>> for
>>>>> sure that EJB JNDI lookups are supposed to fail from within a  
>>>>> server
>>>>> context (i.e. it will fail by design) and let me know?
>>>>
>>>> You have to do a bit of work to enable this -- we didn't end up
>>>> including all the pieces in geronimo.
>>>>
>>>> If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
>>>> plugins/global-jndi you'll find a class EjbBindings.  I don't think
>>>> this made it into geronimo itself.  If you build this little  
>>>> project
>>>> and deploy an instance of this ejbBindings gbean in your ejb app it
>>>> should result in each ejb getting bound in the global java:context
>>>> under the names you specified in the openejb-jar plan.
>>>>
>>>> I think the gbean config would look something like
>>>>
>>>> <gbean name="EjbBindings"
>>>> class="org.apache.geronimo.gjndi.binding.EJBBindings">
>>>>      <attribute name="homeContext">remote</attribute>
>>>>      <attribute name="localHomeContext">local</attribute>
>>>> </gbean>
>>>>
>>>> Then a typical remote home would be bound at java:remote/foo.
>>>>
>>>> Hope this helps and sorry for not making it easier.
>>>>
>>>> thanks
>>>> david jencks
>>>>
>>>>>
>>>>> Thanks,
>>>>> Aman
>>>>>
>>>>>
> _____________________________________________________________________
>>>>> _
>>>>> ____________
>>>>> * This message is intended only for the use of the individual or
>>>>> entity to which it is addressed, and may contain information that
>>>>> is privileged, confidential and exempt from disclosure under
>>>>> applicable law. Unless you are the addressee (or authorized to
>>>>> receive for the addressee), you may not use, copy or disclose the
>>>>> message or any information contained in the message. If you have
>>>>> received this message in error, please advise the sender by  
>>>>> reply e-
>>>>> mail , and delete the message, or call (collect) 001 613 747  
>>>>> 4698. *
>>>>>
>>>>
>>>>
>>>>
>>>>
> ______________________________________________________________________
>>>> ____________
>>>> * This message is intended only for the use of the individual or
>>>> entity to which it is addressed, and may contain information that
>>>> is privileged, confidential and exempt from disclosure under
>>>> applicable law. Unless you are the addressee (or authorized to
>>>> receive for the addressee), you may not use, copy or disclose the
>>>> message or any information contained in the message. If you have
>>>> received this message in error, please advise the sender by  
>>>> reply e-
>>>> mail , and delete the message, or call (collect) 001 613 747  
>>>> 4698. *
>>>>
>>>
>>
>>
> ______________________________________________________________________ 
> ____________
>
>> * This message is intended only for the use of the individual or
>> entity to which it is addressed, and may contain information that is
>> privileged, confidential and exempt from disclosure under applicable
>> law. Unless you are the addressee (or authorized to receive for the
>> addressee), you may not use, copy or disclose the message or any
>> information contained in the message. If you have received this
>> message in error, please advise the sender by reply e-mail , and
>> delete the message, or call (collect) 001 613 747 4698. *
>>
>
> ______________________________________________________________________ 
> ____________
> * This message is intended only for the use of the individual or  
> entity to which it is addressed, and may contain information that  
> is privileged, confidential and exempt from disclosure under  
> applicable law. Unless you are the addressee (or authorized to  
> receive for the addressee), you may not use, copy or disclose the  
> message or any information contained in the message. If you have  
> received this message in error, please advise the sender by reply e- 
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>


Re: Accessing EJB via JNDI from a web application

Posted by Aman Nanner/MxI Technologies <am...@mxi.com>.
So it seems there's a problem with the code in the EjbBindings.java file.
Specifically, the GBeanInfoBuilder object that is created in the static
initializer does not define the "homeContext" and "localHomeContext"
attributes that are used in the constructor.  I change the static
initializer to the following, and rebuilt the global-jndi-plugin, and now I
don't get that constructor initialization error:

    static {
        GBeanInfoBuilder builder =
GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
        builder.addAttribute("homeContext", String.class, true, true);
        builder.addAttribute("localHomeContext", String.class, true, true);
        builder.setConstructor(new String[]{"kernel", "homeContext",
"localHomeContext"});
        GBEAN_INFO = builder.getBeanInfo();
    }


However, now I get another error when the GBean is attempted to be
deployed:

ERROR [KernelContextGBean] Error adding binding for
Mxi/Maintenix/1/ear?J2EEApplication=Mxi/Maintenix/1/ear,j2eeType=EjbBindings,name=EjbBindings

It's hard to decipher what this error means.  I noticed that there's been
no work done to the Global JNDI plugin since September 29th, 2006.  Is this
piece not yet ready to be used?


Aman Nanner/MxI Technologies <am...@mxi.com> wrote on 01-22-2007
01:22:13 PM:

> I'm using the following GBean declaration in my geronimo-application.xml:
>
>     <sys:gbean name="EjbBindings"
> class="org.apache.geronimo.gjndi.binding.EjbBindings">
>         <attribute name="homeContext">remote</attribute>
>         <attribute name="localHomeContext">local</attribute>
>     </sys:gbean>
>
> I was looking at the source code for EjbBindings.xml where I see the
> following code fragment:
>
>     static {
>         GBeanInfoBuilder builder =
> GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
>         builder.setConstructor(new String[]{"kernel", "homeContext",
> "localHomeContext"});
>         GBEAN_INFO = builder.getBeanInfo();
>     }
>
> Although looking at it now, I guess the "setConstructor" method is just
> taking an array of String arguments that are the names of the attributes,
> and that these are not references to attribute types.
>
> This is the error I get when I try to deploy my application with the
> preceding GBean declaration:
>
>      [java]     at java.lang.Thread.run(Thread.java:595)
>      [java] Caused by:
> org.apache.geronimo.gbean.InvalidConfigurationException: Could not find a
> valid constructor for G
> Bean: org.apache.geronimo.gjndi.binding.EjbBindings
>      [java]     at
> org.apache.geronimo.gbean.GBeanInfoBuilder.
> getConstructorTypes(GBeanInfoBuilder.java:500)
>      [java]     at
> org.apache.geronimo.gbean.GBeanInfoBuilder.
> getBeanInfo(GBeanInfoBuilder.java:438)
>      [java]     at
>
org.apache.geronimo.gjndi.binding.EjbBindings.<clinit>(EjbBindings.java:106)

>
>
> Any ideas of what could be wrong?
>
> David Jencks <da...@yahoo.com> wrote on 01-22-2007 12:20:15 PM:
>
> >
> > On Jan 22, 2007, at 6:46 AM, Aman Nanner/MxI Technologies wrote:
> >
> > > This GBean apparently takes a magic attribute "kernel" of type
> > > "String"
> > > (according to the source code definition, although the
> > > documentation I've
> > > seen says it should be of type Kernel).
> >
> > Its the actual kernel instance that geronimo is running in.  Where is
> > the documentation that says its a String?
> >
> > > I can't find any examples on how a
> > > GBean that takes magic attributes is declared within an application
> > > module,
> > > and I keep getting a constructor initialization error.  Is the magic
> > > attribute supposed to be specified at all in the XML GBean
> > > declaration?
> >
> > You don't specify anything about the magic attributes in xml, they
> > are added (by magic :-) for you by the gbean infrastructure when the
> > gbean instance is created.  Another magic attribute that is often
> > useful is the classLoader of the module the gbean is deployed in.
> >
> > What is the error you are getting?
> >
> > thanks
> > david jencks
> >
> > >
> > >
> > >
> > >
> > >              David Jencks
> > >              <david_jencks@yah
> > >
> > > oo.com>                                                    To
> > >                                        user@geronimo.apache.org
> > >              01-18-2007
> > > 08:24                                           cc
> > >              PM
> > >
> > > Subject
> > >                                        Re: Accessing EJB via JNDI
> > > from a
> > >              Please respond to         web application
> > >              user@geronimo.apa
> > >                   che.org
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:
> > >
> > >>
> > >> Hi,
> > >>
> > >> I'm running into an issue using the Geronimo 1.2 beta release.
> > >>
> > >> I'm running a web application from which an EJB is being looked up
> > >> via its
> > >> JNDI name as declared in the openejb-jar.xml descriptor that
> > >> resides in the
> > >> EJB module.  In my web.xml for the web application, I have the EJB
> > >> declared
> > >> as a reference.
> > >>
> > >> The problem is that I get a NameNotFoundException by looking up the
> > >> EJB via
> > >> the JNDI name.  However, if I look up the EJB via it's EJB
> > >> reference, as
> > >> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
> > >> I should
> > >> be using the EJB reference to look up the EJB anways, but I've got
> > >> a legacy
> > >> app that I'm trying to port to Geronimo that is littered with EJB
> > >> lookups
> > >> using direct JNDI names.
> > >>
> > >> Before I dive into the Geronimo source code, perhaps somebody knows
> > >> for
> > >> sure that EJB JNDI lookups are supposed to fail from within a server
> > >> context (i.e. it will fail by design) and let me know?
> > >
> > > You have to do a bit of work to enable this -- we didn't end up
> > > including all the pieces in geronimo.
> > >
> > > If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
> > > plugins/global-jndi you'll find a class EjbBindings.  I don't think
> > > this made it into geronimo itself.  If you build this little project
> > > and deploy an instance of this ejbBindings gbean in your ejb app it
> > > should result in each ejb getting bound in the global java:context
> > > under the names you specified in the openejb-jar plan.
> > >
> > > I think the gbean config would look something like
> > >
> > > <gbean name="EjbBindings"
> > > class="org.apache.geronimo.gjndi.binding.EJBBindings">
> > >      <attribute name="homeContext">remote</attribute>
> > >      <attribute name="localHomeContext">local</attribute>
> > > </gbean>
> > >
> > > Then a typical remote home would be bound at java:remote/foo.
> > >
> > > Hope this helps and sorry for not making it easier.
> > >
> > > thanks
> > > david jencks
> > >
> > >>
> > >> Thanks,
> > >> Aman
> > >>
> > >>
_____________________________________________________________________
> > >> _
> > >> ____________
> > >> * This message is intended only for the use of the individual or
> > >> entity to which it is addressed, and may contain information that
> > >> is privileged, confidential and exempt from disclosure under
> > >> applicable law. Unless you are the addressee (or authorized to
> > >> receive for the addressee), you may not use, copy or disclose the
> > >> message or any information contained in the message. If you have
> > >> received this message in error, please advise the sender by reply e-
> > >> mail , and delete the message, or call (collect) 001 613 747 4698. *
> > >>
> > >
> > >
> > >
> > >
______________________________________________________________________
> > > ____________
> > > * This message is intended only for the use of the individual or
> > > entity to which it is addressed, and may contain information that
> > > is privileged, confidential and exempt from disclosure under
> > > applicable law. Unless you are the addressee (or authorized to
> > > receive for the addressee), you may not use, copy or disclose the
> > > message or any information contained in the message. If you have
> > > received this message in error, please advise the sender by reply e-
> > > mail , and delete the message, or call (collect) 001 613 747 4698. *
> > >
> >
>
>
__________________________________________________________________________________

> * This message is intended only for the use of the individual or
> entity to which it is addressed, and may contain information that is
> privileged, confidential and exempt from disclosure under applicable
> law. Unless you are the addressee (or authorized to receive for the
> addressee), you may not use, copy or disclose the message or any
> information contained in the message. If you have received this
> message in error, please advise the sender by reply e-mail , and
> delete the message, or call (collect) 001 613 747 4698. *
>

__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by Aman Nanner/MxI Technologies <am...@mxi.com>.
I'm using the following GBean declaration in my geronimo-application.xml:

    <sys:gbean name="EjbBindings"
class="org.apache.geronimo.gjndi.binding.EjbBindings">
        <attribute name="homeContext">remote</attribute>
        <attribute name="localHomeContext">local</attribute>
    </sys:gbean>

I was looking at the source code for EjbBindings.xml where I see the
following code fragment:

    static {
        GBeanInfoBuilder builder =
GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
        builder.setConstructor(new String[]{"kernel", "homeContext",
"localHomeContext"});
        GBEAN_INFO = builder.getBeanInfo();
    }

Although looking at it now, I guess the "setConstructor" method is just
taking an array of String arguments that are the names of the attributes,
and that these are not references to attribute types.

This is the error I get when I try to deploy my application with the
preceding GBean declaration:

     [java]     at java.lang.Thread.run(Thread.java:595)
     [java] Caused by:
org.apache.geronimo.gbean.InvalidConfigurationException: Could not find a
valid constructor for G
Bean: org.apache.geronimo.gjndi.binding.EjbBindings
     [java]     at
org.apache.geronimo.gbean.GBeanInfoBuilder.getConstructorTypes(GBeanInfoBuilder.java:500)
     [java]     at
org.apache.geronimo.gbean.GBeanInfoBuilder.getBeanInfo(GBeanInfoBuilder.java:438)
     [java]     at
org.apache.geronimo.gjndi.binding.EjbBindings.<clinit>(EjbBindings.java:106)


Any ideas of what could be wrong?

David Jencks <da...@yahoo.com> wrote on 01-22-2007 12:20:15 PM:

>
> On Jan 22, 2007, at 6:46 AM, Aman Nanner/MxI Technologies wrote:
>
> > This GBean apparently takes a magic attribute "kernel" of type
> > "String"
> > (according to the source code definition, although the
> > documentation I've
> > seen says it should be of type Kernel).
>
> Its the actual kernel instance that geronimo is running in.  Where is
> the documentation that says its a String?
>
> > I can't find any examples on how a
> > GBean that takes magic attributes is declared within an application
> > module,
> > and I keep getting a constructor initialization error.  Is the magic
> > attribute supposed to be specified at all in the XML GBean
> > declaration?
>
> You don't specify anything about the magic attributes in xml, they
> are added (by magic :-) for you by the gbean infrastructure when the
> gbean instance is created.  Another magic attribute that is often
> useful is the classLoader of the module the gbean is deployed in.
>
> What is the error you are getting?
>
> thanks
> david jencks
>
> >
> >
> >
> >
> >              David Jencks
> >              <david_jencks@yah
> >
> > oo.com>                                                    To
> >                                        user@geronimo.apache.org
> >              01-18-2007
> > 08:24                                           cc
> >              PM
> >
> > Subject
> >                                        Re: Accessing EJB via JNDI
> > from a
> >              Please respond to         web application
> >              user@geronimo.apa
> >                   che.org
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:
> >
> >>
> >> Hi,
> >>
> >> I'm running into an issue using the Geronimo 1.2 beta release.
> >>
> >> I'm running a web application from which an EJB is being looked up
> >> via its
> >> JNDI name as declared in the openejb-jar.xml descriptor that
> >> resides in the
> >> EJB module.  In my web.xml for the web application, I have the EJB
> >> declared
> >> as a reference.
> >>
> >> The problem is that I get a NameNotFoundException by looking up the
> >> EJB via
> >> the JNDI name.  However, if I look up the EJB via it's EJB
> >> reference, as
> >> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
> >> I should
> >> be using the EJB reference to look up the EJB anways, but I've got
> >> a legacy
> >> app that I'm trying to port to Geronimo that is littered with EJB
> >> lookups
> >> using direct JNDI names.
> >>
> >> Before I dive into the Geronimo source code, perhaps somebody knows
> >> for
> >> sure that EJB JNDI lookups are supposed to fail from within a server
> >> context (i.e. it will fail by design) and let me know?
> >
> > You have to do a bit of work to enable this -- we didn't end up
> > including all the pieces in geronimo.
> >
> > If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
> > plugins/global-jndi you'll find a class EjbBindings.  I don't think
> > this made it into geronimo itself.  If you build this little project
> > and deploy an instance of this ejbBindings gbean in your ejb app it
> > should result in each ejb getting bound in the global java:context
> > under the names you specified in the openejb-jar plan.
> >
> > I think the gbean config would look something like
> >
> > <gbean name="EjbBindings"
> > class="org.apache.geronimo.gjndi.binding.EJBBindings">
> >      <attribute name="homeContext">remote</attribute>
> >      <attribute name="localHomeContext">local</attribute>
> > </gbean>
> >
> > Then a typical remote home would be bound at java:remote/foo.
> >
> > Hope this helps and sorry for not making it easier.
> >
> > thanks
> > david jencks
> >
> >>
> >> Thanks,
> >> Aman
> >>
> >> _____________________________________________________________________
> >> _
> >> ____________
> >> * This message is intended only for the use of the individual or
> >> entity to which it is addressed, and may contain information that
> >> is privileged, confidential and exempt from disclosure under
> >> applicable law. Unless you are the addressee (or authorized to
> >> receive for the addressee), you may not use, copy or disclose the
> >> message or any information contained in the message. If you have
> >> received this message in error, please advise the sender by reply e-
> >> mail , and delete the message, or call (collect) 001 613 747 4698. *
> >>
> >
> >
> >
> > ______________________________________________________________________
> > ____________
> > * This message is intended only for the use of the individual or
> > entity to which it is addressed, and may contain information that
> > is privileged, confidential and exempt from disclosure under
> > applicable law. Unless you are the addressee (or authorized to
> > receive for the addressee), you may not use, copy or disclose the
> > message or any information contained in the message. If you have
> > received this message in error, please advise the sender by reply e-
> > mail , and delete the message, or call (collect) 001 613 747 4698. *
> >
>

__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by David Jencks <da...@yahoo.com>.
On Jan 22, 2007, at 6:46 AM, Aman Nanner/MxI Technologies wrote:

> This GBean apparently takes a magic attribute "kernel" of type  
> "String"
> (according to the source code definition, although the  
> documentation I've
> seen says it should be of type Kernel).

Its the actual kernel instance that geronimo is running in.  Where is  
the documentation that says its a String?

> I can't find any examples on how a
> GBean that takes magic attributes is declared within an application  
> module,
> and I keep getting a constructor initialization error.  Is the magic
> attribute supposed to be specified at all in the XML GBean  
> declaration?

You don't specify anything about the magic attributes in xml, they  
are added (by magic :-) for you by the gbean infrastructure when the  
gbean instance is created.  Another magic attribute that is often  
useful is the classLoader of the module the gbean is deployed in.

What is the error you are getting?

thanks
david jencks

>
>
>
>
>              David Jencks
>              <david_jencks@yah
>               
> oo.com>                                                    To
>                                        user@geronimo.apache.org
>              01-18-2007  
> 08:24                                           cc
>              PM
>                                                                     
> Subject
>                                        Re: Accessing EJB via JNDI  
> from a
>              Please respond to         web application
>              user@geronimo.apa
>                   che.org
>
>
>
>
>
>
>
>
>
> On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:
>
>>
>> Hi,
>>
>> I'm running into an issue using the Geronimo 1.2 beta release.
>>
>> I'm running a web application from which an EJB is being looked up
>> via its
>> JNDI name as declared in the openejb-jar.xml descriptor that
>> resides in the
>> EJB module.  In my web.xml for the web application, I have the EJB
>> declared
>> as a reference.
>>
>> The problem is that I get a NameNotFoundException by looking up the
>> EJB via
>> the JNDI name.  However, if I look up the EJB via it's EJB
>> reference, as
>> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
>> I should
>> be using the EJB reference to look up the EJB anways, but I've got
>> a legacy
>> app that I'm trying to port to Geronimo that is littered with EJB
>> lookups
>> using direct JNDI names.
>>
>> Before I dive into the Geronimo source code, perhaps somebody knows
>> for
>> sure that EJB JNDI lookups are supposed to fail from within a server
>> context (i.e. it will fail by design) and let me know?
>
> You have to do a bit of work to enable this -- we didn't end up
> including all the pieces in geronimo.
>
> If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
> plugins/global-jndi you'll find a class EjbBindings.  I don't think
> this made it into geronimo itself.  If you build this little project
> and deploy an instance of this ejbBindings gbean in your ejb app it
> should result in each ejb getting bound in the global java:context
> under the names you specified in the openejb-jar plan.
>
> I think the gbean config would look something like
>
> <gbean name="EjbBindings"
> class="org.apache.geronimo.gjndi.binding.EJBBindings">
>      <attribute name="homeContext">remote</attribute>
>      <attribute name="localHomeContext">local</attribute>
> </gbean>
>
> Then a typical remote home would be bound at java:remote/foo.
>
> Hope this helps and sorry for not making it easier.
>
> thanks
> david jencks
>
>>
>> Thanks,
>> Aman
>>
>> _____________________________________________________________________ 
>> _
>> ____________
>> * This message is intended only for the use of the individual or
>> entity to which it is addressed, and may contain information that
>> is privileged, confidential and exempt from disclosure under
>> applicable law. Unless you are the addressee (or authorized to
>> receive for the addressee), you may not use, copy or disclose the
>> message or any information contained in the message. If you have
>> received this message in error, please advise the sender by reply e-
>> mail , and delete the message, or call (collect) 001 613 747 4698. *
>>
>
>
>
> ______________________________________________________________________ 
> ____________
> * This message is intended only for the use of the individual or  
> entity to which it is addressed, and may contain information that  
> is privileged, confidential and exempt from disclosure under  
> applicable law. Unless you are the addressee (or authorized to  
> receive for the addressee), you may not use, copy or disclose the  
> message or any information contained in the message. If you have  
> received this message in error, please advise the sender by reply e- 
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>


Re: Accessing EJB via JNDI from a web application

Posted by Aman Nanner/MxI Technologies <am...@mxi.com>.
This GBean apparently takes a magic attribute "kernel" of type "String"
(according to the source code definition, although the documentation I've
seen says it should be of type Kernel).  I can't find any examples on how a
GBean that takes magic attributes is declared within an application module,
and I keep getting a constructor initialization error.  Is the magic
attribute supposed to be specified at all in the XML GBean declaration?



                                                                           
             David Jencks                                                  
             <david_jencks@yah                                             
             oo.com>                                                    To 
                                       user@geronimo.apache.org            
             01-18-2007 08:24                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re: Accessing EJB via JNDI from a   
             Please respond to         web application                     
             user@geronimo.apa                                             
                  che.org                                                  
                                                                           
                                                                           
                                                                           
                                                                           





On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:

>
> Hi,
>
> I'm running into an issue using the Geronimo 1.2 beta release.
>
> I'm running a web application from which an EJB is being looked up
> via its
> JNDI name as declared in the openejb-jar.xml descriptor that
> resides in the
> EJB module.  In my web.xml for the web application, I have the EJB
> declared
> as a reference.
>
> The problem is that I get a NameNotFoundException by looking up the
> EJB via
> the JNDI name.  However, if I look up the EJB via it's EJB
> reference, as
> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
> I should
> be using the EJB reference to look up the EJB anways, but I've got
> a legacy
> app that I'm trying to port to Geronimo that is littered with EJB
> lookups
> using direct JNDI names.
>
> Before I dive into the Geronimo source code, perhaps somebody knows
> for
> sure that EJB JNDI lookups are supposed to fail from within a server
> context (i.e. it will fail by design) and let me know?

You have to do a bit of work to enable this -- we didn't end up
including all the pieces in geronimo.

If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
plugins/global-jndi you'll find a class EjbBindings.  I don't think
this made it into geronimo itself.  If you build this little project
and deploy an instance of this ejbBindings gbean in your ejb app it
should result in each ejb getting bound in the global java:context
under the names you specified in the openejb-jar plan.

I think the gbean config would look something like

<gbean name="EjbBindings"
class="org.apache.geronimo.gjndi.binding.EJBBindings">
     <attribute name="homeContext">remote</attribute>
     <attribute name="localHomeContext">local</attribute>
</gbean>

Then a typical remote home would be bound at java:remote/foo.

Hope this helps and sorry for not making it easier.

thanks
david jencks

>
> Thanks,
> Aman
>
> ______________________________________________________________________
> ____________
> * This message is intended only for the use of the individual or
> entity to which it is addressed, and may contain information that
> is privileged, confidential and exempt from disclosure under
> applicable law. Unless you are the addressee (or authorized to
> receive for the addressee), you may not use, copy or disclose the
> message or any information contained in the message. If you have
> received this message in error, please advise the sender by reply e-
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>



__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by Aman Nanner/MxI Technologies <am...@mxi.com>.
Thanks for the reply.

I built the geronimo-global-jndi plugin and included it into my Geronimo
server.  I've declared a dependency on it in my app, and have also
registered it as a GBean.  However, during deployment of my app, I get an
exception when it tries to deploy the GBean:

     [java] Caused by:
org.apache.geronimo.gbean.InvalidConfigurationException: Could not find a
valid constructor for GBean: org.apache.geronimo.gjndi.binding.EjbBindings
     [java]     at
org.apache.geronimo.gbean.GBeanInfoBuilder.getConstructorTypes(GBeanInfoBuilder.java:500)
     [java]     at
org.apache.geronimo.gbean.GBeanInfoBuilder.getBeanInfo(GBeanInfoBuilder.java:438)
     [java]     at
org.apache.geronimo.gjndi.binding.EjbBindings.<clinit>(EjbBindings.java:106)

The following is my GBean declaration:

    <sys:gbean name="EjbBindings"
class="org.apache.geronimo.gjndi.binding.EjbBindings">
        <attribute name="homeContext">remote</attribute>
        <attribute name="localHomeContext">local</attribute>
    </sys:gbean>

I checked the source of the EjbBindings.java file, and it seems like the
constructor is declared as follows:

----
    static {
        GBeanInfoBuilder builder =
GBeanInfoBuilder.createStatic(EjbBindings.class, "EjbBindings");
        builder.setConstructor(new String[]{"kernel", "homeContext",
"localHomeContext"});
        GBEAN_INFO = builder.getBeanInfo();
    }

    public EjbBindings(Kernel kernel, String homeContext, String
localHomeContext) throws NamingException {
        super("", new AbstractNameQuery(null, Collections.EMPTY_MAP,
RpcEjbDeployment.class.getName()), kernel);
        NameParser parser = getNameParser();
        this.homeContext = parser.parse(homeContext);
        this.localHomeContext = parser.parse(localHomeContext);
    }

----

What is this "kernel" attribute that I'm supposed to pass into the
constructor?  I suppose this is the reason that it is failing...



                                                                           
             David Jencks                                                  
             <david_jencks@yah                                             
             oo.com>                                                    To 
                                       user@geronimo.apache.org            
             01-18-2007 08:24                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re: Accessing EJB via JNDI from a   
             Please respond to         web application                     
             user@geronimo.apa                                             
                  che.org                                                  
                                                                           
                                                                           
                                                                           
                                                                           





On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:

>
> Hi,
>
> I'm running into an issue using the Geronimo 1.2 beta release.
>
> I'm running a web application from which an EJB is being looked up
> via its
> JNDI name as declared in the openejb-jar.xml descriptor that
> resides in the
> EJB module.  In my web.xml for the web application, I have the EJB
> declared
> as a reference.
>
> The problem is that I get a NameNotFoundException by looking up the
> EJB via
> the JNDI name.  However, if I look up the EJB via it's EJB
> reference, as
> defined in the ejb-jar.xml, then the lookup succeeds.  I know that
> I should
> be using the EJB reference to look up the EJB anways, but I've got
> a legacy
> app that I'm trying to port to Geronimo that is littered with EJB
> lookups
> using direct JNDI names.
>
> Before I dive into the Geronimo source code, perhaps somebody knows
> for
> sure that EJB JNDI lookups are supposed to fail from within a server
> context (i.e. it will fail by design) and let me know?

You have to do a bit of work to enable this -- we didn't end up
including all the pieces in geronimo.

If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/
plugins/global-jndi you'll find a class EjbBindings.  I don't think
this made it into geronimo itself.  If you build this little project
and deploy an instance of this ejbBindings gbean in your ejb app it
should result in each ejb getting bound in the global java:context
under the names you specified in the openejb-jar plan.

I think the gbean config would look something like

<gbean name="EjbBindings"
class="org.apache.geronimo.gjndi.binding.EJBBindings">
     <attribute name="homeContext">remote</attribute>
     <attribute name="localHomeContext">local</attribute>
</gbean>

Then a typical remote home would be bound at java:remote/foo.

Hope this helps and sorry for not making it easier.

thanks
david jencks

>
> Thanks,
> Aman
>
> ______________________________________________________________________
> ____________
> * This message is intended only for the use of the individual or
> entity to which it is addressed, and may contain information that
> is privileged, confidential and exempt from disclosure under
> applicable law. Unless you are the addressee (or authorized to
> receive for the addressee), you may not use, copy or disclose the
> message or any information contained in the message. If you have
> received this message in error, please advise the sender by reply e-
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>



__________________________________________________________________________________
* This message is intended only for the use of the individual or entity to which it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. Unless you are the addressee (or authorized to receive for the addressee), you may not use, copy or disclose the message or any information contained in the message. If you have received this message in error, please advise the sender by reply e-mail , and delete the message, or call (collect) 001 613 747 4698. *


Re: Accessing EJB via JNDI from a web application

Posted by David Jencks <da...@yahoo.com>.
On Jan 18, 2007, at 3:02 PM, Aman Nanner/MxI Technologies wrote:

>
> Hi,
>
> I'm running into an issue using the Geronimo 1.2 beta release.
>
> I'm running a web application from which an EJB is being looked up  
> via its
> JNDI name as declared in the openejb-jar.xml descriptor that  
> resides in the
> EJB module.  In my web.xml for the web application, I have the EJB  
> declared
> as a reference.
>
> The problem is that I get a NameNotFoundException by looking up the  
> EJB via
> the JNDI name.  However, if I look up the EJB via it's EJB  
> reference, as
> defined in the ejb-jar.xml, then the lookup succeeds.  I know that  
> I should
> be using the EJB reference to look up the EJB anways, but I've got  
> a legacy
> app that I'm trying to port to Geronimo that is littered with EJB  
> lookups
> using direct JNDI names.
>
> Before I dive into the Geronimo source code, perhaps somebody knows  
> for
> sure that EJB JNDI lookups are supposed to fail from within a server
> context (i.e. it will fail by design) and let me know?

You have to do a bit of work to enable this -- we didn't end up  
including all the pieces in geronimo.

If you check out https://svn.apache.org/repos/asf/geronimo/sandbox/ 
plugins/global-jndi you'll find a class EjbBindings.  I don't think  
this made it into geronimo itself.  If you build this little project  
and deploy an instance of this ejbBindings gbean in your ejb app it  
should result in each ejb getting bound in the global java:context  
under the names you specified in the openejb-jar plan.

I think the gbean config would look something like

<gbean name="EjbBindings"  
class="org.apache.geronimo.gjndi.binding.EJBBindings">
     <attribute name="homeContext">remote</attribute>
     <attribute name="localHomeContext">local</attribute>
</gbean>

Then a typical remote home would be bound at java:remote/foo.

Hope this helps and sorry for not making it easier.

thanks
david jencks

>
> Thanks,
> Aman
>
> ______________________________________________________________________ 
> ____________
> * This message is intended only for the use of the individual or  
> entity to which it is addressed, and may contain information that  
> is privileged, confidential and exempt from disclosure under  
> applicable law. Unless you are the addressee (or authorized to  
> receive for the addressee), you may not use, copy or disclose the  
> message or any information contained in the message. If you have  
> received this message in error, please advise the sender by reply e- 
> mail , and delete the message, or call (collect) 001 613 747 4698. *
>