Solution to Error Running mxmlc.exe with Windows 64bit JVM

When attempting to run mxmlc.exe from the Flex 3 SDK:

Error loading: C:\Program Files\Java\jdk1.6.0_17\jre\bin\server\jvm.dll

To solve this error I created a new batch file in the FLEX3_HOME/bin directory and named it mxmlc64bit.bat with the following one line:

 ”%JAVA_HOME%\bin\java.exe” -Xmx384m -Dsun.io.useCanonCaches=false -jar “%~dp0\..\lib\mxmlc.jar” +flexlib=”%~dp0\..\frameworks” %*

 This bascially executes java to load the mxmlc.jar directly similar to what the linux script does and I assume it is also what mxmlc.exe does.

 Hope this helps. :-) Check out my google ads. :-)

Hauppauge HD PVR Streaming to Flash Player

This blog shows how to stream directly from the Hauppauage HD PVR H.264 Encoder to a Flash Player Client with no need to reencode the audio or video.  To accomplish this I have used a series of Windows DirectShow Filters to receive the stream from the HD PVR, send the stream out to the network using RTP/AVP.  And then Wowza Media Server does the rest to restream it to flash player.

What you will need:

- Hauppauge HD PVR
- Elecard NWRenderer DirectShow Filter (Elecard Codec .NET SDK G4 or Streaming Plug-in)
- Windows Graph Edit (Windows Driver Devlopment Kit)
- Wowza Media Server

First, install the Hauppauage HD PVR and drivers and get a good video signal coming in to it.   Next, get a copy of the Windows Driver Development Kit and you only need to install the AV Stream Tools in order to get the graphedt.exe and related libraries.  ( “C:\WINDDK\3790.1830\tools\avstream\x86\graphedt.exe” )  Most of the instructions will be building a DirectShow Filter Graph using this tool.

Using Windows Graph Edit you can create a filter graph to expose the raw data from the HD PVR.  The raw data is an MPEG Transport Stream containing H.264 video and AAC audio.  In Graph Edit you need to add and connect in sequence the Hauppauge HD PVR Crossbar, Hauppauge HD PVR Capture Device, and Hauppauge PVR Encoder filters.  These are found under Graph > Insert Filters > WDM Streaming Crossbar Devices,  WDM Streaming Capture Devices, and WDM Streaming Encoder Devices respectivally.  Connect the crossbar device to the capture device and connect the capture device to the encoder.  You can right click on each of these to modify properties.  Especially usefully is the encoder properties page to set the H.264 and AAC settings.

You now have direct access to the MPEG Transport Stream (containing H.264 audio and AAC video).  You could use a Dump Filter to dump this directly to a file if you wanted to.  What we want to do is feed this into the Elecard NWRenderer and stream it out to the network.  You will need to install either the Elecard Codec .NET SDK G4 or the Elecard Streaming Pack.  Once you have installed these they should show up under Graph > Insert Filters > DirectShow Filters.  If for some reason you do not see these Elecard filters, you may need to register them in windows.  The filters are *.ax files in the install folder of the Elecard software.  ( “C:\Program Files\Elecard\Elecard Codec SDK G4\Bin” or “C:\Program Files\Common Files\Elecard” )  Pass each of the *.ax filenames as a parameter to regsvr32.exe.

Insert the Elecard NWRenderer filter.  Connect the output of the Hauppauge Encoder to the Input of the Elecard NWRenderer.  Click Play to run the filter graph.  Right click to view the properties of the NWRenderer.  Under Information Click the Save SDP message.  Save this file out.  You can open this file in VLC Media Player to test that it is really being sent out over the network.  We are finished using the Graph Edit program.  Leave the graph playing and streaming on the network.

Install Wowza Media Server with an MPEG-TS add-on license.  Make sure you request an MPEG-TS add-on license.  Without the MPEG-TS add-on this does not work in Wowza Media Server.  Copy the rtplive folder from “%WMSCONFIG_HOME%\examples\NativeRTPVideoStreaming\conf” to “%WMSCONFIG_HOME%\conf”.  Create an empty folder named  rtplive in “%WMSCONFIG_HOME%\applications”.  Copy the .sdp into “%WMSCONFIG_HOME%\content”. Start the Wowza service.

