I just cannot seem to get an Application-managed DataSource to work!
I am using Tomcat 5.5.17 on JDK 1.5.0_07 on Red Hat Linux.
I have done what I think is required in the context.xml and the web.xml files
for my application to enable an Application-managed DataSource, and have done
what is require to get the DataSource and get a connection from it, passing the
correct username & password, but when I try to get my first connection to the
database I always get an Exception telling me the username/password are invalid.
I have included below copies of the Stack Trace Back, the context.xml, the
web.xml, and the code used to access the DataSource and get the connection.
Everything was working fine with the same username & password using a
Container-managed DataSource, but now I have the requirement that I get the
plain-text username & password out of the XML files.
I tried to cast the DataSource to org.apache.tomcat.dbcp.dbcp.BasicDataSource,
so as to get and display some of the properties (username, password, url, etc)
but the package and class could not be found when compiling. So I added this
jar file to the classpath:
<INSTALL_DIR>/apache-tomcat-5.5.17/common/lib/naming-factory-dbcp.jar
Same error! I looked inside the jar file, and the .class file is indeed there.
Am I to assume this class is private or package-protected?
I downloaded the Tomcat source but cannot find the source for this class. I
could not even find and directories named 'dbcp' in the source tree. And I
grep'ed the entire source tree for the string 'BasicDataSource' and it wasn't found.
(And, like many, it seems, I tried <ResourceParams> in my context.xml, only to
find it doesn't work.)
Now I don't know what to do.
Can someone please help me?
Has anyone ever gotten an Application-managed DataSource to work?
Thanks,
---Mark Barnes
---Burlington Coat Factory Warehouse, Inc
---Lebanon, NH
============================
Here's the Stack Trace Back:
============================
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (ORA-01017:
invalid username/password; logon denied
)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:855)
at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:554)
at coat.util.DatabaseAlias.getConnection(DatabaseAlias.java:108)
at coat.util.DbUtils.getDatabaseConnection(DbUtils.java:383)
at cwp.DmTrxRequest.getInternetMap(DmTrxRequest.java:72)
at DmTrx.initializeData(DmTrx.java:1159)
at DmTrx.initialize(DmTrx.java:745)
at DmTrx.init(DmTrx.java:738)
at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3917)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4201)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904)
at
org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867)
at
org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
at
org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
at
org.apache.catalina.core.StandardService.start(StandardService.java:450)
at
org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
Caused by: java.sql.SQLException: ORA-01017: invalid username/password; logon
denied
============================
Here is the context.xml file
============================
<Context path="/allegiance"
docBase="allegiance"
debug="5"
reloadable="true"
crossContext="true"/>
<Resource name="jdbc/myoracle"
auth="Application"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:oci8:@tsvc"
maxActive="20"
maxIdle="10"
removeAbandoned="true"
removeAbandonedTimeout="120"
logAbandoned="true"
maxWait="-1" />
</Context>
====================
Here is the web.xml:
====================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app startup-mode='automatic' redeploy-mode='automatic'>
<servlet>
<servlet-name>WebAllegiance</servlet-name>
<servlet-class>DmTrx</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>BalanceInquiry</servlet-name>
<servlet-class>BalanceInq</servlet-class>
</servlet>
<servlet>
<servlet-name>f5_request</servlet-name>
<servlet-class>f5_request</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>WebAllegiance</servlet-name>
<url-pattern>/servlet/DmTrx</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>BalanceInquiry</servlet-name>
<url-pattern>/servlet/BalanceInq</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>f5_request</servlet-name>
<url-pattern>/servlet/f5_request</url-pattern>
</servlet-mapping>
<resource-ref>
<description>Oracle Datasource for SVC</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
</web-app>
=======================================
Here is a snippet from the Source Code:
=======================================
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection(this.userName, this.password);
} catch (SQLException e) }
e.printStackTrace();
}
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]