Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6000777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:44:33+00:00 2026-05-23T00:44:33+00:00

In server.xml: <GlobalNamingResources> <Resource name=jdbc/ArchiveDB auth=Container type=javax.sql.DataSource driverClassName=oracle.jdbc.OracleDriver factory=org.apache.tomcat.jdbc.pool.DataSourceFactory …etc In web.xml: <resource-ref> <description>Archive

  • 0

In server.xml:

<GlobalNamingResources>
<Resource name="jdbc/ArchiveDB" 
    auth="Container" 
    type="javax.sql.DataSource" 
    driverClassName="oracle.jdbc.OracleDriver"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    ...etc

In web.xml:

<resource-ref>
<description>Archive Database</description>
<res-ref-name>jdbc/ArchiveDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>  

My Code:

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

I am getting the following exception:

java.lang.ClassCastException: org.apache.tomcat.dbcp.dbcp.BasicDataSource cannot be cast to org.apache.tomcat.jdbc.pool.DataSource

Any idea what I have got wrong? It seems that the factory field in the resource is not being used, but I have no idea how to find out why. Any ideas how I can progress?

Update 1. Delving into source code, found the following in ResourceFactory.java

if (ref.getClassName().equals("javax.sql.DataSource")) {
String javaxSqlDataSourceFactoryClassName =
    System.getProperty("javax.sql.DataSource.Factory",
    Constants.DBCP_DATASOURCE_FACTORY);

I guess I have to set that system property so it doesn’t revert to default.

Update 2.
Have now set the following for startup:

-Djavax.sql.DataSource.Factory=org.apache.tomcat.jdbc.pool.DataSourceFactory

And getting different error:

09-Jun-2011 14:48:20 org.apache.naming.NamingContext lookup
WARNING: Unexpected exception resolving reference
java.sql.SQLException
at        org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:243)
Caused by: java.lang.NullPointerException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
    at     org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:236)
    ... 57 more
javax.naming.NamingException
    at org.apache.naming.NamingContext.lookup(NamingContext.java:843)

I guess it is not able to pick up the driver info I specified.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:44:34+00:00Added an answer on May 23, 2026 at 12:44 am

    Seems working now. I think this was a problem that I was debugging under Eclipse, so I wasn’t using the server.xml that I thought I was using. Eclipse copies the one under the tomcat directory. Solution is to delete and the recreate under Eclipse to get changes in server.xml to be effective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to query SQL Server XML type so that for an
I have a column that stores xml using SQL Server's Xml data type. Also,
In sql server xml column I have xml like this: <Test> <Operations> <Operations type=OperationSend>
In the server.xml for Tomcat I have a <Resource> tag with a Sybase datasource
I would like to use SQL Server xml type as a column type for
The server.xml which controls the startup of Apache Tomcat's servlet container contains a debug
SQL Server XML Schema Collection is an interesting concept and I find it very
Is there a way to have an SQL Server XML return use CDATA? I
I am having a tough time struggling with XML within Sql Server 2008. I
Is it possible to use Sql Server XML columns as a substitute for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.