Java cast errors in JDBC code after installing FR5

103 views
Skip to first unread message

Tom Chiverton

unread,
Aug 27, 2013, 5:42:22 AM8/27/13
to fusion...@googlegroups.com
Hi, we've got some Java code that runs it's own JDBC queries.
It's loaded as a .jar dropped into the ColdFusion lib folder, and the ColdFusion code then createObject()'s it.
This was all fine with FR4, but it throws a funny error under FR5.

The error is "com.intergral.fusionreactor.jdbc.ResultSetSurrogate cannot be cast to com.inet.tds.j"
I'm fairly sure the error isn't truncated there, but I'm trying to make a stand alone test file as we speak :-)

Don't suppose anyone else has seen this ?

The code is calling 'execute( getConn() )' on a CachedRowSet.
getConn() just does

    Class.forName("com.inet.tds.TdsDriver");

and then returns

   DriverManager.getConnection("jdbc:inetdae7:" + dbServerString + ":nnnn", "xxx", "yyyy");

I assume this is related to the automatic JDBC wrapping FR5 does ?
Disabling various JDBC related options in FR didn't seem to resolve the issue, so we've had to disable FR5 for now (by removing the -javaagent JVM argument).

Is there anyway to have FR5 skip JDBC wrapping ? I didn't see a JVM startup argument for it, for instance.

Tom

Tom Chiverton

unread,
Aug 27, 2013, 6:20:54 AM8/27/13
to fusion...@googlegroups.com
Update: Here is some ColdFusion code that attempts to create a JDBC connection :

<cfset driverManager=createObject('java','java.sql.DriverManager')/>
<cfset conn=driverManager.getConnection("jdbc:inetdae7:a.b.c.d", "xxx", "yyy")/>
<cfset crs=createObject('java','com.inet.tds.CachedRowSet')/>

<cfset crs.setCommand("select top 1 * from foo")/>
<cfset res=crs.execute( conn ) />

With FR5 loaded, this throws the ClassCastException, the full stack is below. Line 12 is the crs.execute(...) as I stripped out some CFDump above. The CFDumps confirm that the conn object changes from a com.inet.tds.a to com.intergral.fusionreactor.jdbc.ConnectionSurrogate :-/
This is with the 1.7 JDK, CF9.0.1.

Is this some issue in the MSSQL JDBC drivers ?

java.lang.ClassCastException: com.intergral.fusionreactor.jdbc.ResultSetSurrogate cannot be cast to com.inet.tds.j at com.inet.tds.CachedRowSet.execute(Unknown Source) at com.inet.tds.CachedRowSet.execute(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at coldfusion.runtime.java.JavaProxy.invoke(JavaProxy.java:97) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cft2ecfm470451646.runPage(/wwwroot/development/OpensTracking/webroot/t.cfm:12) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:378) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:94) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:62) at coldfusion.CfmServlet.service(CfmServlet.java:201) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:96) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doNext(FusionReactorRequestHandler.java:350) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doHttpServletRequest(FusionReactorRequestHandler.java:224) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doFusionRequest(FusionReactorRequestHandler.java:153) at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.handle(FusionReactorRequestHandler.java:385) at com.intergral.fusionreactor.j2ee.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:36) at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:78) at sun.reflect.GeneratedMethodAccessor84.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at com.intergral.fusionreactor.agent.filter.FusionReactorStaticFilter.doFilter(FusionReactorStaticFilter.java:53) at com.intergral.fusionreactor.agent.pointcuts.NewFilterChainPointCut$1.invoke(NewFilterChainPointCut.java:41) at jrun.servlet.FilterChain.doFilter(FilterChain.java) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

Tom

David Stockton

unread,
Aug 27, 2013, 6:31:41 AM8/27/13
to fusion...@googlegroups.com
Hello Tom,

The com.inet.tds classes contain an explicit class cast operation. This shouldn't be necessary but obviously we can't change i-net's code.
You can stop all JDBC monitoring for these classes by placing the attached file in the same location as your fusionreactor.jar file (typically /opt/fusionreactor/instances/<instance name> on *nix) and restarting ColdFusion. I'd note that you may prefer to use other drivers (eg JTDS or Microsoft's own) which may offer a) better performance and b) compatibility unless you have a specific reason not to.

Best regards,
David Stockton
Fusion Team


--
You received this message because you are subscribed to the Google Groups "FusionReactor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fusionreacto...@googlegroups.com.
To post to this group, send email to fusion...@googlegroups.com.
Visit this group at http://groups.google.com/group/fusionreactor.
For more options, visit https://groups.google.com/groups/opt_out.

fusionreactoragent.properties

Tom Chiverton

unread,
Aug 27, 2013, 7:36:09 AM8/27/13
to fusion...@googlegroups.com
Ahh ha, that makes sense; gotta love old code :-)

The file works a treat. Can I put comments in this (leading hash ?) to remind us why it's there ?
I'm sure you are already considering blacklisting these classes by default too...

Thanks again for the awesome response,
Tom

David Stockton

unread,
Aug 27, 2013, 9:49:09 AM8/27/13
to fusion...@googlegroups.com
Hello Tom,

You can also exclude individual datasources by adding "__fusionreactor_exclude=true" as a property to your JDBC URL. Note: Most use ";" as a delimiter but it's up to your JDBC driver what the delimiter is.
You can add comments to the file using # as the first character.

We aren't currently considering a blacklist because of the complexity involved in maintaining that (driver vendors could change their code but not the classname resulting in an outdated list).

Best regards,
David Stockton
Fusion Team

--

Tom Chiverton

unread,
Aug 28, 2013, 10:44:44 AM8/28/13
to fusion...@googlegroups.com
Oh, ta :-)

I saw the link in the docs about being able to take a whole ColdFusion DSN out of monitoring, but it'd take forever to go through all our data sources, even using the admin API.

Tom
Reply all
Reply to author
Forward
0 new messages