tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Winslow <martinge...@yahoo.com>
Subject Re: JNDI resources different between 5.0 and 5.5?
Date Wed, 02 Feb 2005 20:46:05 GMT
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 <martingerxt@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


Mime
View raw message