users@glassfish.java.net

NameNotFound Exception: No object bound to name java:/comp/env

From: Mon Cab <futon33_at_yahoo.com>
Date: Mon, 31 Mar 2008 12:04:50 -0700 (PDT)

I am getting this error when I try run a web app in NetBeans? I looked
all over the web for the answer, but can't seem to find an explanation
that makes sense. This is a regular struts app, and the exception is
being thrown by the following code:

Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)initContext.lookup("jdbc/mydb");
Connection con = ds.getConnection();

The exception is:

javax.naming.NameNotFoundException: No object bound to name
java:/comp/env
        at com.bla.bla.class



The sun-resources.xml file is configured as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application
Server 9.0
Resource Definitions //EN"
"http://www.sun.com/software/appserver/dtds/sun-
resources_1_3.dtd">
<resources>
  <jdbc-resource enabled="true" jndi-name="jdbc/myDatasource"
object-type="user"
pool-name="connectionPool">
    <description/>
  </jdbc-resource>
  <jdbc-connection-pool allow-non-component-callers="false"
associate-with-
thread="false" connection-creation-retry-attempts="0"
connection-creation-retry-
interval-in-seconds="10" connection-leak-reclaim="false"
connection-leak-timeout-in-
seconds="0" connection-validation-method="auto-commit" datasource-
classname="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"
fail-all-
connections="false" idle-timeout-in-seconds="300"
is-connection-validation-
required="false" is-isolation-level-guaranteed="true" lazy-connection-
association="false" lazy-connection-enlistment="false"
match-connections="false" max
-connection-usage-count="0" max-pool-size="32"
max-wait-time-in-millis="60000"
name="connectionPool" non-transactional-connections="false"
pool-resize-quantity="2"
res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1"
steady-pool-
size="8" validate-atmost-once-period-in-seconds="0"
wrap-jdbc-objects="false">
    <property name="URL" value="jdbc:mysql://localhost/businessDB"/>
    <property name="User" value="root"/>
  </jdbc-connection-pool>
</resources>


However, looking under jndi resources under glassfish under servers in
the services tab in Netbeans, I do not see anything listed.

Since this is an Integrated development environment, I am guessing that
there should be a comp/env by default.

What is wrong here?




      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.
http://tc.deals.yahoo.com/tc/blockbuster/text5.com