Now you can run “%WMSCONFIG_HOME%\examples\NativeRTPVideoStreaming\client\nativertp.html”.  Put the filename of the .sdp file as the stream name. You are now watching the video and audio being encoded from the HD PVR.  Wowza simply converts the container from mpeg transport stream to the flash compatible mp4 box.

More to come including screen shots …

Working udev rules for multiple pvrusb2 and hvr-1950 devices

I have 6 WinTV HVR-1950 Model Category 751xx usb devices attached to one MythBuntu box recording 6 composite audio/video feeds from 6 security cameras.

Whenever the machine reboots the usb devices are assigned their device filename in non-repeatable and not well defined order so that each time /dev/video0 will probably be a different device.

So I knew that udev rules should solve the problem.  At present, there are no attributes defined for these devices that can be used in a udev rules, but the driver does create a lot of useful information in files under /sys/class/pvrusb2/.

I first tried using the rules and script found on this page: http://www.isely.net/pvrusb2/utils.html

But they did not work.  After several hours of troubleshooting and with some help, I finally found out the reason why: the /sys/class/pvrusb2/ folder and files are not yet available at the time that the udev rule is executing the program script.

To solve this problem, I’ve rewritten the script so that it will wait up to 15 seconds until these sys files are available, and then using the information, properly link each /dev/videoX device to a /dev/video_sn-XXXXXXX using the serial number of that device.

Then in MythTV I am able to use the /dev/video_sn-XXXXXXX filename which will be the exact same physical device every time.

I tried using the WAIT_FOR_SYSFS and WAIT_FOR keys in the rules file, but it also did not work for me.

If you find this information useful you might also find a useful ad on my site and click to read more about it.  :-)

Here are the files that work for me:

/etc/udev/rules.d/99-hvr1950.rules


KERNEL=="video[0-9]*", PROGRAM="/usr/bin/udev-hvr-1950.sh %m", SYMLINK+="video_%c", OWNER="mythtv", GROUP="mythtv"

/usr/bin/udev-hvr-1950.sh


#!/bin/bash

# author: Steve Gudmundson

pvrusb2=/sys/class/pvrusb2
search=$pvrusb2/sn-*
timeout=15

# find the serial number for this device #
count_seconds=0
minor_num=-1
until [ $count_seconds -gt $timeout ]
do
sleep 1
count_seconds=`expr $count_seconds + 1`
for file in $search
do
minor_num=`cat $file/v4l_minor_number`
if [ $minor_num -eq $1 ]
then
serial_num=”${file//$pvrusb2\//}”
echo $serial_num
exit 0
fi
done
done

echo unknown_$1
exit 0

Hauppauge WinTV HVR-1950 on Linux MythBuntu MythTV

What I did to get analog tv tuner, composite, or s-video capture to work:

  1. Fresh install of mythbuntu 9.04
  2. Extract and install the firmware files for HVR-1950:
    1. Download http://www.isely.net/downloads/fwextract.pl to ~/Desktop
    2. Insert the CD that came with your HVR-1950 (contains windows drivers) [assume it mounted as /media/cdrom0]
    3. cd ~/Desktop
    4. chmod u+x fwextract.pl
    5. ./fwextract.pl /media/cdrom0/Drivers/
    6. sudo copy *.fw /lib/firmware
  3. Run mythtv-setup using sudo
    1. sudo mythtv-setup
    2. Capture Card Type: IVTV MPEG-2 encoder card
    3. Video device: /dev/video0
    4. Probed info: WinTV HVR-1950 Model Category 7 [pvrusb2]
  4. Run mythtvfrontend
  5. (if the video looks really bad in mythfrontend):
    1. Utilities/Setup
    2. Setup
    3. TV Settings
    4. Recording Profiles
    5. MPEG-2 Encoders (PVR-x50, PVR-500)
    6. for Live TV, Default, High Quality, Low Quality
      1. Change Width to 720
      2. Change Height to 480

Notes:

  • To use it for digital capture instead of analog I think you need to use the DVB DTV capture card type.
  • If you do not run mythtv-setup through sudo you will get an error message: “Probed info: Failed to open” and “Could not open ‘/dev/video0′ to probe its inputs.”
  • If you do not extract and install the firmware files, then the HVR-1950 usb will not init.  You should get the following files extracted and copied: v4l-cx2341x-enc.fw, v4l-cx25840.fw, v4l-pvrusb2-29xxx-01.fw, v4l-pvrusb2-73xxx-01.fw
  • If you try to do this on MythBuntu 8.10 you will run into the deadlock problem described in http://www.isely.net/pvrusb2/history.html and fixed in the pvrusb2-mci-20081019 release.  (I did not try to recompile the pvrusb2 driver in 8.10 because I assume it is part of the kernel and it seemed like a lot of work.  If you do and it works, let me know how.)
  • My research shows that MythBuntu does not use the standalone pvrusb2 driver but uses the -in V4L version thus further complicating the compiling of an up-to-date version of pvrusb2.  I also could not figure out which packages to force upgrade in order to get the latest pvrusb2.
  • Some things I did that I don’t think helped fix the problems:
    • sudo apt-get update
    • sudo apt-get dist-upgrade
    • sudo apt-get autoremove
    • sudo rmmod pvrusb2
    • sudo modprobe pvrusb2
  • If you find this information useful you might also find a useful ad on my site and click to read more about it.  :-)

