[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Tomcat4 and Debian



Hi all,
  I have been makeing an application under tomcat4. The application tuns 
correctly with the version 4.1.24 downloaded directly from apache. But it 
does not with the version of tomcat from debian (unstable). The following 
exception appears:

javax.naming.NamingException: Cannot create resource instance

These are the lines causing the exception:

        InitialContext init = new InitialContext();
        Context ctx = (Context) init.lookup("java:comp/env");
->      DataSource source = (DataSource)ctx.lookup("jdbc/contenedores");

In the /etc/tomcat4/server.xml I have defined the following under the 
application context:

          <Resource name="jdbc/contenedores" auth="Container"
                type="javax.sql.DataSource" />
          <ResourceParams name="jdbc/contenedores" >
                <parameter>
                    <name>driverClassName</name>
                    <value>com.mysql.jdbc.Driver</value>
                </parameter>
                <parameter>
                    <name>url</name>
                    <value>jdbc:mysql://localhost:3306/
contenedores?user=luis</value>
                </parameter>
                <parameter>
                    <name>password</name>
                    <value>1s8b3l1t8</value>
                </parameter>
                <parameter>
                    <name>username</name>
                    <value>luis</value>
                </parameter>
          </ResourceParams>


In the web.xml file of the application I have the following
    <resource-ref>
      <description>Base de datos de contenedores</description>
      <res-ref-name>jdbc/contenedores</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>    

And I have installed the file 05VazMaCon under the directory /etc/tomcat4/
policy.d containing:

grant codeBase "file:/home/luis/RamonVazquez/VazMaCon/WEB-INF/classes/-" {
  permission java.security.AllPermission;  
};


If I connect directly to de database:
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            conexion = DriverManager.getConnection("jdbc:mysql://localhost
/contenedores?user=luis&password=1s8b3l1t8");                

The application runs correctly. I suppose that there is a mistake in the jndi 
configuration, but I do not  what I have to do.

Thank you all,
        Luis Llana

-- 
Luis Fernando Llana Díaz
If you use Internet Explorer 6 under Windog XP, click here
http://antares.sip.ucm.es/~luis/ie/aviso.html



Reply to: