RE: [EXTERNAL] Re: Could not find datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13
Chris: I did what you suggested, that is to remove all drivers from the application's WEB-INF/lib directory and leave the one in Tomcat's lib/ directory. Now the error "FATAL connection.DatasourceConnectionProvider - Could not find datasource: java:/comp/env/jdbc/TOPSDB " and " java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to javax.sql.DataSource " is gone. I am going to do more cleaning and re-arrangement to the jars. Thanks Gary -Original Message- From: Christopher Schultz [mailto:ch...@christopherschultz.net] Sent: Tuesday, March 26, 2019 10:43 AM To: users@tomcat.apache.org Subject: Re: [EXTERNAL] Re: Could not find datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13 -BEGIN PGP SIGNED MESSAGE- Hash: SHA256 Gary, On 3/25/19 12:08, Hua, Gary - Saint Louis, MO - Contractor wrote: > Olaf: > > Thanks for the input.I removed jdbc2_0-stdext.jar and > tomcat-dbcp.jar from > /opt/TomCat/apache-tomcat-9.0.13/webapps/TOPS-WEB/WEB-INF/lib and > did some cleaning on /opt/TomCat/apache-tomcat-9.0.13/lib, now > that is my lib folder looks like: Wow, this must be a very old web application. You still have some cleaning-up to do. > atadmin@eagnmnmed1f45:/opt/TomCat/apache-tomcat-9.0.13/webapps/TOPS-WE B/WEB-INF/lib>ls > -l total 20648 -rwxrwxrwx 1 atadmin atadmin 433164 Dec 17 17:47 > antlr-2.7.5H3.jar -rwxrwxrwx 1 atadmin atadmin 281998 Dec 17 17:45 > cglib-2.1.jar Super old. [...] > -rwxrwxrwx 1 atadmin atadmin 16777 Dec 17 17:45 asm-attrs.jar > -rwxrwxrwx 1 atadmin atadmin 26360 Dec 17 17:45 asm.jar > -rwxrwxrwx 1 atadmin atadmin 188671 Dec 17 17:47 > commons-beanutils.jar -rwxrwxrwx 1 atadmin atadmin 165119 Dec 17 > 17:45 commons-collections.jar > -rwxrwxrwx 1 atadmin atadmin 168446 Dec 17 17:47 > commons-digester.jar -rwxrwxrwx 1 atadmin atadmin 26388 Dec 17 > 17:47 commons-logging.jar -rwxrwxrwx 1 atadmin atadmin 84462 Dec > 17 17:47 commons-validator.jar -rwxrwxrwx 1 atadmin atadmin > 153115 Dec 17 17:45 jdom.jar -rwxrwxrwx 1 atadmin atadmin8812 > Dec 17 17:45 jta.jar -rwxrwxrwx 1 atadmin atadmin 367444 Dec 17 > 17:45 log4j.jar I'm always suspicious of library JAR files that have no version number. You might want to take a look at what these are and re-name them appropriately. > -rwxrwxrwx 1 atadmin atadmin 1196109 Dec 17 17:47 classes12.jar classes12.jar is Oracle's JDBC driver written for Java 1.2. I'm fairly sure that was hand-coded by Hammurabi himself. If you are indeed using Oracle DB, you need to upgrade to a library version released during this century. > -rwxrwxrwx 1 atadmin atadmin 3698857 Mar 15 15:32 ojdbc7.jar This is a second Oracle JDBC driver. Do you need both of them? > -rwxrwxrwx 1 atadmin atadmin 4604132 Dec 17 17:45 > com.ibm.ws.webcontainer.jar This is a WebSphere library. Presumably, you have left WebSphere behind in favor of Tomcat? Or maybe you need some service that WS provides and you have taken it with you? > -rwxrwxrwx 1 atadmin atadmin 205318 Mar 19 11:20 > commons-dbcp2-2.6.0.jar -rwxrwxrwx 1 atadmin atadmin 70604 Dec 17 > 17:45 commons-fileupload-1.3.3.jar -rwxrwxrwx 1 atadmin atadmin > 214788 Dec 17 17:45 commons-io-2.6.jar -rwxrwxrwx 1 atadmin > atadmin 207723 Dec 17 17:47 commons-lang-2.1.jar -rwxrwxrwx 1 > atadmin atadmin 315805 Dec 17 17:47 commons-lang3-3.1.jar > -rwxrwxrwx 1 atadmin atadmin 210432 Dec 17 17:45 > displaytag-1.1.jar -rwxrwxrwx 1 atadmin atadmin 12590 Dec 17 > 17:45 displaytag-export-poi-1.1.jar -rwxrwxrwx 1 atadmin atadmin > 312509 Dec 17 17:45 dom4j-1.5.2.jar -rwxrwxrwx 1 atadmin atadmin > 47531 Dec 17 17:45ehcache-1.1.jar -rwxrwxrwx 1 atadmin atadmin > 1925498 Dec 17 17:45 hibernate3.jar -rwxrwxrwx 1 atadmin atadmin > 65425 Dec 17 17:45jakarta-oro.jar > -rwxrwxrwx 1 atadmin atadmin 1979523 Dec 17 17:41 javaee-api-8.0.jar I'm fairly sure this should be removed. Tomcat provides all of the APIs that you need. While this may be a compile-time dependency, everything should be provided at runtime by Tomcat. > -rwxrwxrwx 1 atadmin atadmin 414240 Dec 17 16:29 jstl-1.2.jar > -rwxrwxrwx 1 atadmin atadmin 105355 Dec 17 17:45 > old_lcms-webtools.jar -rwxrwxrwx 1 atadmin atadmin 795231 Dec 17 > 17:45 poi-2.5-final-20040302.jar -rwxrwxrwx 1 atadmin atadmin > 55210 Dec 17 17:45poi-contrib-2.5-final-20040302.jar -rwxrwxrwx 1 > atadmin atadmin 188942 Dec 17 17:45 > poi-scratchpad-2.5-final-20040302.jar -rwxrwxrwx 1 atadmin atadmin > 475943 Dec 17 17:45 proxool-0.8.3.jar -rwxrwxrwx 1 atadmin atadmin > 543706 Dec 17 17:47 struts.jar Aha, I see. You are running Struts 1 which requires ancient versions of certain libraries. &
Re: [EXTERNAL] Re: Could not find datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13
rwxrwxrwx 1 atadmin atadmin 1653788 Nov 2 > 09:29 catalina.jar.20181115-1049 Remove this. > -rwxrwxrwx 1 atadmin atadmin 78634 Nov 2 09:29 > catalina-storeconfig.jar -rwxrwxrwx 1 atadmin atadmin 338876 Nov > 2 09:29 catalina-tribes.jar -rwxrwxrwx 1 atadmin atadmin 2769774 > Nov 2 09:29 ecj-4.7.3a.jar -rwxrwxrwx 1 atadmin atadmin 87515 > Nov 2 09:29 el-api.jar -rwxrwxrwx 1 atadmin atadmin 167490 Nov > 2 09:29jasper-el.jar -rwxrwxrwx 1 atadmin atadmin 557374 Nov 2 > 09:29 jasper.jar -rwxrwxrwx 1 atadmin atadmin 27900 Nov 2 09:29 > jaspic-api.jar -rwxrwxrwx 1 atadmin atadmin 63167 Nov 2 09:29 > jsp-api.jar -rwxrwxrwx 1 atadmin atadmin 3698857 Mar 12 17:51 > ojdbc7.jar This is duplicated from your web application. If Tomcat is configuring your JDBC connector for you (using a configuration) then you probably want to put your JAR file *here* and not in the applicatio n. > -rwxrwxrwx 1 atadmin atadmin 282576 Nov 2 09:29 servlet-api.jar > -rwxrwxrwx 1 atadmin atadmin 11212 Nov 2 09:29 tomcat-api.jar > -rwxrwxrwx 1 atadmin atadmin 845744 Nov 2 09:29 > tomcat-coyote.jar -rwxrwxrwx 1 atadmin atadmin 307435 Mar 19 17:42 > tomcat-dbcp-9.0.13.jar Is this not what came with Tomcat? You should not replace any of Tomcat's libraries without a *very* good reason. > -rwxrwxrwx 1 atadmin atadmin 65303 Nov 2 09:29 > tomcat-i18n-es.jar -rwxrwxrwx 1 atadmin atadmin 39235 Nov 2 > 09:29 tomcat-i18n-fr.jar -rwxrwxrwx 1 atadmin atadmin 42125 Nov > 2 09:29 tomcat-i18n-ja.jar -rwxrwxrwx 1 atadmin atadmin 12166 > Nov 2 09:29 tomcat-i18n-ru.jar -rwxrwxrwx 1 atadmin atadmin > 36029 Nov 2 09:29tomcat-jni.jar -rwxrwxrwx 1 atadmin atadmin > 165171 Nov 2 09:29 tomcat-util.jar -rwxrwxrwx 1 atadmin atadmin > 208966 Nov 2 09:29 tomcat-util-scan.jar -rwxrwxrwx 1 atadmin > atadmin 230254 Nov 2 09:29 tomcat-websocket.jar -rwxrwxrwx 1 > atadmin atadmin 38022 Nov 2 09:29 websocket-api.jar It would be well worth your while to run OWASP's dependency-checker against your applications dependencies (libraries). It will liekly scare the hell out of you. Or, it should. I suspect your problems are from: 1. Two drivers loaded at application level 2. One driver loaded at Tomcat level I would remove all drivers from the application's WEB-INF/lib directory and leave the one in Tomcat's lib/ directory. - -chris > -Original Message- From: Olaf Kock > [mailto:tom...@olafkock.de] Sent: Monday, March 25, 2019 1:56 AM > To: users@tomcat.apache.org Subject: [EXTERNAL] Re: Could not find > datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13 > > > > On 25.03.19 03:41, Hua, Gary - Saint Louis, MO - Contractor wrote: >> Hi experts: >> >> After I deployed my application TOPS to Tomcat server(9.0.13) on >> Linux box, and started the server, I got the following error: >> >> >> 1537 [main] FATAL connection.DatasourceConnectionProvider - >> Could not find datasource: java:/comp/env/jdbc/TOPSDB >> java.lang.ClassCastException: >> org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to >> javax.sql.DataSource at >> org.hibernate.connection.DatasourceConnectionProvider.configure(Datas o >> >> urceConnectionProvider.java> >> ... >> >> I have tried to put different version of tomcat-dbcp.jar like >> tomcat-dbcp-7.0.47.jar/ tomcat-dbcp-8.0.23.jar/ >> tomcat-dbcp-9.0.13.jar into >> /opt/TomCat/apache-tomcat-9.0.13/lib, but not the same error >> occurred. > > One way or another, the last sentence most likely is the most > relevant information, and key to solving your problem: Whenever a > Java class can't be typecast to its legitimate superclass or > interface, this is a clear sign that the superclass or interface > can be found twice on the classpath. > > The error message only contains the class name, not the > classloader, so the root cause is effectively hidden. Make sure > that javax.sql.DataSource is nowhere to be found in your app's > WEB-INF/lib, and only once in tomcat's lib directory. > > Olaf > > - > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > > > - > > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org > For additional commands, e-mail: users-h...@tomcat.apache.org > -BEGIN PGP SIGNATURE- Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/ iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAlyaSGgACgkQHPApP6U8 pFjyPA/9GNnf9FVkSL3yly8ebDaDy405PfyEdAW1YfYBqYyDJzjQV9f7xeK
RE: [EXTERNAL] Re: Could not find datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13
tomcat-i18n-ru.jar -rwxrwxrwx 1 atadmin atadmin 36029 Nov 2 09:29 tomcat-jni.jar -rwxrwxrwx 1 atadmin atadmin 165171 Nov 2 09:29 tomcat-util.jar -rwxrwxrwx 1 atadmin atadmin 208966 Nov 2 09:29 tomcat-util-scan.jar -rwxrwxrwx 1 atadmin atadmin 230254 Nov 2 09:29 tomcat-websocket.jar -rwxrwxrwx 1 atadmin atadmin 38022 Nov 2 09:29 websocket-api.jar I shutdown.sh and startup.sh the server, same error occurred. Thanks Gary -Original Message- From: Olaf Kock [mailto:tom...@olafkock.de] Sent: Monday, March 25, 2019 1:56 AM To: users@tomcat.apache.org Subject: [EXTERNAL] Re: Could not find datasource: java:/comp/env/jdbc/TOPSDB when start Tomcat 9.0.13 On 25.03.19 03:41, Hua, Gary - Saint Louis, MO - Contractor wrote: > Hi experts: > > After I deployed my application TOPS to Tomcat server(9.0.13) > on Linux box, and started the server, I got the following error: > > > 1537 [main] FATAL connection.DatasourceConnectionProvider - Could not > find datasource: java:/comp/env/jdbc/TOPSDB > java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp2.BasicDataSource > cannot be cast to javax.sql.DataSource > at > org.hibernate.connection.DatasourceConnectionProvider.configure(Dataso > urceConnectionProvider.java> > ... > > I have tried to put different version of tomcat-dbcp.jar like > tomcat-dbcp-7.0.47.jar/ tomcat-dbcp-8.0.23.jar/ tomcat-dbcp-9.0.13.jar into > /opt/TomCat/apache-tomcat-9.0.13/lib, but not the same error occurred. One way or another, the last sentence most likely is the most relevant information, and key to solving your problem: Whenever a Java class can't be typecast to its legitimate superclass or interface, this is a clear sign that the superclass or interface can be found twice on the classpath. The error message only contains the class name, not the classloader, so the root cause is effectively hidden. Make sure that javax.sql.DataSource is nowhere to be found in your app's WEB-INF/lib, and only once in tomcat's lib directory. Olaf - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org