[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tomcat-user
Subject:    Re: Tomcat can't find JDBC Driver listed under Maven
From:       Sreyan Chakravarty <sreyan.mailing () gmail ! com>
Date:       2015-08-29 20:50:30
Message-ID: CAOcRYWpPLuvFgv8Q6svNgn5mTbBsEkkw+OkBYk52OADDqAohzA () mail ! gmail ! com
[Download RAW message or body]


Thanks Christopher but I have solved the problem. It seems when you are
using the Maven archetype for webapp you have to manually create a META-INF
in the /src/main/webapp directory and place the context.xml there.

And I have partly solved the issue. Will get back to you.

Regards
Sreyan Chakravarty

On Sat, Aug 29, 2015 at 1:02 AM, Christopher Schultz <
chris@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Sreyan,
>
> On 8/28/15 3:11 PM, Sreyan Chakravarty wrote:
> > Okay I am trying to use connection pooling for my project which
> > uses Maven as a build tool. Now the JDBC Driver is listed as a
> > maven dependency. Tomcat however cant find it when I try to do
> >
> > ds.getConnection (ie. get a JDBC connection from a datasource).
> >
> > The error that I am getting is -:
> >
> > java.sql.SQLException: Cannot create JDBC driver of class '' for
> > connect URL 'null'
> >
> > [snip]
> >
> > Caused by: java.sql.SQLException: No suitable driver at
> > java.sql.DriverManager.getDriver(DriverManager.java:315) at
> > org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(B
> asicDataSource.java:2049)
> >
> >
> ... 27 more
> >
> > As you can see in the end it says that caused by "No suitable
> > driver"
>
> Where is your mysql-*.jar file?
>
> > <Context>
> >
> > <Resource name="jdbc/TestDB" auth="Container"
> > type="javax.sql.DataSource" maxTotal="100" maxIdle="30"
> > maxWaitMillis="10000" removeAbandonedOnBorrow="true"
> > timeBetweenEvictionRunsMillis="10000"
> > minEvictableIdleTimeMillis="6000"
> > removeAbandonedOnMaintenance="true" logAbandoned="true"
> > username="sreyan" password="sreyan"
> > driverClassName="com.mysql.jdbc.Driver"
> > url="jdbc:mysql://localhost:3306/practice"/> <Realm
> > className="org.apache.catalina.realm.DataSourceRealm"
> > dataSourceName="jdbc/TestDB" userTable="users"
> > userNameCol="user_id" userCredCol="user_pass"
> > userRoleTable="user_roles" roleNameCol="role_name">
> >
> > <CredentialHandler className =
> > "org.apache.catalina.realm.SecretKeyCredentialHandler" algorithm =
> > "PBEWITHHMACSHA384ANDAES_256" iterations = "111111" saltLength =
> > "20" />
> >
> > </Realm> </Context>
>
> I'm glad you got the CredentialHandler stuff working (or did you?).
>
> NOTE: your <Realm> is going to need to have this attribute added to it
> in order to work:
>
>    localDataSource="true"
>
> > I have used the Maven webapp archetype for creating the project.
> >
> > How do I get Tomcat to load the driver at start up. Also I have put
> > the JDBC Driver at $Catalina_Home/lib. But even this has no help.
> > All my other projects that don't use Maven can use connection
> > pooling perfectly with the above configurations.
>
> Do you have the JDBC driver in both places (lib/ and
> webapps/[app]/WEB-INF/lib) or just in Tomcat's lib/ directory?
>
> > Where am I going wrong ? Where do you keep the <resource-ref>
> > declaration ? After the servlet mappings ?
>
> I've found that <resource-ref> is entirely unnecessary, but that may
> be because you have declared the <Resource> in your app's
> META-INF/context.xml file, so your application already knows it's local.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Comment: GPGTools - http://gpgtools.org
>
> iQIcBAEBCAAGBQJV4LdEAAoJEBzwKT+lPKRYHr4P/3Ewp4bFEOSU7SG17nzmMK9Q
> YpT8g+Zd8AFuF5uKH/IjogFMaZD5wgYalImjMxp1/KzgT3XULK0YWfd1NZcK276i
> kxXNEMB7ybjmbETASVGh/BDrCNn/v6GPv1TCI/mrjsrcP4iRHeUrLiMjfk9KxdaO
> n2kmn770bvBmYn/VvILu9KTLF1rWh/aY75mdUc2q5mtyqdC7dg+Ky0aeZCdQj5yM
> yxJCInN8ntk/UFIO2ycDoosgdQIvA9c0+4VluKJ7tGLSc0QRrEaLjNnAHn3J/evP
> jpUQTSnhgD9G9dzjVNEtNcwTFbPNemdItpSVFPHB3p6An5sE6uKY4hkTiCDAwTk5
> 4cp8fkpabVvSz0+FEYZ9FSOqeun2Bn61bJTqPM4Yk9Z9dfC92CcKkC8tnjnVyPaK
> DGgMxEFFZgBza9BZAtcGWn3CzOWBQvRJCiK/xm02dQKHYyszA33W/h9pGB1hIWJT
> hePUusot0w9p8IgDhFh4+0cTkTNAVUnIQWnPuHsdUn5Itc0qql1LDWRdhWlQMc6W
> tp3Oqt7noSnoZpIa2mLimXW/36QOkm1nxZl3urnbTlsxPuAmfrEt/ndfIoWPlhcN
> 1jbAF7Kh4k4wdBbu4SNptl1xqb2GVD3f+BcuSQr3s2OkYd8fXQqFzIDjS9JzWvD5
> iX2CYicMQroQhgS/06MQ
> =oogU
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic