Hi,

  I have a problem with NamingException : "Cannot create resource instance"
with code :

    initCtx = new InitialContext(); }
    envCtx = (Context) initCtx.lookup("java:comp/env");
    System.out.println(envCtx.lookup("bean/MemoireFactory"));
     ||
     ====> NamingException : "Cannot create resource instance"

Have you an idea to correct this ?



Configuration :
---------------
 web.xml :
  <resource-env-ref>
    <resource-env-ref-name>bean/MemoireFactory</resource-env-ref-name>
    <resource-env-ref-type>pastel.jsp.HD_Exemple</resource-env-ref-type>
  </resource-env-ref>

 server.xml :
  <context ....>
    <Resource name="bean/MemoireFactory" auth="Container"
type="pastel.jsp.HD_Exemple"/>
    <ResourceParams name="bean/MemoireFactory">
      <parameter>
        <name>factory</name>
        <value>pastel.jsp.MemoireFactory></value>
      </parameter>
      </ResourceParams>
    </Context>

MemoireFactory :

public class MemoireFactory implements ObjectFactory
{
  public MemoireFactory() {System.out.println("
MemoireFactory.constructeur");}
  public Object getObjectInstance(Object obj,Name name, Context nameCtx,
Hashtable environment)
    throws NamingException
  {
    // Acquire an instance of our specified bean class
    HD_Exemple bean = new HD_Exemple();

    // Customize the bean properties from our attributes
    Reference ref = (Reference) obj;
    Enumeration addrs = ref.getAll();
    while (addrs.hasMoreElements())
    {
      RefAddr addr = (RefAddr) addrs.nextElement();
      String nom = addr.getType();
      String value = (String) addr.getContent();
      System.out.println("MemoireFactory "+nom+"="+value);
    }

    // Return the customized instance
    return (bean);
  }
}

I have read the Tomcat's HowTo about JNDI Resources.
The version of Tomcat is : 4.0.2.

Thanks for your help,

Elisabeth
Toulouse - France


--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to