References:

dmesg output should be something like this when the device is connected properly:

[ 3014.636441] usbcore: registered new interface driver pvrusb2
[ 3014.636450] pvrusb2: V4L in-tree version:Hauppauge WinTV-PVR-USB2 MPEG2 Encoder/Tuner
[ 3014.636456] pvrusb2: Debug mask is 31 (0x1f)
[ 3015.636130] usb 5-6: firmware: requesting v4l-pvrusb2-73xxx-01.fw
[ 3015.647622] pvrusb2: Device microcontroller firmware (re)loaded; it should now reset and reconnect.
[ 3015.679396] usb 5-6: USB disconnect, address 5
[ 3015.679836] pvrusb2: Device being rendered inoperable
[ 3017.432020] usb 5-6: new high speed USB device using ehci_hcd and address 6
[ 3017.573844] usb 5-6: configuration #1 chosen from 1 choice
[ 3017.670711] cx25840' 0-0044: cx25843-24 found @ 0x88 (pvrusb2_a)
[ 3017.703925] tuner' 0-0042: chip found @ 0x84 (pvrusb2_a)
[ 3017.727963] tveeprom 0-00a2: Hauppauge model 75111, rev C3E9, serial# 5371008
[ 3017.727968] tveeprom 0-00a2: MAC address is 00-0D-FE-51-F4-80
[ 3017.727972] tveeprom 0-00a2: tuner model is Philips 18271_8295 (idx 149, type 54)
[ 3017.727976] tveeprom 0-00a2: TV standards NTSC(M) ATSC/DVB Digital (eeprom 0x88)
[ 3017.727979] tveeprom 0-00a2: audio processor is CX25843 (idx 37)
[ 3017.727982] tveeprom 0-00a2: decoder processor is CX25843 (idx 30)
[ 3017.727985] tveeprom 0-00a2: has radio, has IR receiver, has IR transmitter
[ 3017.727992] pvrusb2: Supported video standard(s) reported available in hardware: PAL-M/N/Nc;NTSC-M/Mj/Mk;ATSC-8VSB/16VSB
[ 3017.727998] pvrusb2: Mapping standards mask=0x300b700 (PAL-M/N/Nc;NTSC-M/Mj/Mk;ATSC-8VSB/16VSB)
[ 3017.728016] pvrusb2: Setting up 6 unique standard(s)
[ 3017.728023] pvrusb2: Set up standard idx=0 name=PAL-M
[ 3017.728026] pvrusb2: Set up standard idx=1 name=PAL-N
[ 3017.728029] pvrusb2: Set up standard idx=2 name=PAL-Nc
[ 3017.728033] pvrusb2: Set up standard idx=3 name=NTSC-M
[ 3017.728036] pvrusb2: Set up standard idx=4 name=NTSC-Mj
[ 3017.728039] pvrusb2: Set up standard idx=5 name=NTSC-Mk
[ 3017.728042] pvrusb2: Initial video standard (determined by device type): NTSC-M
[ 3017.731049] pvrusb2: Device initialization completed successfully.
[ 3017.731131] pvrusb2: registered device video0 [mpeg]
[ 3017.731135] DVB: registering new adapter (pvrusb2-dvb)
[ 3017.757981] cx25840' 0-0044: firmware: requesting v4l-cx25840.fw
[ 3019.986050] cx25840' 0-0044: loaded v4l-cx25840.fw firmware (16382 bytes)
[ 3020.168547] tda829x 0-0042: setting tuner address to 60
[ 3020.192529] tda18271 0-0060: creating new instance
[ 3020.228545] TDA18271HD/C1 detected @ 0-0060
[ 3021.424529] tda829x 0-0042: type set to tda8295+18271
[ 3024.742477] cx25840' 0-0044: Video signal: not present
[ 3024.742482] cx25840' 0-0044: Detected format: NTSC-M
[ 3024.742485] cx25840' 0-0044: Specified standard: NTSC-M
[ 3024.742487] cx25840' 0-0044: Specified video input: Composite 7
[ 3024.742490] cx25840' 0-0044: Specified audioclock freq: 48000 Hz
[ 3024.749349] cx25840' 0-0044: Detected audio mode: mono
[ 3024.749353] cx25840' 0-0044: Detected audio standard: no detected audio standard
[ 3024.749356] cx25840' 0-0044: Audio muted: no
[ 3024.749359] cx25840' 0-0044: Audio microcontroller: detecting
[ 3024.749362] cx25840' 0-0044: Configured audio standard: automatic detection
[ 3024.749365] cx25840' 0-0044: Configured audio system: BTSC
[ 3024.749367] cx25840' 0-0044: Specified audio input: Tuner (In8)
[ 3024.749370] cx25840' 0-0044: Preferred audio mode: stereo
[ 3024.808916] cx25840' 0-0044: firmware: requesting v4l-cx25840.fw
[ 3027.024318] cx25840' 0-0044: loaded v4l-cx25840.fw firmware (16382 bytes)
[ 3029.267787] usb 5-6: firmware: requesting v4l-cx2341x-enc.fw
[ 3029.508914] cx25840' 0-0044: 0x0000 is not a valid video input!
[ 3031.787749] DVB: registering adapter 0 frontend 0 (Samsung S5H1411 QAM/8VSB Frontend)...
[ 3031.790123] tda829x 0-0042: type set to tda8295
[ 3031.828013] tda18271 0-0060: attaching existing instance

