Just a guess on my part, but the connection is probably in the JNDI namespace, not the COMP namespace. To test this you can try either "java:/env" or just "/env" (sorry, can't recall which off the top of my head) where you have: "java:comp/env"

As a side point, you should probably put all such logic into a session bean(s) that your action classes can call. Aside from this being a more 3-tier architecture it should allow you query your container (for instance, using the jmx-console in JBoss) to find out exactly what namespace(s) your beans are available in.

hth,

Joe

rainer juenger wrote:

Hi Maarten,

join the club! There are some more guys having exactliy the same problem as
you.
To me your configuration looks all right. I saw some samples :

<parameter>      <name>driverName</name>
<value>jdbc:mysql://localhost/test</value> </parameter>

where the parameter name is not driverName but url. I tried both without
luck.

Are you using Tomcat 4.x without DBCP from the Jakarta Commons to get the
JNDI DB Connection?

Please follow the thread "Connection pooling dowsn't work for me ... Help
!!"
Hopefully there is someone arround giving us a tip how to get it run

Good luck to all of us ;)
Rainer

----- Original Message -----
From: "Maarten Roosendaal" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 14, 2002 3:42 PM
Subject: DataSource problem


Hi,


I'm trying to create a simple DataBase app. using Struts. Right now i have a
problem with getting the DataSource out of the InitialContext and i'm not
sure what i'm doing wrong or maybe it has something to do with the Struts
Servlet.

In configured the server.xml as follows:
<Resource name="test" auth="CONTAINER"
     type="javax.sql.DataSource"/>

<ResourceParams name="test">
      <parameter>      <name>user</name>
<value>root</value>                                  </parameter>
      <parameter>      <name>password</name>            <value></value>
</parameter>
      <parameter>      <name>driverClassName</name>
<value>org.gjt.mm.mysql.Driver</value>     </parameter>
      <parameter>      <name>driverName</name>
<value>jdbc:mysql://localhost/test</value> </parameter>
     </ResourceParams>

and my web.xml includes the following:
   <resource-ref>
       <res-ref-name>test</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>CONTAINER</res-auth>
   </resource-ref>

In an Action-class i do this:
       Context env = (Context) new
InitialContext().lookup("java:comp/env");
       DataSource ds = (DataSource) env.lookup("test");
Here the DataSource keeps ending up as NULL. When i do this:
   Connection con = DriverManager.getConnection(Commands.DB_TEST_URL,
Commands.DB_TEST_USERNAME, "");
   things are working fine but i have no idea where to look. The Context
does seem to have a reference to the 'test' reference but nothing more.
Does this have something to do with Struts or did i forget something? I
don't want to use the struts.xml for a database-connection. One of the
reasons is that i keep getting the message that it can't find the driver,
while it is included in the CLASSPATH.

Hope someone can help,
Maarten




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






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



Reply via email to