- This topic has 6 replies, 5 voices, and was last updated 14 years, 9 months ago by support-joy.
-
AuthorPosts
-
ess_stegraParticipantTomcat 6 had changed how it accesses shared libraries. There is no /common/lib directory anymore. Here is my setup:
Database MS SQL Server 2005
ODBC Driver sqlodbc.jar (from Microsoft)
Web Server: Tomcat 6
context.xml:<Context> <Resource name="jdbc/DefaultDS" auth="Container" type="javax.sql.DataSource" username="tec" password="test" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://essentialsbs:1433;databaseName=tec;user=tec;password=test;" numTestsPerEvictionRun="15" timeBetweenEvictionRunsMillis="900000" minEvictableIdleTimeMillis="900000" testWhileIdle="true" testOnBorrow="false" validationQuery="select count(*) from tec.conference" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true" /> </Context>
This is my code to connect:
InitialContext jndiCntx = new InitialContext(); System.out.println("Looking up jdbc/DefaultDS"); DataSource ds = (javax.sql.DataSource) jndiCntx .lookup("java:comp/env/jdbc/DefaultDS"); System.out.println("Found. Connecting to jdbc/DefaultDS"); this.con = ds.getConnection();
Partial Stack Trace:
Looking up jdbc/DefaultDS Found. Connecting to jdbc/DefaultDS org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at com.tec.VisitBean.setupUser(VisitBean.java:477) at org.apache.jsp.logonHandler_jsp._jspService(logonHandler_jsp.java:84) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
Tomcat can’t find my sqlodbc.jar
I have tried placing it in
\webapps\TEC\META-INF
and in
\webapps\TEC\WEB-INF\libI still get the error. Where is Tomcat 6 expecting sqlodbc.jar to be located?
ess_stegraParticipantSolved the problem! Tomcat 6 did away with the $CATALINA_HOME/common/lib directory. The correct place to put libraries that need to be loaded before your application starts is now in the $CATALINA_HOME/lib directory. Not sure why they changed this, but this was why Tomcat could not load the driver.
Loyal WaterMemberGlad you got this sorted out.
pr0methiumMember@ess_stegra wrote:
Tomcat 6 had changed how it accesses shared libraries. There is no /common/lib directory anymore. Here is my setup:
Database MS SQL Server 2005
ODBC Driver sqlodbc.jar (from Microsoft)
Web Server: Tomcat 6
context.xml:<Context> <Resource name="jdbc/DefaultDS" auth="Container" type="javax.sql.DataSource" username="tec" password="test" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://essentialsbs:1433;databaseName=tec;user=tec;password=test;" numTestsPerEvictionRun="15" timeBetweenEvictionRunsMillis="900000" minEvictableIdleTimeMillis="900000" testWhileIdle="true" testOnBorrow="false" validationQuery="select count(*) from tec.conference" removeAbandoned="true" removeAbandonedTimeout="300" logAbandoned="true" /> </Context>
This is my code to connect:
InitialContext jndiCntx = new InitialContext(); System.out.println("Looking up jdbc/DefaultDS"); DataSource ds = (javax.sql.DataSource) jndiCntx .lookup("java:comp/env/jdbc/DefaultDS"); System.out.println("Found. Connecting to jdbc/DefaultDS"); this.con = ds.getConnection();
Partial Stack Trace:
Looking up jdbc/DefaultDS Found. Connecting to jdbc/DefaultDS org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at com.tec.VisitBean.setupUser(VisitBean.java:477) at org.apache.jsp.logonHandler_jsp._jspService(logonHandler_jsp.java:84) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
Tomcat can’t find my sqlodbc.jar
I have tried placing it in
\webapps\TEC\META-INF
and in
\webapps\TEC\WEB-INF\libI still get the error. Where is Tomcat 6 expecting sqlodbc.jar to be located?
I was getting a similar error to this the other day. This post is old, but hopefully someone will read it. My code was almost exactly the same (I altered what I had written to look more like yours as a starting point since it worked). What did you have as your resource mapping in the web.xml file? When I run mine in Eclipse it blows up with this stack trace:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at com.sony.common.Servlet.GreetingServlet.doPost(GreetingServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:710) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source) at java.sql.DriverManager.getDriver(Unknown Source) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
Loyal WaterMemberpr0methium,
Im not sure how this issue was resolved so we will have to wait for ess_stegra to give further inputs on this issue.
bipinsoftMember@ess_stegra wrote:
Solved the problem! Tomcat 6 did away with the $CATALINA_HOME/common/lib directory. The correct place to put libraries that need to be loaded before your application starts is now in the $CATALINA_HOME/lib directory. Not sure why they changed this, but this was why Tomcat could not load the driver.
hello ,
i have same problem but i don not know where is $CATALINA_HOME/lib directory
support-joyMemberbipinsoft,
$CATALINA_HOME is your environment variable which points to your TOMCAT HOME directory. Refer http://www.configure-all.com/env_variables.php
-
AuthorPosts