SPEEDTEST.NET MINI with JSP

You can download a neat flash broadband speed test from http://www.speedtest.net/mini.php and put it on your own web site.

It comes with server side scripts in PHP, ASP.NET, and ASP for the upload half of the test.  But what if you want it to run on your java web container server such as tomcat or jboss?

Well, I have the solution. 

First, for the index.html file simply copy the index-asp.html and change the upload_extension line to read jsp instead of asp:

so.addVariable("upload_extension", "jsp");

Next, you will need to create an upload.jsp file alongside the upload.php and upload.asp files in the speedtest folder.

Here is the code for upload.jsp:

<%
long size = 0;
// add length of request header strings
String name = "";
for(java.util.Enumeration e = request.getHeaderNames(); e.hasMoreElements();){
name = (String)e.nextElement();
String value = "";
for(java.util.Enumeration f = request.getHeaders(name); f.hasMoreElements();){
value = (String)f.nextElement();
size += name.length() + value.length() + 3;
//out.print(name+"="+value+"\n");
}
}
/*
// add length of request parameter strings
name = "";
for(java.util.Enumeration e = request.getParameterNames(); e.hasMoreElements();){
name = (String)e.nextElement();
String value = "";
String[] values = request.getParameterValues(name);
for(int i = 0; i 0);
}
*/

// add the length of the input stream of uploaded bytes
java.io.InputStream is = request.getInputStream();
if ( is != null ) {
long skip = 0;
do {
skip = is.skip(Long.MAX_VALUE);
size += skip;
} while (skip > 0);
}

response.reset();
response.resetBuffer();
response.setContentType("text/html");
out.print("size="+size);
%>

Using Boolean AND && Operator in Flex MXML Data Binding

As you probably know because you are searching for a solution to this error, the following Flex MXML code will not work:

<HBox visible="{((booleanValue1) && (booleanValue2))}" >

You will get this error message during compile:

Error: The entity name must immediately follow the ‘&’ in the entity reference.

Instead you will need to use html escape codes for these as follows:

<HBox visible="{((booleanValue1) &amp;&amp; (booleanValue2))}" >

Outlook 2007 VBA Run A Script Rule Stopped Working

