You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark Winslow <ma...@yahoo.com> on 2005/02/02 17:52:17 UTC
JNDI resources different between 5.0 and 5.5?
Hi, I'm trying to upgrade from 5.0.28 to 5.5.4. I
have a java bean resource that no longer works in
5.5.4. Apparently the resource isn't being found. My
code for looking up the resources is:
public static Manager getManager()
{
try
{
Context initCtx = new InitialContext();
Context envCtx = (Context)
initCtx.lookup("java:comp/env");
Manager manager = (Manager)
envCtx.lookup("bean/MyManager"); // fails here on
lookup.
return manager;
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
In server.xml:
<Resourcource name="bean/MyManager" auth="Container"
type="MXForm.Manager"/>
I didn't have a web.xml entry in 5.0, but I added one
after reading the docs.
In web.xml:
<resource-env-ref>
<Description>
Manager resource.
</Description>
<resource-env-ref-name>
bean/MyManager
</resource-env-ref-name>
<resource-env-ref-type>
MXForm.Manager
</resource-env-ref-type>
</resource-env-ref>
Thanks.
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: JNDI resources different between 5.0 and 5.5?
Posted by Mark Winslow <ma...@yahoo.com>.
OK, I think I found the problem. You need to put in
the resource factory in the context section which I
didn't do. I have one question about the docs,
though. The docs seem to indicate that a new instance
of the bean will be created with every call to lookup.
This is not the behavior that I am noticing. I
actually want a single instance of the bean that spans
all sessions which is the behavior as I see it, but
the docs seem to indicate otherwise.
"The resource factory will create a new instance of
the appropriate bean class every time a lookup() for
this entry is made."
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-resources-howto.html
<Context ...>
...
<Resource name="bean/MyBeanFactory" auth="Container"
type="com.mycompany.MyBean"
factory="org.apache.naming.factory.BeanFactory"
bar="23"/>
...
</Context>
--- Mark Winslow <ma...@yahoo.com> wrote:
> Hi, I'm trying to upgrade from 5.0.28 to 5.5.4. I
> have a java bean resource that no longer works in
> 5.5.4. Apparently the resource isn't being found.
> My
> code for looking up the resources is:
>
> public static Manager getManager()
> {
> try
> {
> Context initCtx = new InitialContext();
> Context envCtx = (Context)
> initCtx.lookup("java:comp/env");
> Manager manager = (Manager)
> envCtx.lookup("bean/MyManager"); // fails here on
> lookup.
> return manager;
> }
> catch (Exception e)
> {
> e.printStackTrace();
> return null;
> }
> }
>
> In server.xml:
>
> <Resourcource name="bean/MyManager" auth="Container"
> type="MXForm.Manager"/>
>
> I didn't have a web.xml entry in 5.0, but I added
> one
> after reading the docs.
> In web.xml:
> <resource-env-ref>
> <Description>
> Manager resource.
> </Description>
> <resource-env-ref-name>
> bean/MyManager
> </resource-env-ref-name>
> <resource-env-ref-type>
> MXForm.Manager
> </resource-env-ref-type>
> </resource-env-ref>
>
> Thanks.
>
>
>
>
> __________________________________
> Do you Yahoo!?
> The all-new My Yahoo! - Get yours free!
> http://my.yahoo.com
>
>
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tomcat-user-help@jakarta.apache.org
>
>
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org