users@glassfish.java.net

Re: Running Glassfish v2u2 --> JNDI datasource settings requires manual ref

From: <glassfish_at_javadesktop.org>
Date: Fri, 21 Nov 2008 09:35:57 PST

1: Here is a snippet of code called every time I need a context object:<br>[code]
  protected Object getEnv(String name)
  {
    if(DEBUG) System.out.println("BaseBean.getEnv() - method START with passed string: "+name);
    Object value = null;
    
    try
    {
      if(DEBUG) System.out.println("BaseBean.getEnv() - lookup ENV name and return");
      value = getJndiContext().lookup(name);
      if(DEBUG && (value != null)) System.out.println("BaseBean.getEnv() - ENV LOOKUP SUCCESS");
    }
    catch(Exception e)
    {
      if(DEBUG) System.out.println("BaseBean.getEnv() - ENV LOOKUP FAILED");
      errorLog("BaseBean.getEnv() - Exception: "+e);
      value = null;
    }
    
    return value;
  }
  
  protected Context getJndiContext()
   throws NamingException
  {
    if(m_JNDIContext!=null)
      return m_JNDIContext;

    m_JNDIContext = new InitialContext();
    
    return m_JNDIContext;
  }
[/code]

2: >asadmin version
      Version = Sun Java System Application Server 9.1_02

3: And here is a portion output from the server log at the first instance after I start the app server without manually doing a 're-deploy' of my JNDI reference with the admin web interface. [Note: most of this output is my own DEBUG print statments AND the method that calls this I now have forced it to try 3 times before failing]:<br><br>[code]
INFO: BaseDatabaseBean.getConnection(PropertyManager CBC.utils.properties.PropertiesManager) - enumerating JNDI Context: javax.naming.InitialContext_at_1c5cd05
INFO: - ENTRY: java:comp/env/PropertiesFile: java.lang.String
INFO: - number of elements 1
INFO:
INFO: BaseDatabaseBean.getConnection(PropertyManager object) - calls getEnv passing dsname= jdbc/CBCWEB to create a DataSource obj: m_DataSource
INFO: BaseBean.getEnv() - method START with passed string: jdbc/CBCWEB
INFO: BaseBean.getEnv() - lookup ENV name and return
INFO: BaseBean.getEnv() - ENV LOOKUP FAILED
INFO: 11/21/2008 11:18:37 - BaseBean.getEnv() - Exception: javax.naming.NameNotFoundException: CBCWEB not found
INFO: BaseDatabaseBean.getConnection(PropertyManager object) - m_DataSource RETURNED NULL!!! Retrying...
INFO: BaseBean.getEnv() - method START with passed string: jdbc/CBCWEB
INFO: BaseBean.getEnv() - lookup ENV name and return
INFO: BaseBean.getEnv() - ENV LOOKUP FAILED
INFO: 11/21/2008 11:18:37 - BaseBean.getEnv() - Exception: javax.naming.NameNotFoundException: CBCWEB not found
INFO: BaseDatabaseBean.getConnection(PropertyManager object) - m_DataSource RETURNED NULL!!! Retrying...
INFO: BaseBean.getEnv() - method START with passed string: jdbc/CBCWEB
INFO: BaseBean.getEnv() - lookup ENV name and return
INFO: BaseBean.getEnv() - ENV LOOKUP FAILED
INFO: 11/21/2008 11:18:37 - BaseBean.getEnv() - Exception: javax.naming.NameNotFoundException: CBCWEB not found
INFO: 11/21/2008 11:18:37 - BaseDatabaseBean.getConnection() - DataSource 'jdbc/CBCWEB' is null.[/code]<br><BR>Hope this helps or at least starts to reveal what's wrong...

-- da Lizard
[Message sent by forum member 'loungelizard' (loungelizard)]

http://forums.java.net/jive/thread.jspa?messageID=318140