I have been banging my head against the wall on this one.  I wrote an Outlook 2007 rule that was set to “run a script”.  I used the Outlook integrated Visual Basic Editor (Alt+F11) to create one that would parse an email, pull out an html link for an xml file and save this url.  But, after my machine crashed and burned one night, it just stopped working.  It was broken.  I tried everything: rebooting the machine, exiting and reopening outlook, rewriting the script from scratch, removing and re-adding the rule.  Finally I tried one last thing that actually worked:

  1. Copy the script code to a notepad file. 
  2. Exit Outlook.  
  3. Go to %USERPROFILE%\Application Data\Microsoft\Outlook
  4. Delete the file named VbaProject.OTM.  
  5. Start Outlook
  6. Open up the integrated Macros VB Editor 
  7. Paste the Rule Procedures from the Notpad file
  8. Re-edit the script
  9. Viola! It works again.

What a headache!!! Hope this helps.  Check out the cool google ads!!  ;)

How to Use Apache mod_proxy to Work Around crossdomain.xml Constraints

I was recently given the task to load xml from a Flex app hosted on our web site.  Easy task I thought, especially with the mx.rpc.http.mxml.HTTPService flex object. 

Until I ran into this error:

faultCode: Channel.Security.Error
faultString: ‘Security error accessing url’
faultDetail: ‘Destination: DefaultHTTP’

The problem was that the flex swf was to run on our web site, but the xml data was provided by another site.  ( e.g.  ourWebSite.com/flex.swf —> anotherWebSite.com/data.xml )

Specifically the problem is the security built into flash player.  It will not allow flex.swf hosted on ourWebSite.com to use the xml data from anotherWebSite.com (unless anotherWebSite.com publishes a crossdomain.xml file in the root of their web server granting access to ourWebSite.com).  So, the company providing us the data doesn’t currently have anyone consuming the xml data from a flash swf loaded on a web site.  (It seems we are always pushing the boundaries of new technologies.)  Anyways, it could take forever to request they add a relevant crossdomain.xml to their site that grants us access to their data and get have the file put on their web server.  And, they may not want the headache of keeping track of all the thousands of clients that have a legitimate right to the xml data in a crossdomain.xml file.

So, I decided to circumnavigate (work around or hack a solution)  to the problem.  Basically what I did was use the Apache mod_proxy module to pass requests for the xml through ourWebSite.com.   (e.g. ourWebSite.com/data.xml — mod_proxy –> anotherWebSite.com/data.xml)  So, to the flash player, it looks like the data.xml is actually hosted on ourWebSite.com.  In fact, the url for the xml is now ourWebSite.com/data.xml instead of anotherWebSite.com/data.xml.  So it meets all of the flash player crossdomain security restrictions.

Here is a step-by-step guide of how to get around the crossdomain.xml restriction security constraints:

  1. Install Apache 2. (I used apache_2.2.6-win32-x86-openssl-0.9.8e.msi)
  2. Edit httpd.conf and configure mod_proxy to pass requests through it

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    ProxyRequests Off
    ProxyPass /data.xml http://anotherWebSite.com/data.xml
    ProxyPassReverse /data.xml http://anotherWebSite.com/data.xml

  3. As needed, add an appropriate crossdomain.xml file to the root of this server (if the flex.swf and the proxy-passed data.xml are on the same apache server, you don’t even need this). 
  4. Restart/start Apache 2.

