Flex Samples on Tomcat
Apr 1
I re-ghosted a Windows box today, so I decided to set up Macromedia Flex with Apache Tomcat. Shooting from the hip, I just unzipped the Flex samples.war file into Tomcat's webapps directory with all the other web applications. Initially excited to see if everything would just work right out of the box with no further configurations, I launched the Flex Samples Explorer application. The application compiled, and the main Explorer interface loaded. However, the Hello World mini-app, which is the first one to load by default, threw a pop-up alert for:
HTTPService Fault
Internal Server Error
A quick look at {Tomcat}/webapps/samples/WEB-INF/flex/logs/flex.log revealed a somewhat unhelpful message in the log because Flex debugging features were not enabled. The message, repeated once for every time I clicked on a mini-app in the Explorer, was:
ERROR %%500%%Internal Server Error
Well, I needed more to go on than that, so I stopped Tomcat, and edited the flex-config.xml file to turn all debugging features on, such as keep-generated-swfs, keep-generated-as, etc..., and I changed the log levels from INFO to DEBUG. Restarting Tomcat and requesting the Flex Explorer app had no effect on the initial problem, and of course I was again presented with the HTTPService Fault.
Another examination of the flex.log revealed a great deal of very useful information. Specifically, this message:
ERROR -- GET status: 500, reason: Internal Server Error, target: http://localhost:8080/samples/explorer/formatsource.jsp?url=quicktour/Hello.mxml
Ok, so the Explorer Hello World mini-app was trying to load the example source file in the source tab, and it was trying to use an HTTP call to a jsp to get that source. I copied the URL from the log and entered it in the browser. With all the debugging features turned on in flex-config.xml, I was presented with a very helpful error message and a stack trace. The error message went so far as to tell me *exactly* what the problem was, and *exactly* how to solve it. It turns out that Tomcat couldn't find a compiler for the jsp file, as shown in this Flex error message:
An unexpected error occurred that prevented /samples/explorer/formatsource.jsp from being displayed.
Unable to compile class for JSP No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path.
Technical Information: HTTP Status Code: 500 Exception Type: class org.apache.jasper.JasperException Servlet Name: jsp
Exception org.apache.jasper.JasperException Unable to compile class for JSP
No Java compiler was found to compile the generated source for the JSP. This can usually be solved by copying manually $JAVA_HOME/lib/tools.jar from the JDK to the common/lib directory of the Tomcat server, followed by a Tomcat restart. If using an alternate Java compiler, please check its installation and access path.
Following the instructions in the error message, I copied my {JAVA_HOME}/lib/tools.jar to {Tomcat}/common/lib/tools.jar. I restarted Tomcat, requested the Flex Examples application again, and voila everything worked like a champ. These verbose, debug error messages from Flex are going to make working with a J2EE application a whole lot easier!!
With the Flex Samples Explorer working now, an examination of flex.log showed great debug information about the GET request and response. Here's the complete GET request/response pair from Hello.mxml that was outputted to flex.log while flex-config.xml was configured for maximal debugging:
04/01 21:55:17 INFO -- GET : http://localhost:8080/samples/explorer/formatsource.jsp?url=data/WebServiceDemo.mxml
04/01 21:55:17 INFO -- Cookie in request: domain = localhost path = /samples name = JSESSIONID value = 57E43E5F8AF069706E5B3CD9FDE4B20E
04/01 21:55:17 INFO -- Header in request: accept : */*
04/01 21:55:17 INFO -- Header in request: x-flash-version : 7,0,19,0 04/01 21:55:17 INFO -- Header in request: content-type : application/x-www-form-urlencoded
04/01 21:55:17 INFO -- Header in request: flex-http-service : true
04/01 21:55:17 INFO -- Header in request: user-agent : Mozilla/4.0
04/01 21:55:17 INFO -- Header in request: connection : Keep-Alive
04/01 21:55:17 INFO -- Header in request: cache-control : no-cache
04/01 21:55:18 INFO -- Cookie in response: domain = localhost path = /samples name = JSESSIONID value = 57E43E5F8AF069706E5B3CD9FDE4B20E
04/01 21:55:18 INFO -- Header in response: Content-Type : text/html;charset=utf-8
04/01 21:55:18 INFO -- Header in response: Date : Fri, 02 Apr 2004 02:55:18 GMT
04/01 21:55:18 INFO -- Header in response: Server : Apache-Coyote/1.1
04/01 21:55:18 INFO -- Begin GET response --
04/01 21:55:18 INFO
{snip}The Hello.mxml source was here in the log{/snip}
04/01 21:55:19 DEBUG keep generated SWFs = true
04/01 21:55:19 INFO -- End GET response --
The Flex troubleshooting process is significantly facilitated by the wide range and depth of debug settings built into Flex.
Flex Debugging Resources:

#1 by Douglass Turner on 3/28/05 - 1:53 PM
Unfortunately all the links pointing to Macromedia are currently broken. Can you please point me to their current location. Thanks.
-Douglass
#2 by Steven Erat on 3/28/05 - 7:49 PM
#3 by joe on 7/1/05 - 12:29 AM
thanks for sharing
#4 by keshava on 12/7/05 - 4:18 PM
I am adding the log file details of both.
Works well
**********************************************
12/07 14:07:52 INFO -- GET : [a href="[a href="http://localhost:8700/samples/explorer/formatsourc...e.jsp?url=clientprofile/clientprofile.mxml" target="_blank">http://localhost:8700/samples/explorer/formatsourc......" target="_blank"]http://localhost:8700/samples/explorer/formatsourc......[/a]" target="_blank"]http://localhost:8700/samples/explorer/formatsourc......[/a]
12/07 14:07:52 INFO -- Cookie in request: domain = `localhost`, path = `/`, client name = `JSESSIONID`, endpoint name = `JSESSIONID`, value = `f030b19253e6I$A8$EDA`
12/07 14:07:52 INFO -- Header in request: Content-Type : application/x-www-form-urlencoded
12/07 14:07:52 INFO -- Header in request: User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
12/07 14:07:52 INFO -- Header in request: flex-http-service : true
12/07 14:07:52 INFO -- Header in request: Connection : Keep-Alive
12/07 14:07:52 INFO -- Header in request: Cache-Control : no-cache
12/07 14:07:52 INFO -- Header in request: x-flash-version : 8,0,22,0
12/07 14:07:52 INFO -- Header in request: Accept : */*
12/07 14:07:52 INFO -- Cookie in response: domain = `localhost`, path = `/`, client name = `JSESSIONID`, endpoint name = `JSESSIONID`, value = `f030b19253e6I$A8$EDA
12/07 14:07:52 INFO -- Header in response: Date : Wed, 07 Dec 2005 19:07:52 GMT
12/07 14:07:52 INFO -- Header in response: Content-Type : text/html; charset=utf-8
12/07 14:07:52 INFO -- Header in response: Server : JRun Web Server
12/07 14:07:52 INFO -- Begin GET response --
12/07 14:07:52 INFO
12/07 14:07:52 INFO -- End GET response --
12/07 14:07:52 INFO -- GET status: 200, reason: OK, target: http://localhost:8700/samples/explorer/formatsourc...e.jsp?url=clientprofile/clientprofile.mxml" target="_blank">http://localhost:8700/samples/explorer/formatsourc......
****************************************************
****************************************************
One with error (HTTPService fault: internal server error)
12/07 13:55:49 INFO -- GET : [a href="[a href="http://localhost:8700/samples/oag/oagsource.jsp?ur...l=clientprofile/clientprofile.mxml" target="_blank">http://localhost:8700/samples/oag/oagsource.jsp?ur......" target="_blank"]http://localhost:8700/samples/oag/oagsource.jsp?ur......[/a]" target="_blank"]http://localhost:8700/samples/oag/oagsource.jsp?ur......[/a]
12/07 13:55:49 INFO -- Cookie in request: domain = `localhost`, path = `/`, client name = `JSESSIONID`, endpoint name = `JSESSIONID`, value = `f030b19253e6I$A8$EDA`
12/07 13:55:49 INFO -- Header in request: Content-Type : application/x-www-form-urlencoded
12/07 13:55:49 INFO -- Header in request: User-Agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
12/07 13:55:49 INFO -- Header in request: flex-http-service : true
12/07 13:55:49 INFO -- Header in request: Connection : Keep-Alive
12/07 13:55:49 INFO -- Header in request: Cache-Control : no-cache
12/07 13:55:49 INFO -- Header in request: x-flash-version : 8,0,22,0
12/07 13:55:49 INFO -- Header in request: Accept : */*
12/07 13:55:50 ERROR %%500%%Internal Server Error
12/07 13:55:50 INFO -- Cookie in response: domain = `localhost`, path = `/`, client name = `JSESSIONID`, endpoint name = `JSESSIONID`, value = `f030b19253e6I$A8$EDA
12/07 13:55:50 INFO -- Header in response: Date : Wed, 07 Dec 2005 18:55:50 GMT
12/07 13:55:50 INFO -- Header in response: Content-Language : en-US
12/07 13:55:50 INFO -- Header in response: Server : JRun Web Server
12/07 13:55:50 INFO -- Begin GET response --
12/07 13:55:50 INFO JRun Servlet Error500 Internal Server Error
Internal Server Error
12/07 13:55:50 INFO -- End GET response --
12/07 13:55:50 ERROR -- GET status: 500, reason: Internal Server Error, target: http://localhost:8700/samples/oag/oagsource.jsp?ur...l=clientprofile/clientprofile.mxml" target="_blank">http://localhost:8700/samples/oag/oagsource.jsp?ur......
****************************************************