Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Oops: sry...@srv:~$ java -version java version 1.5.0 gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. sry...@srv:~$ which java /usr/bin/java sry...@srv:~$ OK, I think I see the problem. I contracted out the construction of this server. I need to replace the java install with the Sun version. Do you agree? - Original Message - From: Bob Hall rfha...@yahoo.com To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, January 26, 2010 1:47 AM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource Steve, --- On Mon, 1/25/10 at 10:50 PM, Steve Ryder sry...@jsrsys.com wrote: I understand what you mean by don't use, but I am not using it. What do I need to change so that it is not used? How might I track down the offending library? What do you get when you type the following commands: $ java -version $ which java - Bob - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
From: Steve Ryder [mailto:sry...@jsrsys.com] Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource Oops: sry...@srv:~$ java -version java version 1.5.0 gij (GNU libgcj) version 4.2.3 (Ubuntu 4.2.3-2ubuntu6) A very big oops. I need to replace the java install with the Sun version. Correct; replace the toy JVM with a real one. - 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
RE: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
From: Steve Ryder [mailto:sry...@jsrsys.com] Subject: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource factory=org.apache.commons.dbcp.BasicDataSourceFactory The specified factory is for the standard Apache commons DBCP, not the one bundled with Tomcat. You might try removing it and let the Tomcat DBCP factory do its thing. My jdbc driver jar is: mysql-connector-java-5.0.8-bin.jar Where is the JDBC jar located? Since you're upgrading, why not upgrade to 6.0.x? (5.5 is not getting much in the way of active development these days.) - 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
When I remove the factory line I now get: Cannot create resource instance 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance 2010-01-25 15:56:06:Driver=com.mysql.jdbc.Driver The libraries are all in common\lib. The ones I have added since the 5.5 install are: jsrweb (my Java code), mysql-connector-java-5.0.8-bin.jar, naming-common.jar, naming-java.jar, mail.jar, and activation.jar. I picked 5.5 because it is not getting active develpment, yet supports Java 1.5, and has all the features I need hoping to minimize incompatabilities. My Java connect code reads: (indentation was lost when I copied) private void connect(String dbName) { lastException = OK; try { // Class.forName(org.gjt.mm.mysql.Driver); ---I changed this last night hoping to fix problem. sysout.display(Driver=com.mysql.jdbc.Driver); Class.forName(com.mysql.jdbc.Driver); } catch (Exception E) {lastException= Unable to load driver; E.printStackTrace(); sysout.display(lastException);} try { sql = Connection to jdbc/MySql:; Context myContext = new InitialContext(); Context envContext = (Context)myContext.lookup(java:comp/env); javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); conn = ds.getConnection(); stmt = conn.createStatement(); sql = USE + dbName; // attempt to mymic jdbcConnect set for dbName! stmt.execute(sql); sysout.display(**+sql + : connection to jdbc/MySql established.); } catch (SQLException E) { lastException=*WARNING*+sql+ : connect SQL exception: + E.getMessage(); sysout.display(lastException); //System.exit(4); } catch(Exception eOther) { lastException=*WARNING*+sql+ : connect Other exception: + eOther.getMessage(); sysout.display(lastException); //System.exit(4); } } - Original Message - From: Caldarale, Charles R chuck.caldar...@unisys.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 8:52 AM Subject: RE: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource From: Steve Ryder [mailto:sry...@jsrsys.com] Subject: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource factory=org.apache.commons.dbcp.BasicDataSourceFactory The specified factory is for the standard Apache commons DBCP, not the one bundled with Tomcat. You might try removing it and let the Tomcat DBCP factory do its thing. My jdbc driver jar is: mysql-connector-java-5.0.8-bin.jar Where is the JDBC jar located? Since you're upgrading, why not upgrade to 6.0.x? (5.5 is not getting much in the way of active development these days.) - 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Some more testing... I added displays before each of the connect statements. I get (still with no factory): 2010-01-25 16:27:07:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance 2010-01-25 16:27:07:JsrSQL: Context cast successfull 2010-01-25 16:27:07:Driver=com.mysql.jdbc.Driver which tells me the failure is on the DataSource cast statement. I then added factory back in and got: 2010-01-25 16:35:01:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 16:35:01:JsrSQL: Context cast successfull 2010-01-25 16:35:01:Driver=com.mysql.jdbc.Driver So, failure is in same place with factory, but a different error. I appreciate your suggestions, and look forward to other things I might need to change. - Original Message - From: Caldarale, Charles R chuck.caldar...@unisys.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 8:52 AM Subject: RE: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource From: Steve Ryder [mailto:sry...@jsrsys.com] Subject: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource factory=org.apache.commons.dbcp.BasicDataSourceFactory The specified factory is for the standard Apache commons DBCP, not the one bundled with Tomcat. You might try removing it and let the Tomcat DBCP factory do its thing. My jdbc driver jar is: mysql-connector-java-5.0.8-bin.jar Where is the JDBC jar located? Since you're upgrading, why not upgrade to 6.0.x? (5.5 is not getting much in the way of active development these days.) - 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-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve, On 1/25/2010 11:16 AM, Steve Ryder wrote: When I remove the factory line I now get: Cannot create resource instance 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance Ok. The libraries are all in common\lib. The ones I have added since the 5.5 install are: jsrweb (my Java code), mysql-connector-java-5.0.8-bin.jar, naming-common.jar, naming-java.jar, mail.jar, and activation.jar. I picked 5.5 because it is not getting active develpment, yet supports Java 1.5, and has all the features I need hoping to minimize incompatabilities. Fair enough. My Java connect code reads: (indentation was lost when I copied) private void connect(String dbName) { lastException = OK; try { // Class.forName(org.gjt.mm.mysql.Driver); ---I changed this last night hoping to fix problem. sysout.display(Driver=com.mysql.jdbc.Driver); Class.forName(com.mysql.jdbc.Driver); } catch (Exception E) {lastException= Unable to load driver; E.printStackTrace(); You don't need any of the above if you are using a connection pool: the pool will register the driver for you. sysout.display(lastException);} What does this print, including the stack trace from the catch block? try { sql = Connection to jdbc/MySql:; Context myContext = new InitialContext(); Context envContext = (Context)myContext.lookup(java:comp/env); Ok. javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); conn = ds.getConnection(); stmt = conn.createStatement(); Ok. sql = USE + dbName; // attempt to mymic jdbcConnect set for dbName! stmt.execute(sql); This is not necessary as you have already selected your db via the connection URL. catch (SQLException E) { lastException=*WARNING*+sql+ : connect SQL exception: + E.getMessage(); sysout.display(lastException); //System.exit(4); } catch(Exception eOther) { lastException=*WARNING*+sql+ : connect Other exception: + eOther.getMessage(); sysout.display(lastException); //System.exit(4); } So, the above is the source of the error message which has all your extra stuff like *WARNING*Connection to jdbc/MySql:: connect SQL exception: plus the message from the real exception. I don't recognize Cannot create resource instance so it would be helpful to show the full stack trace and the real exception that caused the message to print. I would recommend not catching Exception unless there is a good reason to do so: allow the exception to propagate up the stack to a place where it can be appropriately caught and dealt with, or at least logged properly. What happens when this code fails and the conn member isn't set properly? I'm guessing you either get NullPointerExceptions later in your code, or you have to have a bunch of null checking in your query code which is kind of ugly. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAktd3f0ACgkQ9CaO5/Lv0PD6CgCXWjgZIBoBQrgS7ciU7Y4L8TGt TQCbBC+bDwqmlEgAeiCXp/PdeweDFWM= =aaxM -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Starting from the bottom up of your suggestions: 1) I tried removing the try/catch. No can do, Java compiler forces me to catch the exceptions. 2) However, Java does provide a getStackTrace. There were 33 elements, but since pages that don't try to connect ARE working I think only the below apply: 2010-01-25 19:37:09:Stack(5)javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 2010-01-25 19:37:09:Stack(4)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 19:37:09:Stack(3)org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 19:37:09:Stack(2)com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 19:37:09:Stack(1)com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 19:37:09:Stack(0)com.jsrsys.web.JsrSQL.connect(JsrSQL.java:503) 2010-01-25 19:37:09:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 19:37:09:JsrSQL: Context cast successfull 2010-01-25 19:37:09:Driver=com.mysql.jdbc.Driver Not much help here, but it is very good to be able to print the trace when debugging so glad I was able to learn how. I am now going to remove the Class.forName code and see if that changes any thing. - Original Message - From: Christopher Schultz ch...@christopherschultz.net To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 12:07 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve, On 1/25/2010 11:16 AM, Steve Ryder wrote: When I remove the factory line I now get: Cannot create resource instance 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance Ok. The libraries are all in common\lib. The ones I have added since the 5.5 install are: jsrweb (my Java code), mysql-connector-java-5.0.8-bin.jar, naming-common.jar, naming-java.jar, mail.jar, and activation.jar. I picked 5.5 because it is not getting active develpment, yet supports Java 1.5, and has all the features I need hoping to minimize incompatabilities. Fair enough. My Java connect code reads: (indentation was lost when I copied) private void connect(String dbName) { lastException = OK; try { // Class.forName(org.gjt.mm.mysql.Driver); ---I changed this last night hoping to fix problem. sysout.display(Driver=com.mysql.jdbc.Driver); Class.forName(com.mysql.jdbc.Driver); } catch (Exception E) {lastException= Unable to load driver; E.printStackTrace(); You don't need any of the above if you are using a connection pool: the pool will register the driver for you. sysout.display(lastException);} What does this print, including the stack trace from the catch block? try { sql = Connection to jdbc/MySql:; Context myContext = new InitialContext(); Context envContext = (Context)myContext.lookup(java:comp/env); Ok. javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); conn = ds.getConnection(); stmt = conn.createStatement(); Ok. sql = USE + dbName; // attempt to mymic jdbcConnect set for dbName! stmt.execute(sql); This is not necessary as you have already selected your db via the connection URL. catch (SQLException E) { lastException=*WARNING*+sql+ : connect SQL exception: + E.getMessage(); sysout.display(lastException); //System.exit(4); } catch(Exception eOther) { lastException=*WARNING*+sql+ : connect Other exception: + eOther.getMessage(); sysout.display(lastException); //System.exit(4); } So, the above is the source of the error message which has all your extra stuff like *WARNING*Connection to jdbc/MySql:: connect SQL exception: plus the message from the real exception. I don't recognize Cannot create resource instance so it would be helpful to show the full stack trace and the real exception that caused the message to print. I would recommend not catching Exception unless there is a good reason to do so: allow the exception to propagate up the stack to a place where it can be appropriately caught and dealt with, or at least logged properly. What happens when this code fails and the conn member isn't set properly? I'm guessing you either get NullPointerExceptions later in your code, or you have to have a bunch of null checking in your query code which is kind of ugly. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEUEARECAAYFAktd3f0ACgkQ9CaO5/Lv0PD6CgCXWjgZIBoBQrgS7ciU7Y4L8TGt TQCbBC+bDwqmlEgAeiCXp/PdeweDFWM= =aaxM -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Removing the Class.forName code did not change anything, I still get the same error. 2010-01-25 20:00:03:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 20:00:03:Stack(4)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 20:00:03:Stack(3)=org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 20:00:03:Stack(2)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 20:00:03:Stack(1)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 20:00:03:Stack(0)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:504) 2010-01-25 20:00:03:JsrSQL: Context cast successfull I have now changed my stack trace display code to stop when it hits the org.apache.jasper... code. - Original Message - From: Christopher Schultz ch...@christopherschultz.net To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 12:07 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve, On 1/25/2010 2:56 PM, Steve Ryder wrote: Starting from the bottom up of your suggestions: 1) I tried removing the try/catch. No can do, Java compiler forces me to catch the exceptions. Hmm... what method is declared as throwing Exception instead of something more specific? 2) However, Java does provide a getStackTrace. Throwable.printStackTrace() will also do the trick. 2010-01-25 19:37:09:Stack(5)javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 2010-01-25 19:37:09:Stack(4)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 19:37:09:Stack(3)org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 19:37:09:Stack(2)com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 19:37:09:Stack(1)com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 19:37:09:Stack(0)com.jsrsys.web.JsrSQL.connect(JsrSQL.java:503) Is this the code you posted earlier? If so, which line is 503? 2010-01-25 19:37:09:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource This isn't the error message you posted earlier. The one you posted earlier was: 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance Removing the Class.forName code did not change anything, I still get the same error. Right: the Class.forName simply wasn't necessary... I didn't expect it to change anything. 2010-01-25 20:00:03:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 20:00:03:Stack(4)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 20:00:03:Stack(3)=org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 20:00:03:Stack(2)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 20:00:03:Stack(1)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 20:00:03:Stack(0)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:504) 2010-01-25 20:00:03:JsrSQL: Context cast successfull Could you re-post the whole method? The object you get from the JNDI context really /should/ be a javax.sql.DataSource object, not a ResourceLink. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkteAdMACgkQ9CaO5/Lv0PAm7wCfSWyuzVUbJ1zXqaruicFBoUnS R6wAn3JGjRZ7uMS5uf1tR8utZ7oWnzpT =ymR0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
2010/1/25 Steve Ryder sry...@jsrsys.com: Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource The above should be javax.sql.DataSource Do you have any references to this resource in your web.xml file? Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Sequence of events: 1) With factory got cast error. 2) Took out factory= and got Cannot create resource instance 3) Put factory statement back in. Is there a different one I should try? The cast exception is Thrown by this line javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); in the connect method. Here is the whole method as of the last test: /** * called by setDataBaseName */ private void connect(String dbName) { lastException = OK; /* don't need this if have connection pools try { // Class.forName(org.gjt.mm.mysql.Driver); sysout.display(Driver=com.mysql.jdbc.Driver); Class.forName(com.mysql.jdbc.Driver); } catch (Exception E) {lastException= Unable to load driver; E.printStackTrace(); sysout.display(lastException);} */ try { sql = Connection to jdbc/MySql:; Context myContext = new InitialContext(); Context envContext = (Context)myContext.lookup(java:comp/env); sysout.display(JsrSQL: Context cast successfull); javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); sysout.display(JsrSQL: DataSource cast successfull); conn = ds.getConnection(); sysout.display(JsrSQL: conn = ds successfull); stmt = conn.createStatement(); sql = USE + dbName; // attempt to mymic jdbcConnect set for dbName! stmt.execute(sql); sysout.display(**+sql + : connection to jdbc/MySql established.); } catch (SQLException E) { lastException=*WARNING*+sql+ : connect SQL exception: + E.getMessage(); sysout.display(lastException); } catch(Exception eOther) { StackTraceElement[] stack = eOther.getStackTrace(); for (int s=0; s stack.length; s++) { lastException = Stack(+s+)= + stack[s]; sysout.display(lastException); if (lastException.indexOf(org.apache.jasper) -1) break; } lastException=*WARNING*+sql+ : connect Other exception: + eOther.getMessage(); sysout.display(lastException); } } - Original Message - From: Christopher Schultz ch...@christopherschultz.net To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 2:40 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve, On 1/25/2010 2:56 PM, Steve Ryder wrote: Starting from the bottom up of your suggestions: 1) I tried removing the try/catch. No can do, Java compiler forces me to catch the exceptions. Hmm... what method is declared as throwing Exception instead of something more specific? 2) However, Java does provide a getStackTrace. Throwable.printStackTrace() will also do the trick. 2010-01-25 19:37:09:Stack(5)javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 2010-01-25 19:37:09:Stack(4)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 19:37:09:Stack(3)org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 19:37:09:Stack(2)com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 19:37:09:Stack(1)com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 19:37:09:Stack(0)com.jsrsys.web.JsrSQL.connect(JsrSQL.java:503) Is this the code you posted earlier? If so, which line is 503? 2010-01-25 19:37:09:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource This isn't the error message you posted earlier. The one you posted earlier was: 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance Removing the Class.forName code did not change anything, I still get the same error. Right: the Class.forName simply wasn't necessary... I didn't expect it to change anything. 2010-01-25 20:00:03:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 20:00:03:Stack(4)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 20:00:03:Stack(3)=org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 20:00:03:Stack(2)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 20:00:03:Stack(1)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 20:00:03:Stack(0)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:504) 2010-01-25 20:00:03:JsrSQL: Context cast successfull Could you re-post the whole method? The object you get from the JNDI context really /should/ be a javax.sql.DataSource object, not a ResourceLink. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkteAdMACgkQ9CaO5/Lv0PAm7wCfSWyuzVUbJ1zXqaruicFBoUnS R6wAn3JGjRZ7uMS5uf1tR8utZ7oWnzpT =ymR0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
OK, I took factory out of context.xml, now I get Resource Instance again, but this time I have the trace! 2010-01-26 05:11:30:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance 2010-01-26 05:11:30:Stack(10)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-26 05:11:30:Stack(9)=org.apache.jsp.AppList_jsp._jspService(AppList_jsp.java:157) 2010-01-26 05:11:30:Stack(8)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-26 05:11:30:Stack(7)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-26 05:11:30:Stack(6)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:504) 2010-01-26 05:11:30:Stack(5)=org.apache.naming.NamingContext.lookup(NamingContext.java:153) 2010-01-26 05:11:30:Stack(4)=org.apache.naming.NamingContext.lookup(NamingContext.java:781) 2010-01-26 05:11:30:Stack(3)=org.apache.naming.NamingContext.lookup(NamingContext.java:140) 2010-01-26 05:11:30:Stack(2)=org.apache.naming.NamingContext.lookup(NamingContext.java:793) 2010-01-26 05:11:30:Stack(1)=javax.naming.spi.NamingManager.getObjectInstance(libgcj.so.81) 2010-01-26 05:11:30:Stack(0)=org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143) 2010-01-26 05:11:30:JsrSQL: Context cast successfull line 504 is the middle line of: 503 get's executed (see above): sysout.display(JsrSQL: Context cast successfull); 504 throws exception: javax.sql.DataSource ds = (javax.sql.DataSource)envContext.lookup(jdbc/MySql); 505 never gets here: sysout.display(JsrSQL: DataSource cast successfull); - Original Message - From: Christopher Schultz ch...@christopherschultz.net To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 2:40 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Steve, On 1/25/2010 2:56 PM, Steve Ryder wrote: Starting from the bottom up of your suggestions: 1) I tried removing the try/catch. No can do, Java compiler forces me to catch the exceptions. Hmm... what method is declared as throwing Exception instead of something more specific? 2) However, Java does provide a getStackTrace. Throwable.printStackTrace() will also do the trick. 2010-01-25 19:37:09:Stack(5)javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 2010-01-25 19:37:09:Stack(4)org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 19:37:09:Stack(3)org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 19:37:09:Stack(2)com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 19:37:09:Stack(1)com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 19:37:09:Stack(0)com.jsrsys.web.JsrSQL.connect(JsrSQL.java:503) Is this the code you posted earlier? If so, which line is 503? 2010-01-25 19:37:09:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource This isn't the error message you posted earlier. The one you posted earlier was: 2010-01-25 15:56:06:*WARNING*Connection to jdbc/MySql:: connect Other exception: Cannot create resource instance Removing the Class.forName code did not change anything, I still get the same error. Right: the Class.forName simply wasn't necessary... I didn't expect it to change anything. 2010-01-25 20:00:03:*WARNING*Connection to jdbc/MySql:: connect Other exception: org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010-01-25 20:00:03:Stack(4)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-25 20:00:03:Stack(3)=org.apache.jsp.index_jsp._jspService(index_jsp.java:89) 2010-01-25 20:00:03:Stack(2)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-25 20:00:03:Stack(1)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-25 20:00:03:Stack(0)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:504) 2010-01-25 20:00:03:JsrSQL: Context cast successfull Could you re-post the whole method? The object you get from the JNDI context really /should/ be a javax.sql.DataSource object, not a ResourceLink. - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkteAdMACgkQ9CaO5/Lv0PAm7wCfSWyuzVUbJ1zXqaruicFBoUnS R6wAn3JGjRZ7uMS5uf1tR8utZ7oWnzpT =ymR0 -END PGP SIGNATURE- - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
- From: Konstantin Kolinko knst.koli...@gmail.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 3:14 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010/1/25 Steve Ryder sry...@jsrsys.com: Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource The above should be javax.sql.DataSource Do you have any references to this resource in your web.xml file? Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
(Http11Processor.java:874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(libgcj.so.81) ** END NESTED EXCEPTION ** Attempted reconnect 3 times. Giving up.) 2010-01-26 05:38:29:Stack(6)=org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98) 2010-01-26 05:38:29:Stack(5)=org.apache.jsp.AppList_jsp._jspService(AppList_jsp.java:157) 2010-01-26 05:38:29:Stack(4)=com.jsrsys.web.JsrSQL.(JsrSQL.java:42) 2010-01-26 05:38:29:Stack(3)=com.jsrsys.web.JsrSQL.setDataBaseName(JsrSQL.java:86) 2010-01-26 05:38:29:Stack(2)=com.jsrsys.web.JsrSQL.connect(JsrSQL.java:506) 2010-01-26 05:38:29:Stack(1)=org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) 2010-01-26 05:38:29:Stack(0)=org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1225) 2010-01-26 05:38:24:JsrSQL: DataSource cast successfull 2010-01-26 05:38:24:JsrSQL: Context cast successfull - Original Message - From: Konstantin Kolinko knst.koli...@gmail.com To: Tomcat Users List users@tomcat.apache.org Sent: Monday, January 25, 2010 3:14 PM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010/1/25 Steve Ryder sry...@jsrsys.com: Resource name=jdbc/MySql auth=Container type=javax.sql.Datasource The above should be javax.sql.DataSource Do you have any references to this resource in your web.xml file? Best regards, Konstantin Kolinko - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
2010/1/26 Steve Ryder sry...@jsrsys.com: at gnu.gcj.convert.Input_iconv.read(libgcj.so.81) Stop right there. Do not use GNU Java for anything. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
I understand what you mean by don't use, but I am not using it. What do I need to change so that it is not used? How might I track down the offending library? - Original Message - From: Konstantin Kolinko knst.koli...@gmail.com To: Tomcat Users List users@tomcat.apache.org Sent: Tuesday, January 26, 2010 12:29 AM Subject: Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource 2010/1/26 Steve Ryder sry...@jsrsys.com: at gnu.gcj.convert.Input_iconv.read(libgcj.so.81) Stop right there. Do not use GNU Java for anything. - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org
Re: Tomcat 5.5 org.apache.naming.ResourceRef cannot be cast to javax.sql.DataSource
Steve, --- On Mon, 1/25/10 at 10:50 PM, Steve Ryder sry...@jsrsys.com wrote: I understand what you mean by don't use, but I am not using it. What do I need to change so that it is not used? How might I track down the offending library? What do you get when you type the following commands: $ java -version $ which java - Bob - To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org