One more caveat I had to work around is enabling Apache 2 to ProxyPass requests to a secure httpS url.  (the true url for our data.xml was httpS://anotherWebSite.com/data.xml)  So, I was getting the following error message in Apache’s error.log file:

proxy: No protocol handler was valid for the URL https
If you are using a DSO version of mod_proxy, make sure the proxy submodules
are included in the configuration using LoadModule.

The problem was that I did not have the openssl version of Apache 2.  You have to have an SSL version of Apache 2 in order to ProxyPass requests to a secure httpS url:

  1. Make sure you have installed the openssl version of Apache 2 (I used apache_2.2.6-win32-x86-openssl-0.9.8e.msi)
  2. Edit http.conf and configure for SSL Proxy support

    LoadModule ssl_module modules/mod_ssl.so
    SSLProxyEngine On

Flex messaging requires display-name entry in web.xml

Flex messaging (Flex Data Services, FDS, FDS2, now called LiveCycle) requires that the display-name entry be in the web.xml (for sure in JBoss, I assume in other Java servers).  Otherwise you will get errors similar to these:


08:04:06,018 ERROR Servlet threw load() exception
java.lang.NullPointerException
at flex.management.BaseControl.getObjectName(BaseControl.java:287)
at flex.management.BaseControl.register(BaseControl.java:148)

NetStream Errors if no AsyncErrorEvent handler specified

This one kind of bugs me.  If you don’t create an event handler on the flex/flash NetStream object for the AsyncErrorEvent and you call the NetStream.play function you will get the following errors. Well, you will see it in the flash debug player.

ERRORS:
Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onMetaData. error=ReferenceError: Error #1069: Property onMetaData not found on flash.net.NetStream and there is no default value.Error #2044: Unhandled AsyncErrorEvent:. text=Error #2095: flash.net.NetStream was unable to invoke callback onPlayStatus. error=ReferenceError: Error #1069: Property onPlayStatus not found on flash.net.NetStream and there is no default value. To solve this add the following code:
var ns: NetStream = new NetStream(nch.nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, ayncErrorHandler);
public function ayncErrorHandler(event: AsyncErrorEvent): void {
// ignore for now
}
Similar problem with the NetConnection object and the NetStatusEvent:

addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler)

Flash Media Server from Flex 2

Flex2 with FMS2

OK, this one caused me to waste a bit of time so here I’m going to describe the problem in detail.  Hopefully it will save someone else the trouble I had.  Basically Flex 2 defaults to AMF3 and Flash Media Server 2 will only support AMF0.

On the FMS server side the application was simply an empty folder. On the client side I had the following actionscript:

var nc NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
private function netStatusHandler(event: NetStatusEvent): void
{
trace(event.info.code + " for " +event.currentTarget.uri);
}
When I would build this code into a flex2 app, I always got NetConnection.Connect.Failed. If I compiled the code through Flash CS3 it worked. I eventually used the flex debugger to inspect the event object in the netStatusHandler function. event.info.description was "objectEncoding error" and event.currentTarget.objectEncoding was 3! So I found that the following line of code easily solved all my headache:

nc.objectEncoding = flash.net.ObjectEncoding.AMF0;

You could also set the default for all instances of NetConnection and SharedObject as follows:

NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
SharedObject.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;

But I decided not to do this since my app also connect to a java backend through AMF.

Flex 2 Java Session Log Out

Here is how to log out a user (invalidate their java web session) assuming you have a Flex 2 front end with a Java back end. Also assuming you are using the standard J2EE JAAS authentication api to protect your web app this will log them out of the software. Create a back end java function with the following code in it:

flex.messaging.FlexContext.getHttpRequest().getSession().invalidate();

Call this from the flex front end through a web service or through flash remoting.
Once you have invalidated the java session you should redirect the user back to the login page or to some other start page for your site. If you do not then the flex app will fail when trying to retreive data through the flex data services servlet to your java web app. So, place the following ActionScript code in the onResult handler of the flex method that called the service:

flash.net.navigateToURL(”.”)

Be careful when naming the method on the java back end. For example, you cannot use the method name “logout” because mx.rpc.AbstractService already has a method named logout() and you would be calling the Adobe class’s function rather than your java function. I have an associate that named his method logout() and it took us almost 2 hours to find out what was actually happening. We found that the mx.rpc.remoting.RemoteObject’s logout() method was being called rather than the one we wrote. And this is the error message we kept getting:

13:54:28,843 INFO [STDOUT:152] [Flex] [ERROR] Error handling message: flex.messaging.security.SecurityException: External login command required. Please check your security configuration.
incomingMessage: Flex Message (flex.messaging.messages.CommandMessage)
operation = logout
messageRefType = flex.messaging.messages.AuthenticationMessage
clientId = 89793734-5F1D-626C-22C6-3FFBE22775BC
correlationId =
destination =
messageId = 3AC1A57B-A8AE-D338-4C9D-B3306BB03966
timestamp = 1188417268687
timeToLive = 0
body = {}
errorReply: Flex Message (flex.messaging.messages.ErrorMessage)
clientId = null
correlationId = 3AC1A57B-A8AE-D338-4C9D-B3306BB03966
destination =
messageId = 897938B1-3B0E-8BFF-B43E-8096767736F8
timestamp = 1188417268843
timeToLive = 0
body = null
code = Server.Authorization
message = External login command required. Please check your security configuration.
details = null
rootCause = null
body = null
extendedData = null

