Have you defined the resource itself in server.xml?  You'll need to set up
the appropriate <Resource> and <ResourceParams> elements there in order to
define how Tomcat is actually supposed to create the object factory for
this resource.  See the jndi-resources-howto.html for more information on
creating object factories for your own beans.

Craig


On Sat, 27 Jul 2002, Michael Delamere wrote:

> Date: Sat, 27 Jul 2002 16:10:44 +0200
> From: Michael Delamere <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Tomcat + JNDI
>
> Hi,
>
> I�m trying to access a bean via JNDI using Tomcat.  Unfortunately, reading
> documentation and mailing-lists hasn�t helped me very much.  Could someone
> please expalin to me what is involved in accessing a bean in tomcat via
> JNDI.  Here�s what I�ve done so far:
>
> ========== WEB.XML ====================
> <resource-env-ref>
>   <description>
>     Object factory for MyBean instances.
>   </description>
>   <resource-env-ref-name>
>     jdo/FindMe
>   </resource-env-ref-name>
>   <resource-env-ref-type>
>     com.test.osforum.services.FindMe
>   </resource-env-ref-type>
> </resource-env-ref>
>
> ======== MY ACTION SERVLET ============
>   Context context;
>   Context envCtx;
>   try {
>    context = new InitialContext();
>    envCtx = (Context) context.lookup("java:comp/env");
>
>     FindMe findme = (FindMe) envCtx.lookup("jdo/FindMe");
>    message = findme.getSillyMessage();
>    request.setAttribute("message", message);
>   } catch (NamingException e) {
>    System.out.println("-----| CATCH NAMING EXCEPTION-: " + e.toString() + "
> |----- \n\n");
>    e.printStackTrace();
>   }
> ========================================
>
> The above results in a " javax.naming.NamingException: Cannot create
> resource instance".  Could someone please point me in the right direction.
>
> Regards,
>
> Michael
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to