Ok. Let me explain this again because I am getting no love here.
It seems to me that you cannot declare environment entries in 'web.xml' and
have them used in JNDI by Tomcat applications (i.e. servlets, jsps, etc...).
An environment entry in 'web.xml' looks something like this:
<web-app>
...
<env-entry>
<env-entry-name>ejb/catalog/CatalogDAOClass</env-entry-name>
<env-entry-value>com.sun....dao.CatalogDAOImpl</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry>
...
</web-app>
The result of this at deployment time is that your application server should
create a JNDI entry scoped under, or local to, a name relative to your
resource. For example, the same environment entry in 'ejb-jar.xml' for a
session bean produces the following output in the JNDI JMX console:
...
java:comp namespace of the TheCatalog bean:
+- env (class: org.jnp.interfaces.NamingContext)
| +- jdbc (class: org.jnp.interfaces.NamingContext)
| | +- EstoreDataSource[link -> java:/EstoreDB] (class:
javax.naming.LinkRef)
| +- ejb (class: org.jnp.interfaces.NamingContext)
| | +- catalog (class: org.jnp.interfaces.NamingContext)
| | | +- CatalogDAOClass (class: java.lang.String)
...
Something similar should normally be created for Tomcat.
The result of this configuration is that one can do something portable
inside your code like this:
myInitialContext.lookup( "java:comp/env/ejb/catalog/CatalogDAOClass" );
One does this because it is not portable across deployments to hard-code any
server-wide JNDI names into your code. Therefore EJB 1.1 provides an
environmental JNDI context that is local to each deployed EJB (one
environment per home) and this also extends to servlet containers (or
should). The prefix "java:comp/env" means the JNDI context local to the
component you are trying to access.
With me so far? Ok. Now the rub is that it appears JBoss2.2.2w/Tomcat3.2.2
completely ignore environment entries in 'web.xml'. Other items like
resource references or ejb-references must be specified in a file called
'jboss-web.xml'. The DTD for 'jboss-web.xml' looks like this (btw.. this DTD
is hard to find, could someone put it in the Documentation Files link?):
<?xml version='1.0' encoding='UTF-8' ?>
<!-- The JBoss specific elements used to integrate the servlet
web.xml elements into a JBoss deployment.
-->
<!-- The jboss-web element is the root element.
-->
<!ELEMENT jboss-web (resource-ref* , ejb-ref*)>
<!ELEMENT ejb-ref (ejb-ref-name , jndi-name)>
<!ELEMENT ejb-ref-name (#PCDATA)>
<!ELEMENT jndi-name (#PCDATA)>
<!ELEMENT resource-ref (res-ref-name , jndi-name)>
<!ELEMENT res-ref-name (#PCDATA)>
Note that there is no provision for an environment entry (which would be
something like '<!ELEMENT env-entry (env-entry-name, env-entry-value,
env-entry-type)>'. Because environment entries are not resource references
or ejb references you cannot kludge them into 'jboss-web.xml'. If you try,
say, creating a resource reference in 'jboss-web.xml'to map to an
environment entry you will be faced with two different problems:
1. Without an equivalent resource reference entry in 'web.xml' you will get
a deployment error.
2. Trying to translate an environment entry into a resource reference won't
work because they aren't the same thing.
If I am correct in the above, you will have to rework applications like
PetStore 1.1.2 to work with JBoss and not simply change a few deployment
items.
Some confirmation of this would be nice from anyone on the JBoss team
reading this list. Any changes in this behavior in 2.4 would also be good to
know.
Thanks, very much, for your efforts. If I have the time I will rummage
through the source code and see what I can implement on my own for JBoss
(not Petstore).
j.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of danch
Sent: Friday, June 29, 2001 4:53 PM
To: [EMAIL PROTECTED]
Subject: Re: [JBoss-user] Possible naming bug JBoss 2.2.2 with Tomcat
3.2.2
J. King wrote:
> True, there is an <env-entry> tag in web.xml which should bind a name to a
> value for "/ejb/catalog/CatalogDAOClass" which should in turn, I assume,
be
> accessible from the servlet using
> "java:comp/env/ejb/catalog/CatalogDAOClass".
>
> I don't think, however, that JBoss 2.2.2 binds <env-entry>s from web.xml
> into the jndi tree under a tomcat scope. You have to use jboss-web.xml.
This is an env-entry? You might be able to simply supply an empty
jboss-web.xml. I was thinking that this was a DataSource being looked up.
>
> Buuuuutttt, that gets into something circular: you can't reference
something
> from jboss-web.xml unless it has already been bound into the jndi
directory
> and as a result you can't add environment variables to the jndi directory
> for the tomcat scope using either the web.xml or jboss-web.xml files. You
> have to do it progammatically, as far as I can tell.
I don't follow. names in jboss-web.xml tell JBoss _how_ to map things in
JNDI - both descriptors (standard and jboss specific) are read together,
then the JNDI naming context is set up.
-danch
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user