Upgrading the Internet Explorer Active X Controls in Delphi 5

Component > Install Packages…
“Internet Explorer Controls”
Remove

Component > Import ActiveX Control
“Microsoft Ineternet Controls (Version 1.1)”

XPath Issues with JBoss 4.0.3 SP1

I recently ran across this error message when running Flex Data Services 2 inside JBoss 4.0.3 SP1:

ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/samples].[MessageBrokerServlet]:145]
Allocate exception for servlet MessageBrokerServlet
java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFctory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom

The problem is with JBoss 4.0.3 SP1 and is documented several places on the web:

Basically the solution is to download the 2.7.0 version of the xalan jars from apache and copy xalan.jar, xercesImpl.jar, and xml-apis.jar into the jboss deploy folder before deploying any flex data services 2 applications.  Below is the link to apache’s xalan download sites where you can either download xalan-j_2_7_0-bin.zip or xalan-j_2_7_0-bin-2jars.zip.

ActionScript Package Name Case Sensitvity

I checked out some mxml / action script code from our CVS repository today and recieved an error when trying to compile it:

 Error: Type was not found or was not a compile-time constant: <ActionScript Class Name>

It seemed from the error message that someone must have 1) forgotten to add an import in action script or 2) had messed up with the xml namespace attribute in the mxml file or 3) maybe they forgot to add the actionscript file to cvs.  After double checking each of these possibilities, I found that none of them was the problem.  Actually I was getting this same error message for several different actionscript classes.  So then I started asking the developers who wrote the code why I couldn’t compile it, they simply said it does compile just fine on their machines.  Yet, it still didn’t work on my computer.  After stepping through the imports and xml namespaces and showing one of the developers that the actionscript source code’s file was indeed on my computer, he noticed that one of the folders in the path to the file had an incorrect upper case letter in it.  I had checked this code out from cvs and for some reason cvs had created one of the folders with an upper case letter which was not in the package name. 

Here is an example of the problem:

Action script class’s package name:

package com.squidpower.education.assessmenttools.model

Path to this action script file on my computer:

com/squidpower/education/assessmentTools/model

Notice the capital ‘T’ in one of the folders compared to the package name.  Our linux cvs server is case sensitive in folder names and my windows xp machine is not.  I assume that somehow the other developers had renamed the folder on their machines to the all lower case name after having added it to cvs with the folder name with the upper case letter.  To solve the problem for future developers on this project I renamed the folder on the linux cvs server to the correct all lower case name.  See my related topic Renaming folders in CVS.

How to Access HttpRequest from Flex Data Services 2

Sometimes in a flex app that is deployed as part of a java web app you will need to know who is the currently logged in user.  To do this in Flex 1.5 you could use the flashGateway.Gateway class.  In Flex 2.0 this is done using the flex.messaging.FlexContext class (part of the flex-messaging.jar file).  Use the appropriate class in java code to get access to the HttpServletRequest object and thus get to the current user.  This java code would then be exposed to flex as either a web service or a remote object. 

Example Java Remote Method for Flex 2.0:

 public String getCurrentUserName() {
  return flex.messaging.FlexContext.getHttpRequest().getUserPrincipal().getName();
 }

Maven Build for Flex Applications

First see related blog Directory Structure for Integrated Flex and Java Web Applications.  This blog shows how easily one can build such project using maven with sample maven.xml, project.xml, project.properties files.  The samples are for maven version 1.0.2 and not version 2.x.             

<to be continued>

NOTE: You will get an error in maven on the call to the mxml compiler if the path name to an mxml file contains spaces.

Integrating Flex and Java in an Eclipse Web App Project

Requirements

1. Eclipse Web Tools Platform (WTP) from http://www.eclipse.org/webtools/, specifically the Web Standard Tools (WST) is used in this tutorial.
2. Flex 2 Builder Eclipse Plug-In from http://www.adobe.com/products/flex/flexbuilder/

Create the Eclipse Web App Project

1. Create a new project as “Web > Dynamic Web Project”.
2. Give it a descriptive project name.
3. Uncheck “Use default” and set “Directory” to the root directory where the project files are kept. (See related blog Directory Structure for Integrated Flex and Java Web Applications.)
4. Click “Next”.
5. On “Project Facets” screen click “Next”.
6. On “Web Module” screen set “Context Root”.
7. Set “Content Directory” to the root location of web files and WEB-INF folder.
8. Set “Java Source Directory” to the root location of web related java source (e.g. struts actions).
9. Click “Finish”
10. See blog Maven Build with Eclipse for optional steps.

