tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniele Development-ML" <daniele....@googlemail.com>
Subject Problems with user/password data when trying to connect to DBs - Tomcat sees '' as username instead of the given one
Date Tue, 09 Sep 2008 10:54:04 GMT
Hello,

I have a WS deployed on Tomcat and querying a DB. The JDBC and JNDI
configurations should be fine but I still have some problems.

When loading the WS (actually starting Tomcat)  I got the following
exception. It doesn't recognise the user and password I set in the
context.xml.

I searched for similar problems, but in the net there are only example
exceptions that indeed see the username they set. In my case, the program
doesn't consider the username "me" and indeed tries to estabilish the
connection with username ' ' . The account perfectly works when accessing
through the MySQL Query Browser.

Any hints on what I'm doing wrong?

Thanks!

Dan


Tomcat Exception:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Access denied for user ''@'localhost' (using
password: YES))
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225)
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
        at
uk.ac.ox.comlab.combio.euhart.db.DBAccess.connect(DBAccess.java:96)
        at
uk.ac.ox.comlab.combio.euhart.db.DBAccess.<init>(DBAccess.java:37)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at java.lang.Class.newInstance0(Class.java:355)
        at java.lang.Class.newInstance(Class.java:308)
        at
com.sun.xml.ws.api.server.InstanceResolver.createNewInstance(InstanceResolver.java:215)
        at
com.sun.xml.ws.api.server.InstanceResolver.createDefault(InstanceResolver.java:180)
        at
com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:123)
        at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
        at
com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
        at
com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
        at
com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
        at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
        at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
        at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
        at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
        at
org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:627)
        at
org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
        at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
        at
org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
        at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
        at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
        at
org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
        at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
        at
org.apache.catalina.core.StandardService.start(StandardService.java:516)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.sql.SQLException: Access denied for user ''@'localhost'
(using password: YES)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
        at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
        at
com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
        at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
        at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
        at
com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
        at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
        at
org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
        at
org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294)
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1247)
        at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1221)
        ... 40 more


web.xml

    <resource-ref>
        <description>
            The database DataSource for the CellML repository web
application.
        </description>
        <res-ref-name>jdbc/cellmlrep</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

context.xml

<Context path="/DB_WS" debug="5" reloadable="true" crossContext="true">
    <Resource name="jdbc/cellmlrep" type="javax.sql.DataSource"
auth="Container"
              user="me" password="me"
driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/cellmlrep" maxActive="8"
maxIdle="4"/>
</Context>


code:

private void connect() {
        try {

            Context ctx = new InitialContext( );
            DataSource ds =
(DataSource)ctx.lookup("java:comp/env/jdbc/cellmlrep");

            con = ds.getConnection();
        } catch (NamingException ex) {
            Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE,
null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(DBAccess.class.getName()).log(Level.SEVERE,
null, ex);
        }
    }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message