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