Add Flex Project Nature

1. Right click newly created project.
2. Select “Flex Project Nature” > “Add Flex Project Nature”
3. Open the “Flex Development” perspective (Window > Open Perspective)
4. Open project properties (Right click project and select “Properties”).
5. Select “Flex Build Path”.
6. Set “Main source folder” to the root directory where mxml and action script files are.
7. Optionally set the “Output folder” to “.output\flex2” (see blog Maven Build with Eclipse and Directory Structure for Integrated Flex and Java Web Applications).
8. Select “Flex Applications”.
9. Add all flex applications (root level mxml files, those that contain the Application root tag).
10. Click “Set as Default” for one of the applications.
11. Remove auto created flex applications that you don’t need.
12. Unless compiling mxml on server, open project properties > “Flex Compiler” and uncheck “Generate HTML wrapper file” as this creates a possibly unneeded html-templates folder
13. See blog on Maven Build with Eclipse for optional steps.

Directory Structure for Integrated Flex and Java Web Applications

This blog describes a proposed directory structure for web applications that contain a mix of flex applications, java presentation layer code, and java integration layer code.  From this structure you could easily build projects using ant or maven (preferred). 

Read More »

FDS 2 and Flex Builder 2

I have found that Flex Builder 2 does not properly recognize any flex data services 2 mx components because it does not include the fds2.swc file by default in its install and thus cannot use the FDS2 controls.  To fix this problem, simply copy fds2.swc from <fds2 install folder>\flex_sdk_2\frameworks\libs to <flex builder 2 plug-in install folder>\Flex SDK 2\frameworks\libs.  Then you will also need to add this swc to the list of swc’s in flex builder 2 project properties under “Flex Build Path” > “Library Path”.

The symptoms of this problem are that it will not recoginize any of the dataservice mx controls in flex builder and you will see errors such as “Could not resolve <mx:DataService> to a component implementation.” 

Quick and Easy POJO Web Services with JBossWS

Here is a step-by-step tutorial explaining the quickest and easiest way to expose a plain old java object (POJO) as a web service.  This example uses jboss’s new web services stack (JBossWS-1.0.2.GA).  With this method you can quickly convert any java object into a web service.  For example, you could expose data access objects to a front-side client such as flex.  Best of all, no coding and extremely little configuration is needed to make the conversion from POJO to web service!

Read More »

Maven Build with Eclipse

I have found that the best way to run maven from inside eclipse is to create only one external tool named “Maven” and use the project_loc variable to specify the working directory in which maven will run. 
Here is a step-by-step guide:

1. Run > External Tools > External Tools…
2. Right click on “Program” and select “New”
3. For “Name”, type “Maven”.
4. For “Location”, click “Browse File System…” and find the maven.bat file
5. For “Working Directory”, click “Variables” and select “project_loc”.
6. Now you can run Maven by simply clicking the external tools button and it will build the project you are currently working on using maven.

Also, maven will create and delete the target folders as needed.  Eclipse also needs a place to put files that it builds.  I suggest that all of the eclipse built files be put in a folder named “.output” in the root of the project folder. 
For example:

1. Set “Flex Build Path” > “Output Folder” to “.output/flex2”
2. Set “Java Build Path” > “Output Folder” to “<eclipse project name>/.output/java/classes”.

Maven versus Ant comparison

Here are the short and concise reasons why maven is a better choice than ant for project builds:

  • Maven can run any ant scripts you need, so maven can do any thing ant does.
  • Maven does not need to be explicitly told to compile java files or build a war or ear file, so there is less xml code to write to get the build up and running.
  • Maven has integrated plug-ins already written for unit testing and reporting and for maintaining a project status web site with all kinds of useful project management reports.
  • See http://maven.apache.org for more information

Renaming Folders in CVS

When renaming a folder in CVS, you will need to perform the following steps:

  • Rename the folder on the CVS server
  • On every client that already has it checked out, change the folder name and modify the
    • CVS/Entries file at the same level as the renamed folder
    • every CVS/Repositories file below the renamed folder

What a pain! Yet another reason to switch to subversion.