Web Services Problems with ColdFusion 8 on a Mac
By Pete Freitag
I just got a brand new Mac Pro yesterday - I spent most of yesterday installing stuff, but today I was trying to get a little work done... I ran into a problem when trying to invoke web services on CF8 - it threw the following error:
coldfusion.jsp.JavaCompiler$UnknownCompiler: Unable to run the internal Java compiler: java.lang.NoClassDefFoundError: javax/tools/StandardJavaFileManager.
I setup the following test code using Doug Hughes' Fortune web service, to make sure it wasn't just the service I was trying to call:
<cfset ws = CreateObject("webservice", "http://www.doughughes.net/WebServices/fortune/fortune.cfc?wsdl")> <cfset f = ws.getTopicsList()> <cfdump var="#f#">
After searching google, all I could find were a few other people with the same problem and no solution. I found that the StandardJavaFileManager class (the one it can't find) is part of Java 6 - I was running Java 1.5, and I know that on Windows CF8 ships with Java 1.6. I pinged Sean Corfield to see if he had experienced these problems. He said, no but he is already running Java 6 (which helped me confirm that was indeed the problem). He also helped me figure out step 3.
Step 1 - Download & Install Java 6 for Mac
I downloaded the Java SE 6.0 Release 1 Developer Preview 6 from Sept. 2006, as it was the most current release as of this writing. You can download it from the Apple Developers Connection (ADC) which is free but requires a login.
Step 2 - Make Java 1.6 the default JDK for your Mac
To do this run the following:
cd /System/Library/Frameworks/JavaVM.framework/Versions sudo rm CurrentJDK sudo ln -s 1.6 CurrentJDK
To make sure it's working run the following:
./CurrentJDK/Home/bin/java -version
You should get something like this:
java version "1.6.0-dp" Java(TM) SE Runtime Environment (build 1.6.0-dp-b88-34)
Step 3 - Remove tools.jar
If you restart CF8 at this point your server will infact be running on Java 6, and this is good, but web services still throw an error, this time a different one. To fix you need to remove tools.jar
(make a backup of it and put it somewhere else, also you probably want to stop CF first). You can find it in CF8's WEB-INF/cfusion/lib
folder.
Finally just start or restart ColdFusion, and you should be able to invoke web services.
Web Services Problems with ColdFusion 8 on a Mac was first published on August 16, 2007.
If you like reading about coldfusion 8, mac, apple, web services, soap, java, java 6, or cf8 then you might also like:
- ColdFusion SOAP Web Services and onRequestStart
- Working with /etc/hosts on Mac
- PostalMethods - Web Service for Snail Mail
- CFImage Presentation Outline
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.
CFBreak
The weekly newsletter for the CFML Community
Comments
java -version
will show 1.6 after installing the developer preview but before changing the symbolic link. The DP changes the JRE - including the java binary - but doesn't change the JDK. JRun requests a JDK instance and gets the "old" 1.5 JDK (although Eclipse and other console Java apps will use 1.6 JDK).
A good way to check you got it right is to start ColdFusion from the console (e.g., ./jrun start cfusion) and JRun's console output will confirm the JDK version it picked up.
I'll also note that I did not need to remove tools.jar *after* fixing the JDK link (but I would have expected to need to remove it if I was running against Java 5).
But - I started CF, went to settings, and saw 1.6 there. So I'm assuming I'm good to go.
@Ray - DP stands for developer preview. Did you try running the web service example?
OS X 10.4.10
Java 1.5.0_07
Apache 2.2.4
JBoss 4.2.1
ColdFusion 8
I used the same code as above and ran without error. Are you using Jrun?
Damon
@Damon Good Point, but do you have any insight as to why I might have been getting that error (I'm not the only one search the web)
For localhost development, I would never recommend the JBoss route - and I've worked with JBoss in production systems quite a bit.
http://coldfused.blogspot.com/2007/08/coldfusion-and-webservice-file-has.html
If you want to use JDK1.5, you would need to replace lib/tools.jar with 1.5's tools.jar.
Anyways thanks for all the comments, I am using JRun in multi-server mode, and I am also connecting to Apache... I will have to give JBoss a try at some point as well.
The multiserver instance management built into CF is great - something you lose with JBoss.
Regarding your suggestion of installing appropriate version of tools.jar, thats not possible at all. For standalone CF, there is no issue because it is a complete install where we install JVM as well. Issue comes with J2EE installation where installer simply creates an ear or war which needs to be deployed on the J2ee server. We wouldnt know which J2EE server you are going to install it on and what version of JVM that server will run on.
And there hasn't been any change in JVM version or tools.jar or webservices between public beta and final version.
cfobject webservice="http://codex.corp.adobe.com/codex/codex.wsdl" name="wsObj"
(brackets omitted so I could post) and get the error: "java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)". I'm running on a MacBook Pro, 2.6 GHz Intel Core 2 Duo.
I'm beginning to suspect that jrun (or some other related software) thinks it's running on a Windows machine, as the only web references I can find mention ntvinv.dll. Any idea what might be going on?
Thanks,
Mark
Server Product ColdFusion
Version 8,0,1,195765
Edition Developer
Serial Number Developer
Operating System Mac OS X
OS Version 10.5.7
JVM Details
Java Version 1.6.0_07
Java Vendor Apple Inc.
Java Vendor URL http://www.apple.com/
Java Home /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
Java File Encoding MacRoman
Java Default Locale en_US
File Separator /
Path Separator :
Line Separator Chr(10)
User Name Mark
User Home /Users/Mark
User Dir /Applications/ColdFusion8/runtime/bin
Java VM Specification Version 1.0
Java VM Specification Vendor Sun Microsystems Inc.
Java VM Specification Name Java Virtual Machine Specification
Java VM Version 1.6.0_07-b06-57
Java VM Vendor Apple Inc.
Java VM Name Java HotSpot(TM) 64-Bit Server VM
Java Specification Version 1.6
Java Specification Vendor Sun Microsystems Inc.
Java Specification Name Java Platform API Specification
Java Class Version 50.0
Error starting modern compiler
at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:69)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:942)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:764)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:382)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.thunisoft.summer.web.filter.UserAASFilter.doFilter(UserAASFilter.java:77)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at com.thunisoft.summer.web.filter.CharsetFilter.doFilter(CharsetFilter.java:48)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:61)
... 41 more
Caused by: java.lang.NoClassDefFoundError: javax/tools/StandardJavaFileManager
sudo ln -s 1.6 CurrentJDK/
When I tried
sudo ln -s 1.6 CurrentJDK
it worked. But when I did java -version, I still got 1.5.x.