If you’ve ran into this error when consuming a web service in Open BlueDragon, this may help you. Here is what my error looked like:

BlueDragon Internal Server Error
The page you were executing caused an internal BlueDragon server error
Request /shared/rps/twitter.cfm
File Trace /www/twitter.cfm
Type     Internal
Tag Context     CFSET (/www/twitter.cfm, Line=10, Column=1)
Source
7 :
8 : <body>
9 :
10: <cfset wx = CreateObject("webservice","http://www.webservicex.net/WeatherForecast.asmx?WSDL")>
11: <cfdump var="#wx#">

^ Snippet from underlying CFML source

Stack Trace
java.lang.NoClassDefFoundError: sun/tools/javac/Main
	at com.naryx.tagfusion.cfm.xml.ws.dynws.WSDL2Java.compileOutput(Unknown Source)
	at com.naryx.tagfusion.cfm.xml.ws.dynws.DynamicWebServiceStubGenerator.buildClientClasses(Unknown Source)
	at com.naryx.tagfusion.cfm.xml.ws.dynws.DynamicWebServiceStubGenerator.generateStub(Unknown Source)
	at com.naryx.tagfusion.cfm.xml.ws.dynws.DynamicWebServiceInvoker.getStub(Unknown Source)
	at com.naryx.tagfusion.cfm.tag.cfINVOKE.prepareWSObjectData(Unknown Source)
	[snipped]
Caused by: java.lang.ClassNotFoundException: sun.tools.javac.Main
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
	... 37 more

This happened when deployed on Tomcat on JDK 1.6 but it can happen on any Java version and servlet container I think. I also had Adobe ColdFusion 8 deployed on this setup, and I got an error there when running the same code. The error from Adobe CF looked like:


The following information is meant for the website developer for debugging purposes.

Error Occurred While Processing Request

coldfusion.jsp.CompilationFailedException: Errors reported by Java compiler: /www/WEB-INF/cfusion/stubs/WS1167679061/net/webservicex/www/ArrayOfWeatherData.java:10: cannot access java.io.Serializable bad class file: /usr/java/jdk1.6.0_13/jre/lib/rt.jar(java/io/Serializable.class) class file has wrong version 49.0, should be 48.0 Please remove or make sure it appears in the correct subdirectory of the classpath. public class ArrayOfWeatherData implements java.io.Serializable {
^
1 error
.

 

Resources:
  • Enable Robust Exception Information to provide greater detail about the source of errors. In the Administrator, click Debugging & Logging > Debug Output Settings, and select the Robust Exception Information option.
  • Check the ColdFusion documentation to verify that you are using the correct syntax.
  • Search the Knowledge Base to find a solution to your problem.
Browser   Opera/9.62 (Windows NT 5.1; U; en) Presto/2.1.1
Remote Address   10.0.0.1
Referrer  
Date/Time   08-Jun-09 03:28 AM

The solution was to put the tools.jar file thats located in your installed JDK/lib directory into your CLASSPATH. I did this just by copying the file into Tomcat’s “lib” directory. You could also just copy the file to bluedragon’s WEB-INF/lib directory. This solved the problem in both OpenBD and Adobe CF8. I noticed that there was already a tools.jar file in my deployed CF8 directory at ./WEB-INF/cfusion/lib/tools.jar. I think thats why the Adobe CF error was different – it wasn’t complaining about a class not found like OpenBD, it was complaining about a “wrong version” problem. So I’m guessing the tools.jar file that Adobe includes isn’t compatible with Tomcat or with my JVM or something. Maybe thats why Open BlueDragon doesn’t include a tools.jar file in their distribution (it would also increase their file size by about 50%!)

When I asked about why this was needed on the OpenBD mailing this I got this response:

wsdl2java is used to generate Java stubs for the client and end point of
CFML based web services. This library generates java (not compiled) and
tools.jar contains the javac compiler, which is needed to compile the java
that wsdl2java spits out.

Interesting to note that Railo did not need this fix, they must be using a completely different method for consuming web services.

One Comment

  1. Martin says:

    Thanks so much for this! I have been ages wondering why my web application would not find the sun.tools.javac.Main on Tomcat and JDK 1.5 or 1.6, and adding the tools.jar to Tomcat/common/lib has sorted it! It’s Friday and I can relax knowing this issue is solved for Monday! THANKS!