Actually, I should phrase myself more carefully.  Whether names of this sort
will work or not depends on what your client is.  The "java:comp/env"
namespace is intended for resource references bound to specific beans.  For
instance, in the ejb-jar.xml file, you can bind things like JDBC
connections, references to other beans, even random data to names in the
"java:comp/env" namespace.  jBoss does support this.  However, since this is
specified in the ejb-jar.xml file, only beans themselves can use this
namespace (i.e., if one bean is the client of another).  However, if your
client is a servlet, or even just some random Java program somewhere, the
java:comp/env namespace will not necessarily work.  Some EJB servers might
provide it (like WebLogic), but it is not required by the J2EE
specification.

To this end, when designing any kind of bean client, that is not a bean
itelf, I would encapsulate all the lookup code in a place that is easy to
change.  By lookup code, I mean the system properties that set up the JNDI
provider url, etc., and the actual names of the beans.  Client behavior is a
lot more loosely dealt with in the J2EE specification than EJB behavior,
which is why I have found that beans are easy to port between servers, while
clients typically need some rewriting.

-Charles


Kevin Lewis wrote:

> Thanks for the reply, Charles.  The problem is that some existing code
> I'm deploying use names like this (for ease of development, I suppose).
> Because these examples work in things like the J2EE RI, WebLogic, etc.,
> I was thinking that they should work in jBoss.
>
> Are you saying that names like that won't work?
>
> Thanks for your time.
>
> -----Original Message-----
> From: Charles Crain [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 29, 2000 9:35 AM
> To: jBoss
> Subject: Re: [jBoss-User] JNDI Name java:comp/env/ejb/something
>
> Yeah, don't do that...
> The "java:" namespace is "reserved" in some sense.  It is used to look
> up
> things like environment properties and UserTransactions.  When binding
> an
> EJB to a name, do not use java:.  Look at some of the examples to see
> the
> names they are bound to.  For instance, the cd bean home interface gets
> a
> name like "cd/CDHome" or something.
>
> -Charles
>
> Kevin Lewis wrote:
>
> > Hi, everyone.
> >
> > I have a bean that I am deploying.  I am giving it a JNDI name of the
> > form:
> >
> >     java:comp/env/ejb/name
> >
> > However, when my client tries to lookup the name, RMI (I'm assuming)
> > returns:
> >
> > javax.naming.NameNotFoundException: comp not bound
> >         at
> > sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown
> > Source)
> >         at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown
> > Source)
> >         at sun.rmi.server.UnicastRef.invoke(Unknown Source)
> >         at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
> >         at
> > org.jnp.interfaces.NamingContext.lookup(NamingContext.java:280)
> >         at
> > org.jnp.interfaces.NamingContext.lookup(NamingContext.java:265)
> >         at javax.naming.InitialContext.lookup(Unknown Source)
> > .....
> >
> > If I give the bean a simple name (like "name") my client can look it
> up
> > just fine.
> >
> > Is this a problem with how I'm deploying the bean, with RMI, or with
> > jBoss?
> >
> > Thanks for any help.
> >
> > --
> > Kevin Lewis
> > Middle Reliever
> > Axys Solutions
> > http://www.AxysSolutions.com/
> >
> > --
> > --------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Problems?:           [EMAIL PROTECTED]
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to