Re: setContextClassLoader error

169 views
Skip to first unread message

Mark Mandel

unread,
Aug 15, 2012, 6:36:59 PM8/15/12
to javaloa...@googlegroups.com
So everything passes with the unit tests with ColdFusion 10, so some more information on what you are doing would be useful.

What's your code look like? What's the full stack trace?

Can you dig into the code and see what the object is that it's failing on?

Is it a web based request, or something else?

More info please.

Mark

On Thu, Aug 16, 2012 at 7:49 AM, Raymond Camden <raymon...@gmail.com> wrote:
I'm using JL to wrap a call to Tika (seems like a popular topic ;) and discovered that I need to use switchThreadContextClassLoader. (Thanks Mark!) However, when I run it, I get:

The setContextClassLoader method was not found.

from line 139 of JavaLoader.cfc.

This is with CF10 on OSX.

--
You received this message because you are subscribed to the Google Groups "javaloader-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/javaloader-dev/-/B20gZkRwRd8J.
To post to this group, send email to javaloa...@googlegroups.com.
To unsubscribe from this group, send email to javaloader-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javaloader-dev?hl=en.



--
E: mark....@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast

Raymond Camden

unread,
Aug 15, 2012, 9:25:59 PM8/15/12
to javaloa...@googlegroups.com
Code is pretty simple - https://gist.github.com/3365332

Stack trace:
coldfusion.runtime.java.MethodSelectionException: The setContextClassLoader method was not found. at coldfusion.runtime.java.ObjectHandler.findMethodUsingCFMLRules(ObjectHandler.java:383) at coldfusion.runtime.StructBean.invoke(StructBean.java:524) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2465) at cfJavaLoader2ecfc773555732$funcSWITCHTHREADCONTEXTCLASSLOADER.runFunction(/Users/ray/Dropbox/websites/testingzone/getallthetexts/getallthetexts/javaloader/JavaLoader.cfc:139) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47) at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:655) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:444) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:414) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2432) at cftextextractor2ecfc1387623139$funcREAD.runFunction(/Users/ray/Dropbox/websites/testingzone/getallthetexts/getallthetexts/textextractor.cfc:33) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472) at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368) at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55) at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321) at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:655) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:444) at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:414) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2432) at cftest12ecfm1103899929.runPage(/Users/ray/Dropbox/websites/testingzone/getallthetexts/test1.cfm:16) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:244) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:444) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.IpFilter.invoke(IpFilter.java:64) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:422) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:112) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:94) 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:204) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:414) at org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:203) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:298) 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:680)

Raymond Camden

unread,
Aug 15, 2012, 9:32:53 PM8/15/12
to javaloa...@googlegroups.com
Ok, I switched to the dev branch of JavaLoader and I'm getting something new. Now when doParse is run, 

public function doParse(filename) {
          // grab a new instance of tika
          var tika = variables.javaloader.create("org.apache.tika.Tika").init();
  
          // parse the file
          var returnValue = tika.parseToString(createObject("java","java.io.File").init(arguments.filename));
  
          // return the parsed string
          return returnValue;
  
}

I'm told javaloader isn't in the variables scope. I did a quick dump of variables, and it appears as if variables==javaloader. Is that expected?

Raymond Camden

unread,
Aug 15, 2012, 9:35:50 PM8/15/12
to javaloa...@googlegroups.com
So when I rewrite doParse to assume JavaLoader's methods are local, it works. Everything works. But is it expected?

Mark Mandel

unread,
Aug 15, 2012, 10:44:38 PM8/15/12
to javaloa...@googlegroups.com
It's not going to work, as the way you have written it passes the function object through, which doesn't know about the variables scope you are accessing (class functions don't retain context when they are passed. They aren't closures).

I would suggest:

Or you could even use a mixin approach.

Mark

--
You received this message because you are subscribed to the Google Groups "javaloader-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/javaloader-dev/-/ag36WQTjdnUJ.

To post to this group, send email to javaloa...@googlegroups.com.
To unsubscribe from this group, send email to javaloader-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/javaloader-dev?hl=en.

Mark Mandel

unread,
Aug 15, 2012, 10:45:45 PM8/15/12
to javaloa...@googlegroups.com
That explains the error. You were overwriting the ClassLoader with a struct.

Mark


On Thu, Aug 16, 2012 at 11:32 AM, Raymond Camden <raymon...@gmail.com> wrote:
Ok, I switched to the dev branch of JavaLoader and I'm getting something new



Mark Mandel

unread,
Aug 15, 2012, 10:46:21 PM8/15/12
to javaloa...@googlegroups.com
Dumb question - how come you aren't using CF10's build in Java Loading?

Mark

Raymond Camden

unread,
Aug 16, 2012, 6:40:40 AM8/16/12
to javaloa...@googlegroups.com
The code was written to -maybe- run in CF9 too, and correct me if I'm wrong, the only way to replicate javaloader in CF10 is via an application setting. This code was meant to be a component that could be shared.
Message has been deleted

Mark Mandel

unread,
Aug 16, 2012, 6:59:08 PM8/16/12
to javaloa...@googlegroups.com
Fair enough :) Figured I would ask, was just curious.

I assume all working now?

Mark


On Thu, Aug 16, 2012 at 8:40 PM, Raymond Camden <raymon...@gmail.com> wrote:
The code was written to -maybe- run in CF9 too, and correct me if I'm wrong, the only way to replicate javaloader in CF10 is via an application setting. This code was meant to be a component that could be shared.



Jeff Coughlin

unread,
Aug 17, 2012, 8:18:17 PM8/17/12
to javaloa...@googlegroups.com
We tried that last year, but still ran into issues. I gave Ray a workaround that works, but I'd be interested to try your approach since its not as much a cheap way out... Maybe it'll work for me.  Any tips?

--
Jeff Coughlin

On Aug 17, 2012, at 19:57, Luis Majano <lma...@gmail.com> wrote:

Ray, did you get it to work.

I actually discovered in my setup that Tika ships with an old copy of SL4j that conflicts with what solrj or what is on CF.  I had to actually remove the old SL4J pacakage from TIKA in order to get it to parse correctly.


On Wednesday, August 15, 2012 2:49:24 PM UTC-7, Raymond Camden wrote:
I'm using JL to wrap a call to Tika (seems like a popular topic ;) and discovered that I need to use switchThreadContextClassLoader. (Thanks Mark!) However, when I run it, I get:

The setContextClassLoader method was not found.

from line 139 of JavaLoader.cfc.

This is with CF10 on OSX.

--
You received this message because you are subscribed to the Google Groups "javaloader-dev" group.
To view this discussion on the web visit https://groups.google.com/d/msg/javaloader-dev/-/67nywEArw5oJ.

Andrew Myers

unread,
Aug 18, 2012, 1:24:04 AM8/18/12
to javaloa...@googlegroups.com, javaloa...@googlegroups.com
Not sure of its any help, but in my github account (am2605) I have a modified version of javaloader that creates a loader that has a completely clean classpath.  It was the only way I could get our internal libraries to load from cf (it uses spring and mybatis which in turn had some dependencies that I couldn't get to resolve, even with the tccl).

If you're stuck, check it out.  I haven't documented how it works, but give me a shout if you want me to run you though it.

Andrew

Sent from my mobile
Reply all
Reply to author
Forward
0 new messages