You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ro...@surecomp.com on 2011/02/22 23:35:52 UTC
Issue with oralce drive under tomcat 7
Hello
I am run a webapp under tomcat that also runs under websphere and weblogic. I have identified changes to war and code needed to handle the jdni issues as well as differences in configuration of web services between the three containers.
The issue I am having (it seems strange and not believable) is a problem with code that works under the web* containers and does not seem to work under tomcat 7.
The following are log out puts from web* and tomcat they show that the driver being used via jdbc pooling is the same driver.
Weblogic/WebSphere log entries showing oracle driver
2011.02.22 05:00:22,602 Database Name: reportwriter
2011.02.22 05:00:22,602 Database Username: weblogic
2011.02.22 05:00:22,715 Database connection properties
2011.02.22 05:00:22,716 ------------------------------
2011.02.22 05:00:22,716 Database Connection URL: jdbc:oracle:thin:@ssi-allmatch:1521:reporting
2011.02.22 05:00:22,716 Database User Name: SYSTEM
2011.02.22 05:00:22,716 Database Product Name: Oracle
2011.02.22 05:00:22,717 Database Product Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
2011.02.22 05:00:22,717 Database Driver Name: Oracle JDBC driver
2011.02.22 05:00:22,717 Database Driver Version: 11.1.0.7.0-Production
2011.02.22 05:00:23,36 Language repositories have been populated successfully.
Log entries using Tomcat 7
2011.02.22 05:20:59,627 Database Name: reportwriter
2011.02.22 05:20:59,627 Database Username: tomcat
2011.02.22 05:21:00,46 Database connection properties
2011.02.22 05:21:00,46 ------------------------------
2011.02.22 05:21:00,46 Database Connection URL: jdbc:oracle:thin:@ssi-allmatch:1521:reporting
2011.02.22 05:21:00,46 Database User Name: SYSTEM
2011.02.22 05:21:00,46 Database Product Name: Oracle
2011.02.22 05:21:00,47 Database Product Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
2011.02.22 05:21:00,47 Database Driver Name: Oracle JDBC driver
2011.02.22 05:21:00,47 Database Driver Version: 11.1.0.7.0-Production
2011.02.22 04:57:05,280 Language repositories have been populated successfully.
When I start up web* I get the following log segment
2011.02.22 05:29:20,1 Initializing reporting object.
2011.02.22 05:29:20,91 ReportWriter Web application initialization has been completed.
When I start up Tomcat I get the following error
2011.02.22 05:21:04,193 Initializing reporting object.
2011.02.22 05:21:04,313 Error initializing Reporting object------
java.lang.RuntimeException: com.surecomp.reportwriter.bo.Reporting: unable to populate fields.
at com.surecomp.reportwriter.bo.BO.newInstance(BO.java:211)
at com.surecomp.reportwriter.ws.ReportingService.initialize(ReportingService.java:11)
at com.surecomp.reportwriter.ReportWriter.init(ReportWriter.java:286)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1133)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:996)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4741)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5062)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5057)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetMetaData cannot be cast to oracle.jdbc.OracleResultSetMetaData
at com.surecomp.reportwriter.ClientDatabase.getFieldTypes(ClientDatabase.java:1011)
at com.surecomp.reportwriter.bo.Reporting.populateFields(Reporting.java:107)
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:597)
at com.surecomp.reportwriter.bo.BO.newInstance(BO.java:205)
... 14 more
------
The code in question (by error) is the following
public HashMap<String, Class> getFieldTypes(String tableName, String databaseName) throws Throwable {
if (databaseName == null) {
databaseName = Configuration.getDatabaseName();
}
HashMap<String, Class> types = new HashMap<String, Class>();
Connection cn = null;
ResultSet rs = null;
DatabaseMetaData meta = null;
try {
cn = getConnection(databaseName, Configuration.getUsername(), Configuration.getPassword());
if ("oracle".equals(dbtype)) {
Statement stmt = cn.createStatement();
rs = stmt.executeQuery("SELECT * from "+tableName);
// Get the ResultSet meta data
OracleResultSetMetaData rmd = (OracleResultSetMetaData)rs.getMetaData(); // this is the line of the error
if (rmd == null) {
throw new RuntimeException("ResultSet meta data is not available for the Oracle table ["+tableName+"]");
}
else {
int columnCount = rmd.getColumnCount();
for(int i=1; i<=columnCount; i++) {
String name = rmd.getColumnName(i).toLowerCase();
int type = rmd.getColumnType(i);
setType(types, name, type);
}
}
}
The only difference between the environments (from a code perspective) is how a database connection is obtained. The following shows that code (the difference is detected by a properties file container entry)
Connection conn = null;
DataSource ds = null;
if (LanguageHelper.allMATCH) {
conn = APIWrapper.getConnection(sDatabase);
}
else {
conn = APIWrapper.getConnection();
}
if (conn != null) return conn;
Context ctx = new InitialContext();
ctx.addToEnvironment("SetBigStringTryClob", "true");
if (Configuration.getContainer().toLowerCase().equals("tomcat")) {
Context envContext = (Context)ctx.lookup("java:/comp/env");
ds = (DataSource)envContext.lookup("jdbc/" + sDatabase);
conn = ds.getConnection();
} else {
ds = (DataSource)ctx.lookup("jdbc/" + sDatabase);
conn = ds.getConnection(sUsername, sPassword);
}
Has anyone seen this type of issue before?
Sincerely,
Robert Jenkin
Surecomp Services, Inc.
2 Hudson Place, 4th Floor
Hoboken, NJ 07030
Skype: robert.jenkin
Office: 201 217 1437 | Direct: 201 716 1219 | Mobile: 908 251 0537
http://www.Surecomp.com
This mail was sent via Mail-SeCure System.
RE: Issue with oralce drive under tomcat 7
Posted by Ro...@surecomp.com.
Chuck,
Your are correct.. I removed the ojdbc6.jar from by app\lib folder and it worked. Thanks
Sincerely,
Robert Jenkin
Surecomp Services, Inc.
2 Hudson Place, 4th Floor
Hoboken, NJ 07030
Skype: robert.jenkin
Office: 201 217 1437 | Direct: 201 716 1219 | Mobile: 908 251 0537
http://www.Surecomp.com
-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
Sent: Tuesday, February 22, 2011 9:25 PM
To: Tomcat Users List
Subject: RE: Issue with oralce drive under tomcat 7
> From: Robert.Jenkin@surecomp.com [mailto:Robert.Jenkin@surecomp.com]
> Subject: Issue with oralce drive under tomcat 7
> Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetMetaData
> cannot be cast to oracle.jdbc.OracleResultSetMetaData
This is frequently caused by having the JDBC driver jar in more than one location. If you're using Tomcat's DBCP capability, the jar must be in Tomcat's lib directory - only. If you're doing your own connection pooling (or none at all), the jar should be in the webapp's WEB-INF/lib directory - only. Make sure the jar is not also in some other location, such as jre/lib, or the endorsed directory.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
This mail was sent via Mail-SeCure System.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Issue with oralce drive under tomcat 7
Posted by Ro...@surecomp.com.
We have classes for oracle, Microsoft, and db2 and each class is specific to the vendor. I have inherited the code. I also question why class name are different and why removing ojdbc6.jar from app\lib worked.
Sincerely,
Robert Jenkin
Surecomp Services, Inc.
2 Hudson Place, 4th Floor
Hoboken, NJ 07030
Skype: robert.jenkin
Office: 201 217 1437 | Direct: 201 716 1219 | Mobile: 908 251 0537
http://www.Surecomp.com
-----Original Message-----
From: Christopher Schultz [mailto:chris@christopherschultz.net]
Sent: Wednesday, February 23, 2011 6:15 PM
To: Tomcat Users List
Subject: Re: Issue with oralce drive under tomcat 7
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chuck,
On 2/22/2011 9:24 PM, Caldarale, Charles R wrote:
>> From: Robert.Jenkin@surecomp.com [mailto:Robert.Jenkin@surecomp.com]
>> Subject: Issue with oralce drive under tomcat 7
>
>> Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetMetaData
>> cannot be cast to oracle.jdbc.OracleResultSetMetaData
>
> This is frequently caused by having the JDBC driver jar in more than one location. If you're using Tomcat's DBCP capability, the jar must be in Tomcat's lib directory - only. If you're doing your own connection pooling (or none at all), the jar should be in the webapp's WEB-INF/lib directory - only. Make sure the jar is not also in some other location, such as jre/lib, or the endorsed directory.
Odd that the class names are different... and that your suggestion
worked. Copy/paste error?
Robert, may I ask why you were casting to an Oracle-specific interface
in the first place?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1llP8ACgkQ9CaO5/Lv0PAE0wCcCP0Bbq0GmdDJBeOG3Z6ksPoP
dHEAnj01yUcjYwrHqXYqo6RlZP3PQhwM
=vi8b
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
This mail was sent via Mail-SeCure System.
Re: Issue with oralce drive under tomcat 7
Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chuck,
On 2/22/2011 9:24 PM, Caldarale, Charles R wrote:
>> From: Robert.Jenkin@surecomp.com [mailto:Robert.Jenkin@surecomp.com]
>> Subject: Issue with oralce drive under tomcat 7
>
>> Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetMetaData
>> cannot be cast to oracle.jdbc.OracleResultSetMetaData
>
> This is frequently caused by having the JDBC driver jar in more than one location. If you're using Tomcat's DBCP capability, the jar must be in Tomcat's lib directory - only. If you're doing your own connection pooling (or none at all), the jar should be in the webapp's WEB-INF/lib directory - only. Make sure the jar is not also in some other location, such as jre/lib, or the endorsed directory.
Odd that the class names are different... and that your suggestion
worked. Copy/paste error?
Robert, may I ask why you were casting to an Oracle-specific interface
in the first place?
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk1llP8ACgkQ9CaO5/Lv0PAE0wCcCP0Bbq0GmdDJBeOG3Z6ksPoP
dHEAnj01yUcjYwrHqXYqo6RlZP3PQhwM
=vi8b
-----END PGP SIGNATURE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Issue with oralce drive under tomcat 7
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Robert.Jenkin@surecomp.com [mailto:Robert.Jenkin@surecomp.com]
> Subject: Issue with oralce drive under tomcat 7
> Caused by: java.lang.ClassCastException: oracle.jdbc.driver.OracleResultSetMetaData
> cannot be cast to oracle.jdbc.OracleResultSetMetaData
This is frequently caused by having the JDBC driver jar in more than one location. If you're using Tomcat's DBCP capability, the jar must be in Tomcat's lib directory - only. If you're doing your own connection pooling (or none at all), the jar should be in the webapp's WEB-INF/lib directory - only. Make sure the jar is not also in some other location, such as jre/lib, or the endorsed directory.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org