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.


Reply via email to