Flerry: Flex-Java bridge for Adobe AIR 2.0
Today I published Flerry on Google Code, a Flex-Java bridge that uses NativeProcess API from Adobe AIR 2.0. Using it is very simple and similar to RemoteObject API in Flex. In fact I reused libraries from BlazeDS to do AMF de/serialization on Java side and on Flex side classes like AsyncToken, RemotingMessage, AcknowledgeMessage and ResultEvent/FaultEvent for eventing.
Here is short snippet how you can use it directly in MXML:
<?xml version="1.0" encoding="utf-8"?> <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="300" minHeight="200" xmlns:flerry="net.riaspace.flerry.*"> <fx:Script> <![CDATA[ import flash.events.MouseEvent; import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; protected function nativeObject_faultHandler(event:FaultEvent):void { Alert.show(event.message.toString()); } protected function addMethod_resultHandler(event:ResultEvent):void { txtResult.text = event.result.toString(); } protected function btnAdd_clickHandler(event:MouseEvent):void { nativeObject.add(parseInt(txtValue1.text), parseInt(txtValue2.text)); } ]]> </fx:Script> <fx:Declarations> <!-- Declaring NativeObject that points to net.riaspace.flerrydemo.MyJavaObject class in ./jars/flerry-demo.jar --> <flerry:NativeObject id="nativeObject" binPath="./jars/flerry-demo.jar" source="net.riaspace.flerrydemo.MyJavaObject" fault="nativeObject_faultHandler(event)"> <!-- Declaring NativeMethod with custom result handler, for this example actually result from NativeObject could be used --> <flerry:NativeMethod id="addMethod" name="add" result="addMethod_resultHandler(event)" /> </flerry:NativeObject> </fx:Declarations> <s:HGroup verticalAlign="middle" textAlign="center" horizontalCenter="0" verticalCenter="0"> <s:TextInput id="txtValue1" text="2" width="30" /> <s:Label text="+" width="30" /> <s:TextInput id="txtValue2" text="3" width="30" /> <s:Button id="btnAdd" label="=" width="30" click="btnAdd_clickHandler(event)" /> <s:TextInput id="txtResult" width="30" editable="false" /> </s:HGroup> </s:WindowedApplication>
Some NativeObject properties:
- binPath – points to jar file with your Java application
- source – points to java class that this NativeObject maps to
- singleton – sets source class object as singleton
- startupInfoProvider – custom implementation of net.riaspace.flerry.IStartupInfoProvider, by default Flerry comes with JavaStartupInfoProvider that tries to detect where Java is installed on users machine, in other case Error is thrown
In following posts I will explain in details how it all works, for now you can download flerry Flash Builder project with all the source code from here.


Great post thanks!
How does this compare to Merapi?
http://code.google.com/p/merapi/
Breizo
14 Jan 10 at 7:51 pm
First of all Flerry will work only with AIR 2.0 applications and it uses NativeProcess API that comes with upcoming release of AIR. NativeProcess API uses STDIN and STDOUT communication where Merapi is using local sockets communication. With Merapi main problem is that you have to start Java process first before AIR app in order to be able to communicate with it and it is not possible out of the box with AIR versions prior to 2.0.
p.
Piotr Walczyszyn
17 Jan 10 at 6:55 pm
Great post. Does it mean that from now on we’ll be able to call Java classes directly from AIR applications – I mean using only installed JRE, without the need of launching anything else?
Maciej Panka
17 Jan 10 at 8:44 pm
Yes, you can call Java classes directly from AIR 2.0 apps now;) Only important thing you will need to package those apps into native installer – that is obligatory when using NativeProcess API… You can create NI directly from AIR 2.0 sdk with adt tool, EXE for windows platforms, DMG for Mac OS X, DEB or RPM for Linux distros…
Piotr Walczyszyn
17 Jan 10 at 8:57 pm
Interesting stuff. But I’m still not clear on what needs to be in the JAR file… does at least one of the classes in the JAR file have to have a “main” method?
In your example, the Java class MyJavaObject does not have a “main” method.
With Flerry, can I call any public method of any public class in the JAR file?
Since Flerry is using the NativeProcess API in AIR 2, Flerry must be executing something… what is that something?
Thanks!
Chris
19 Jan 10 at 8:15 pm
Bloat, bloat, bloat, corporate bloat, lame workarounds and brainless code-monkey gluing. How about Python-Lua-Java -PL/SQL-PHP-AJAX-RUPP-XML-RubyOnRAILS bridging, of course with all installers bound with it, as a nice 2GB redistributable fancy package to print “hello world”?
Zilogat0r
20 Jan 10 at 3:16 am
@Chris The jar file must contain a Java class with public methods that you can call directly from AS3. This class doesn’t require main method…
Piotr Walczyszyn
20 Jan 10 at 11:32 am
Awesome! I was playing around with jars and Native Process but was still going the Socket-Route. Thanks for sharing!
Benjamin Bojko
30 Jan 10 at 1:29 am
[...] weeks ago I published Flerry project a Flex-Java bridge for AIR 2.0. In this post I wanted to explain how it works and what I used on Java side to do AS3/Java AMF [...]
Java-AS3 serialization with AMF | Space of Flex/AIR technologies
1 Feb 10 at 5:11 pm
[...] AIR2的发布,让我们在AIR和Java通信方面有了新的选择: flerry。flerry使用了AIR2的新特性NativeProcess,它直接创建了一个进程了执行Java程序。从其作者的blog上可以了解更多信息: http://www.riaspace.net/2010/01/flerry-flex-java-bridge-for-adobe-air-2-0/ [...]
使用Merapi来在AIR和Java中通信 | Color Hook
2 Feb 10 at 7:52 am
Thanks for sharing. I was wondering about how the de/serialization worked. Now I know.
Dan
5 Feb 10 at 12:54 am
Thanks,
I was trying an example with a abc.jar
Now here my class is a ParserSingleton and the method is getParsed
so I have configured parameters as
binpath > ./jars/abc.jar
source > an.je.exit.ParserSingleton
singleton > true
id > nativeObj
called the function by nativeObj.getParsed();
It says class not found ? Any clue?
Thanks,
Sawan
Sawan Ruparel
5 Feb 10 at 8:34 am
Make sure your abc.jar gets copied into bin-debug/jars if you are running in debug mode (and it has an.je.exit.ParserSingleton class). What OS are you on?
–Piotr
Piotr Walczyszyn
5 Feb 10 at 9:01 am
Hi,
I could resolve the above issue, the method was public but the constructor was private. So now it seems calling the function but I am getting an error >
RangeError: Error #2006: The supplied index is out of bounds.
at flash.desktop::InboundPipe/readObject()
Why would this be happening?
Thanks,
Sawan
Sawan Ruparel
5 Feb 10 at 9:02 am
Return type of data is some javaVO with multiple datatypes
IN java the definition is
public static parsedVO getParsed(filename);
The return type is limited to string only?
Regards,
Sawan
Sawan Ruparel
5 Feb 10 at 9:08 am
Please try to change getParsed to none static method.
Is the JavaVO marked as RemoteClass(alias=”packages.JavaVO”) on AS3 side?
p.
Piotr Walczyszyn
5 Feb 10 at 9:31 am
… and the return type is not limited to string only.
p.
Piotr Walczyszyn
5 Feb 10 at 9:33 am
Okay,
I havent created the JavaVO on AS3
I was expecting an object then later I will map to corresponding VO
I am getting the RangeError on this line in the code >
var message:AcknowledgeMessage = nativeProcess.standardOutput.readObject() as AcknowledgeMessage;
in NativeObject.as onOutputData function
Is AcknowledgeMessage just the trace output from java function and RemotingMessage is actual object?
Thanks,
Sawan
Sawan Ruparel
5 Feb 10 at 9:48 am
RemotingMessage is the class that is send to Java and AcknowledgeMessage is the one that is returned back.
I just checked into SVN an example with ComplexVO that is passed to and back from Java.
It is also available in downloads: http://flerry.googlecode.com/files/flerry-demo-1.0.1.fxp
Piotr Walczyszyn
5 Feb 10 at 9:59 am
I just tested situation with not existing VO on AS side and everything works and I receive just a dynamic Object.
p.
Piotr Walczyszyn
5 Feb 10 at 10:09 am
Thanks a lot.
I have integrated your example in my code it works
But my java method doesn’t now that is definitely some problem with my Java Method. Its a complex method which parses the HTML document. Rewriting that in AS3 is not an option.
Is there a way to debug the function called in the jar file. Some tool on desktop which can step me through the jar file while it is being executing .. or some way to route the stdout of java to as3 even if the return type is not on stdout
Thanks,
Sawan
Sawan Ruparel
5 Feb 10 at 10:50 am
There is no easy way, you can just built your own Java class with main method and invoke it as standard Java class and also use the Amf3Input and Amf3Output to do AMF de/serialization…
How complex/big is your returning JavaVO object?
p.
Piotr Walczyszyn
5 Feb 10 at 11:12 am
Hi Walczyszyn ,
Thanks for the post. I am really happy to see the solution for my problem. Actually I have a requirement of an AIR Client which will connect to blazeds server and I need to call some java methods at client side. By seeing this post, I am eagerly waiting to integrate flerry into my project and see. But I didn’t find any documentation of it. I am working on Flex Builder. Can I import this project into Flex Builder. Can you please guide me to do the same.
Thanks & Regards,
Sudarshan Kumar G
Sudarshan Kumar G
8 Feb 10 at 6:45 pm
Sorry, was caught up in the bugs
Its a huge function
Thanks for all the help, let me know if you are looking to develop some enhancement to this framework. I would like to contribute to it.
~ Sawan
Sawan Ruparel
10 Feb 10 at 11:30 am
[...] after a little playing with Flerry for Air->Java bridge I started to think about the structure of the code and the framework I [...]
MikeCann.co.uk » Blog Archive » On the Bleeding Edge
10 Feb 10 at 11:33 pm
@Sudarshan Kumar G to communicate AIR app with Java/BlazeDS backend you don’t need Flerry. You can do it out of the box with Flex using RemoteObject class.
Here is the documentation for that: http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_4.html
and ASDoc here: http://livedocs.adobe.com/flex/3/langref/mx/rpc/remoting/mxml/RemoteObject.html
Piotr Walczyszyn
12 Feb 10 at 8:40 am
Thanks . this was exactly that i was searching for. Is there any benchmark available between the performance of AS3 and Java code performance and memory foot prints ?
I need to develop a Rich client server application as its very processor oriented bussiness computation,so cannot find any nice wat to have a middle tier until there is a lot of investment on hardware. So thought of flex and java bussiness boths at client side; was searching something to talk between java and AIR smoothly .. thanks .. will sure try this today
Any siggestions and comments are welcome for my scenario
Martin
13 Feb 10 at 7:59 am
Hi Piotr,
I am basically from Java background and a beginner to flex. I thing your solution will help me a lot. But I am not able to run the project. (Details of error message: http://picasaweb.google.co.in/D.pawan05/Other#5437637183425455874)
Does it need some special configuration? I am using:
- Flex Builder 3.
- JRE and JDK Version 1.6.
- Operating System: Windows XP SP 2
Please provide more information for necessary support/compatibility and configurations .
Waiting for reply.
Pawan
13 Feb 10 at 9:16 am
tip: The link of the error message:
http://picasaweb.google.co.in/D.pawan05/Other#5437637183425455874
Thank you.
Pawan
13 Feb 10 at 9:36 am
In order to run it you will need Flash Builder 4 with Flex 4 and AIR 2.0 runtimes. Flerry is using new API’s that are coming with AIR 2.0.
Piotr Walczyszyn
13 Feb 10 at 9:37 am
Hi Piotr,
I am a beginer in Flex.Hope ur code will help me in proceeding with my work
Thank you.
Sangita
15 Feb 10 at 12:47 pm
Hi Piotr,
Thanks for sharing.Just wanted to know how Flerry differ from Merapi and what are its advantages.
Waiting for ur Reply
Thanks
Sangita
15 Feb 10 at 12:53 pm
Hi Piotr,
I have installed Flash Builder 4. (Since Flerry works with Flex 4)
Then I have imported Flerry Demo (flerry-demo-1.0.1.fxp) in Flash Builder.
While I tried to build the project, It is giving an error saying:
‘Type was not found or was not a compile-time constant: NativeProcessStartupInfo’
When I tried typing – import flash.desktop. – the NativeProcessStartupInfo wasn’t there on pop-up list.
Another thing is it says ‘Unable to open c:\Documents and Settings\UserName\Adobe Flash Builder Beta 2\Flerry\bin-as3\Flerry.swc’
Details of error message: http://picasaweb.google.co.in/D.pawan05/Other#5438539678913349794
Does it need to set up libraries or need to make some configuration?
Thanks. Waiting for your reply.
Pawan
15 Feb 10 at 7:53 pm
Hi Piotr,
I got the solution. The thing was I had not merged the AIR 2 sdk with flex 4 sdk. That’s why I was getting the error message.
Those who are facing the same problem please visit this thread on Adobe forum:
http://forums.adobe.com/thread/574872?tstart=0
Thanks.
Pawan
16 Feb 10 at 10:57 am
Hi Piotr,
There is new problem.
Problem: Flash Builder 4 (beta) crashing unexpectedly.
Event: Opening the Design view.
Preconditions: Added library project ‘Flerry’.
Description: When I have tried to open the Design view to add the controls the Flash Builder is terminating without any prompt. And special thing is this is happening only when I add the ‘Flerry’ as a library project.
Did you encountered this problem before?
Is this a bug in Flash Builder?
Reply.
Pawan
16 Feb 10 at 11:13 am
Hi Walczyszyn,
Thanks for your valuable reply. Actually, I need to call a java print method, which resides at client side but not at server side. In this case, I need flerry bridge to call such methods. Anyway, I solved the issue by reading this post once again. Thanks for the post. It helped me a lot.
Thanks & Regards,
Sudarshan Kumar G
Sudarshan Kumar G
22 Feb 10 at 8:47 pm
Hi Walczyszyn,
I am encountered with some problem. I am working on Windows XP Operating system. When I saw your source code, you are finding java in C:/Program Files/java, if the OS is windows. But what happens when the java installation is in another drive or another path?. My java installation is in another drive. Now I am not able to call java methods with flerry bridge. Is there a way to find java automatically without hardcoding the path, just like by searching java in registry or something? Please correct me If I am wrong and help me to do the same.
Thanks & Regards,
Sudarshan Kumar G
Sudarshan Kumar G
22 Feb 10 at 9:02 pm
Hi Piotr
Thanks a lot. I just made it work with Flex Builder 3 and Air 2.0 beta 2 sdk.
Amazing Work.
Greetings from Peru
- Victor Muguerza Capristan
Victor
25 Feb 10 at 5:43 pm
Hi Piotr:
I have a question, if i have 2 clases let say one person and other personController in my Java side, i have to declare two different native object for each one in the Air side ?
Thanks for your response
- Victor Muguerza Capristan
Victor
27 Feb 10 at 2:58 am
If Person class is only Value Object you don’t need to declare NativeObject for it, only for personController that has some logic that you want to invoke. For Person you most probably would declare AS3 equivalent annotated with [RemoteObject] metadata.
Piotr Walczyszyn
27 Feb 10 at 4:43 pm
Hi Piotr:
Tranks for your valuable reply. I actually made a lots of test with flerry but i have a problem trying to get data from a database (using mysql actually).
I get the following error:
RangeError: Error #2006: The supplied index is out of bounds.
at flash.desktop::InboundPipe/readObject()
at net.riaspace.flerry::NativeObject/onErrorData()[/Users/pwalczys/Workspaces/Blog/flerry/src-as3/net/riaspace/flerry/NativeObject.as:99]
Can you provide a simple example of flerry with db or tell me what steps should i follow.
Tranks for your response:
-Victor Muguerza Capristan
Victor
27 Feb 10 at 8:39 pm
Hi Piotr:
I have successfully done with calling my own java api using flerry just like the ‘add’ method that you have implemented.
But now I want to create an object of a class. The constructor of the class is having some parameters to initialize the object. “How can i specify the parameters to the constructor?”.
can you provide me with any documentation about the working of flerry?
waiting for your reply…
Thanks and regards,
Prashant
Prashant
2 Mar 10 at 11:15 am
With current version of Flerry java class that is mapped to NativeObject may not have any constructor parameters.
Piotr Walczyszyn
2 Mar 10 at 11:27 am
“With current version of Flerry java class that is mapped to NativeObject may not have any constructor parameters.”
But why is it so?
would it be possible in further version of flerry?
or can we make it possible using the concepts used in flerry and some other similar things?
Prashant
2 Mar 10 at 12:26 pm
I have imported Flerry Demo (flerry-demo-1.0.1.fxp) in Flash Builder beta 2.
I have also merged AIR 2 with it.
I am not getting any compile error,but rather I am getting a run time error while running the Flex Demo in my laptop.
Details of error: RangeError:Error#2006:The Supplied index is out of bound and Could not find the main class.
Sangita Patel
2 Mar 10 at 1:01 pm
I have reinstalled Flex builder 4 and performed the same task again but I am getting the same error.
I have also tried to install it in another Drive and change the workspace then also the problem is not solved
Waiting for ur Reply
Thanks and Regards
Sangita
Sangita Patel
2 Mar 10 at 1:05 pm
@Sangita: Do you run Flash Builder as Eclipse plug-in? The example requires it to compile Java source.
What operating system you are on?
Piotr Walczyszyn
2 Mar 10 at 1:33 pm
@Prashant: Technically it is not a problem to implement constructor parameters support. It is just matter of having a time to do that
If you want to help me with that I can give you check-in rights to SVN on Google Code.
Piotr Walczyszyn
2 Mar 10 at 1:35 pm
hi
Piotr
Right now I am on Windows XP
How to get rid of the problem
Waiting for ur reply
Thanks and Regards
Sangita
Sangita Patel
2 Mar 10 at 1:58 pm
Where do you have Java installed on your WinXP box?
Piotr Walczyszyn
2 Mar 10 at 2:00 pm
Hi
Piotr
I have installed Java on C:\Pogram Files\Java\jre1.6.0_01
Sangita Patel
2 Mar 10 at 3:02 pm
Hi Piotr
The same Flerry Demo(flerry-demo-1.0.1.fxp)is executing in my office PC.
Is there any problem related to configuration or is related to memory issue.
I am getting following error
RangeError: Error #2006: The supplied index is out of bounds.
at flash.desktop::InboundPipe/readObject()
at net.riaspace.flerry::NativeObject/onErrorData()[C:\Documents and Settings\Sangita\Adobe Flash Builder Beta 2\flerry\src-as3\net\riaspace\flerry\NativeObject.as:99]
Waiting for ur Reply
Thanks and Regards
Sangita
Sangita Patel
2 Mar 10 at 3:51 pm
Probably is a problem of location where you have Java installed on home PC.
Please check and let me know where you have it installed.
Piotr Walczyszyn
2 Mar 10 at 5:03 pm
oh! thats great…
ofcourse I (with some of my colleagues) would like to help you with that.
and we will surely need your guidance throughout that and documentation support also.
but simultaneously we also have to complete our peoject within 30-40 days.
so what according to you, “should we implement it for our project also?
or should we just find out some other way for our project and implement it without any context to our project ?”
and what we would have to do now to help you?
Prashant
2 Mar 10 at 5:04 pm
I’m not quite surehow/why this is related to that “Error #2006: The supplied index is out of bounds.” error. But I get that error any time my Java code used Log4J. If I remove all calls to Log4J, the return value of my Java method is received without error in my AIR application. Interestingly, with the Log4J calls in place, the Java method still runs completely without error. The only error seems to be in the receipt of the return value.
Rob McKeown
2 Mar 10 at 5:44 pm
Hi Piotr
I have installed Java on C:\Pogram Files\Java\jre1.6.0_01
waiting for ur reply
Thanks and Regards
Sangita
Sangita
2 Mar 10 at 6:35 pm
This may be useful to others having errors. One thing that I fought with for a couple of hours was that, you need to make sure that you update the classpathTemplate to include any additional jar files that your Java classes require. For example, my application calls ANT from my Java code. In order to do that, I put the required ant jar files in the “jars” directory of my AIR app thinking that any jars in that directory would automatically get passed to the java executable as part of the classpath argument. That classpath argument is generated in the JavaStartupInfoProvider class. By default, the NativeObject creates a JavaStartupInfoProvider for you, but it only includes a few jar files on the classpath (flerry.jar, flex-messaging-core.jar and flex-messaging-common.jar). In order to make sure all my jar files were added to the classpath, I added some initialization code to my application to create my own JavaStartupInfoProvider instance in which I specify the classpathTemplate by looking at all jar files in the jars directory. Then I set the my instance into startupInfoProvider property of my NativeObject.
Here is my init method:
private function init() : void {
//build classpath string – right now assumes that there are only .jar files in this directory
var jarsDir:File = File.applicationDirectory.resolvePath(“jars”);
var jars:Array = jarsDir.getDirectoryListing();
classPath = “”;
for (var i:int = 0; i < jars.length; i++) {
classPath += "./jars/" + File(jars[i]).name + "{0}";
}
classPath += "{1}";
var startupProvider:JavaStartupInfoProvider = new JavaStartupInfoProvider();
startupProvider.classpathTemplate = classPath;
nativeObject.startupInfoProvider = startupProvider;
}
Rob McKeown
2 Mar 10 at 7:13 pm
Hi Piotr
Thanks for ur help.
I was able to get rid of the problem.
Problem was related to jre.Actualy there was jdk1.5 and jdk 1.6 both installed.
I have removed the earlier versions and have installed jre 1.6.
After this I updated the flerry and imported the file again.
Thanks and Regards
Sangita
Sangita
2 Mar 10 at 8:15 pm
Hi Piotr
I wanted to know how NativeObject.as in Flerry side is mapped with NativeObject.java
I wanted to know the exact flow and where the constructor of NativeObject.java is called and how its members are initialised
Waiting for ur Reply
Thanks and Regards
Sangita
Sangita Patel
4 Mar 10 at 8:52 am
Thanks for the great post!
I’m working on a project that my AIR application waits for a notification from a Java application.
Is it possible that the Java app. sends the request first to the AIR app. or the Java app. invokes the method provided by the AIR app.?
Could you please give us some example?
I could do the bidirectional message passing with Merapi, but I would like to switch to Flerry since it seems to be more convenient to use.
Thanks a lot!
starsirius
17 Mar 10 at 2:56 am
Hi there,
first a big thanks to you Piotr for this great piece of code.
I am trying to get this to work in one of my projects and I always get an “java.lang.reflect.InvocationTargetException” error. The background to this is, that I have my own jar file, which has some methods (most of them do work in flex using flerry). One of the methods is a conversion method which relies on some classes from a third-party jar file. The first call to a method from this third-party jar throws this execution.
I am already loading all jars with the init-method described by rob in flex. I should also mention, that it is a long time ago I really programmed with java… so I am not to sure on which side the error is. But the java-side is quite simple and works in purely java execution.
Perhaps some one of you has some hints to this.
Thanks and regards,
Hannes
Hannes
27 Mar 10 at 6:56 pm
Hi Piotr,
I am working on Windows XP Operating system. My Java Installation is in D:\Java\jdk1.6.0_07. I am not able to call java methods with flerry bridge. Is there a way to find Java automatically?
Thanks & Regards,
Akhil
Akhil
19 Apr 10 at 4:56 am
You can implement your own: IStartupInfoProvider
Check for details default JavaStartupInfoProvider that I included in the package, for windows platform it looks into C:\Program Files\
Unfortunately there is no easy way to check it, you may want to try calling “echo %JAVA_HOME%” with NativeProcess.
p.
Piotr Walczyszyn
19 Apr 10 at 9:18 am
Really great work!
But I think big problem here is debugging. Is it possible to debug Java program when it’s invoked by flex? I know it is possible in Merapi because it uses socket, but how to do that in flarry? Thank.
Milos
1 Jun 10 at 7:28 pm
Is it possible that there is bug in flarry when invoking method with more than 5 arguments. I have method with 7 String arguments and when I invoke corresponding Java method last 2 arguments are not recognized as String but like RemotingMessage object. How is that possible? Please help. Thanks a lot.
Milos
3 Jun 10 at 8:20 pm
@Milos
this is really good question. How to debug Java side with Flerry (and with NativeProcess API in general)?
Rangy John
18 Jun 10 at 7:03 pm
The way to do it is Java Remote Debugging feature, you would need to pass some extra params to the app:
-Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=nand next connect from your favorite IDE (from Eclipse go to the Debug manager and create a new Remote Java Application configuration for the process you want to connect to).
Piotr Walczyszyn
21 Jun 10 at 3:14 pm
I succeeded to debug with:
// JavaStartupProviderInfo
args.push(“-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n”);
Xdebug doesn’t work for some reason. But there is another error when debugging, onOutputData receive an object (even before respond() method is invoked on Java side) that cannot be casted to AcknowledgeMessage so an error is thrown. Here is the error:
RangeError: Error #2006: The supplied index is out of bounds.
at InboundPipe/readObject()
at net.riaspace.flerry::NativeObject/onOutputData()[C:\Users\milos\Adobe Flash Builder 4\flerry\src-as3\net\riaspace\flerry\NativeObject.as:76]
Milos
21 Jun 10 at 9:04 pm
I just changed port to 8123 and it works great now. Thanks. This is really the best way to work with NP API
Milos
22 Jun 10 at 12:38 am
Hi,
I’ve made some changes in the code, solving issues when the applications uses some log4j or any that compromises sysout, causing read error. I also made some changes that will allow bidirectional messaging. How can I contribute to the project?
Jhonny Everson
26 Jun 10 at 9:36 am
Hi Milos
I think change the point can’t solve the problem. I test some time. The error still appear.
Pizzaman
27 Jun 10 at 11:41 am
[...] that Flerry 1.1.0 was released! For those of you that don’t know what is Flerry, it’s a Flex-Java bridge for Adobe AIR 2.0. This new release brings possibility to call/initiate communication from Java to Flex/AS3 code. [...]
Flerry 1.1.0 released with a two-way Flex-Java communication | Space of Flex/AIR technologies
30 Jun 10 at 10:30 am
BUG finally Fixed
Hello Piotr thanks for the framework, really nice piece of code.
There is a title bug that I managed to fix, and I would like to share the solution with everybody here.
the onOutputData(event:ProgressEvent) method can NOT Handel BIG objects, because the nativeProcess.standardOutput has a limited buffer. If the serialized coming object from Java is small enough to fit the buffer we have no problem. but if the coming object is big, then boom. We will get some nasty errors “I almost pull my hair off”. Hehe
The solution is to collect all the bytes from multi onOutputData calls and compose the AMF object at the end.
Here is my code
http://uploading.com/files/mm7ff254/code.zip/
Cheers
Mohammed
Mohammed
1 Jul 10 at 8:46 am
Hi Mohammed
After my abnormal test the error appear once again.
this’s my solution
I change onOutputData and onErrorData functions, catch message error
try{
var message:ErrorMessage = buffer.readObject() as ErrorMessage;
}catch(err:Error){
trace(buffer.readUTFBytes(buffer.bytesAvailable));
}
Pizzaman
2 Jul 10 at 4:31 am
Hello Pizzaman ,
onOutputData should not catch any errors, that is correct
the correct way is to add EventListener that listens to your events including error events
example:
nativeProcess.addEventListener(IOErrorEvent.STANDARD_INPUT_IO_ERROR, ioError);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_OUTPUT_IO_ERROR, ioError);
nativeProcess.addEventListener(IOErrorEvent.STANDARD_ERROR_IO_ERROR, ioError);
protected function ioError(event:IOErrorEvent):void
{
//do anything u like with the error
}
Hope this helps
Mohammed
Mohammed
5 Jul 10 at 9:12 am
[...] Flerry go ahead and download flerry and flerry-demo projects. You can also find my previous posts (Post 1 | Post 2) [...]
Flerry 1.1.1 released supporting large objects transfer | Space of Flex/AIR technologies
5 Jul 10 at 3:01 pm
[...] Flerry go ahead and download flerry and flerry-demo projects. You can also find my previous posts (Post 1 | Post 2) [...]
Flerry 1.1.1 released supporting large objects transfer | Space of Flex/AIR technologies
5 Jul 10 at 3:01 pm
[...] Link: Flerry: Flex-Java bridge for Adobe AIR 2.0 | Space of Flex/AIR … [...]
Flex learner | Blog | Flerry: Flex-Java bridge for Adobe AIR 2.0 | Space of Flex/AIR ...
17 Jul 10 at 9:27 pm
Hello
I’m following this basic demo.. and i get
Error #2006: The supplied index is out of bounds.
at flash.utils::ByteArray/readObject()
at net.riaspace.flerry::NativeObject/onErrorData()[/Users/npulido/Documents/Adobe Flash Builder 4/DockTest/src/net/riaspace/flerry/NativeObject.as:140]
Everything is just the same.. does it have to be with my Java version, i’m using 1.5..
NAZ
19 Jul 10 at 11:34 am
Hi
.
First of all Great Work
I’m having a hard time trying to execute an Air application after it was installed using a native instaler that i’ve built.
I got the following message:
could not find the main class: net.riaspace.flerry.NativeObject.
Program will exit
Any ideias on that?
Thanks
FIlipe
22 Jul 10 at 9:25 am
I find your demo has a error. I have changed it. protected function ativeObject_faultHandler(event:FaultEvent):void
{ Alert.show(event.fault.faultDetail);
}
pizzaman
27 Jul 10 at 10:06 am
Hi, i’m getting a 3212 Error when running in debug mode, runs on Mac?
Rodrigo Spesia
19 Aug 10 at 10:33 pm
Hello
I having a good experiance on this project, it is really a great work, I could run your demo on Flex builder 3.0 with 4.1 SDK and AIR 2.0 well, but when I export the demo project to release AIR package then install it, it doesn’t work, why ?
Edward
3 Sep 10 at 4:31 am
Hey, found your site by accident undertaking a investigation on Yahoo but I?ll certainly be coming again. ? How can I think in God when only last week I obtained my tongue caught within the roller of an electrical typewriter?
aguilar
25 Sep 10 at 11:05 am
Hi there, i have an error, when i want to call ‘add’ method:
Error deserializing received AMF object
i dont know what to do
Ruben
14 Oct 10 at 5:21 pm
Hi, sorry for my english .. when i want to export a Release version, i cant do it because an error appears:
Error creating AIR file: FlerryDemo-app.xml: error 306: Descriptor must support the profile desktop, mobileDevice, or extendedMobileDevice
I have searched online, i have not find a solution.
is there “extendedDesktop” profile available
Ruben
14 Oct 10 at 10:56 pm
I am trying to communicate with a Server that speaks AMF to a Flex App. The Amf3Input and Am3Output will be important, but unlike your solution I will not have a native object that mirrors the object on the server since I do not have access to the server and its classes. Only have access to the communication that I see using Firebug, which has a built in AMF deserializer. Do you think it is possible to create AMF requests and receive back responses AS IF I am the flex app that the server is intending to communicate with? Please advise, thank you.
David
24 Oct 10 at 8:01 am
@David in that case use built-in RemoteObject class that comes with Flex. Also if your app is not placed on the server and the server doesn’t allow your domain in crossdomain.xml you way want to build this app as an AIR app which dosn’t have this constraint.
Piotr Walczyszyn
24 Oct 10 at 3:12 pm
Flerry is great! Gave it a quick test-drive recently and my simple example worked fine. Actually, I’m wondering whether it would be possible to make use of Flerry in combination with AIR for Android => thus briding an AIR app with a native app on Android 2.2 Froyo???
hanspeter
27 Oct 10 at 3:04 pm
All your demo produce this error on Flash Builder 4.0? Does it actually work at all?
[SWF] FlexUnitApplication.swf – 2,725,351 bytes after decompression
Error: Error deserializing received AMF object:
SIflex.messaging.messages.ErrorMessageheadersrootCause bodycorrelationIdfaultDetailfaultStringclientIdtimeToLivedestinationtimestampextendedDatafaultCodemessageId
java.lang.ClassNotFoundException: com.riaspace.flerry.tests.JavaServiceKcom.riaspace.flerry.tests.JavaService
James
30 Oct 10 at 8:21 pm
@James this problem means you don’t have the compiled java classes in the classpath.
Are you trying to run it in a release build or debug?
You also need to run it with Flash Builder installed as an Eclipse
plugin that you have JDT on board.
p.
Piotr Walczyszyn
3 Nov 10 at 10:32 am
Piotr,
Thanks so much for this library. It makes creating apps in flex (slick UIs made easy) and Java (rich and nifty data model possibilities) much easier than using merapi… and less brittle.
I got stuck for some time on the “doesn’t work in release mode” problem… My app worked perfect in the Eclipse IDE, but when I exported to run as a release exe, it just didn’t work. I had the libs and classes directories set up correctly.
I finally got it working by invoking the adl in the air_2.5 SDK directly. I copied the sdk into the release directory (air_2.5), cd-ed to the release directory, then ran:
air_2.5\bin\adl.exe META-INF\AIR\application.xml .
Or more generically:
\bin\adl.exe \META-INF\AIR\application.xml .
Then the entire app ran like a champ. Don’t forget the period at the end of the adl command. It’s an ugly command line, but that’s what BAT files are for.
Copying the sdk in the release directory was unnecessary.. I just liked it neatly in one directory so I can copy it from machine to machine.
Joe
Jokichi
15 Dec 10 at 9:22 am
Hi, I try to run your demo in the flexbuilder. There will occur a error of “can not find the path of jar”. I think I set the jar file wrong.
the flerry-demo.jar is in src/jars/flerry-demo.jar
my configure as fellows:
How to solve the problem?
Ethan
22 Dec 10 at 10:34 am
my configure as fellows:
Ethan
22 Dec 10 at 10:37 am
my configure as fellows:
flerry:NativeObject id=”nativeObject” binPath=”./jars/flerry-demo.jar” source=”net.riaspace.flerrydemo.MyJavaObject”
fault=”nativeObject_faultHandler(event)”
flerry:NativeMethod id=”addMethod” name=”add” result=”addMethod_resultHandler(event)”
Ethan
22 Dec 10 at 10:42 am
Dear developers, i have been testet your application with JavaStartUpInfo. Very nice!
But do not forget this native support bit processes.
If you are using 32 Bit Java Runtime on 32 Bit Operating System like Windows = x86 / support32bitprocesses,
= C:\\Program Files\\
If you are using 32 Bit Java Runtime on 64 Bit OperatingSystem like Windows = x86_x64 = support32bitprocesses = C:\\Program Files (x86)\\
If you are using 64 Bit Java Runtime on 64 Bit Operating System like Windows = support64bitprocesses = C:\\Program Files\\
Please update this JavaStartUpInfoProvider.as
I will to develop my calling with Java on Java runtime with different processes…
Thanks for importnat.
best developing
Jens
29 Dec 10 at 5:00 am
Thanks a lot for your framework, is very usefull and easy to do.
I’ve got a question, how can write a invocation to native(remote) object using only AS3, beacuse all the examples are only under tags.
So, if you can send me the example or publish the Java/AS docs.
Felipe R. Sebastiani Sobenes
17 Jan 11 at 8:18 pm
I forget to say that Flerry is compatible with Adobe Flash Builder 4, AS3 / Adobe AIR Framework 2.5 and Java 6.
Felipe R. Sebastiani Sobenes
17 Jan 11 at 8:23 pm
[...] best yet. Flurry. Google Code Page GA_googleAddAttr("AdOpt", "1"); GA_googleAddAttr("Origin", "other"); [...]
Access remote database from AIR application « Oracle Notes
23 Feb 11 at 12:54 am
I’m having a problem with version 1.2.0 after call three times the same method.
The error message is: NativeProcess error without correlationId
Does anybody knows how to solve this problem?
Thanks
Saulo Nardin
13 Apr 11 at 2:29 am
Zilogat0r way above just can’t get over the fact that Swing is garbage, and a Flex UI is much more productive to write (not to mention modern looking), so combining that with Java’s ability to do practically anything (non-UI), you have a very powerful and productive combination. Either that or he’s thinking everyone should just use VB or cobol or something. haha
Zilogat0rIsAFool
2 May 11 at 8:37 pm
Hey I just came here to join this wonderful community. thanks
Allen.
Allen toeiop
6 May 11 at 5:56 pm
Flerry looks great, couple questions though. We are developing a project to be compiled as either a Web or Air app. We want to use conditional compilation (http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html).
1st problem: You can’t use conditional constants within mxml, only actionscript. How can we declare a NativeObject in Actionscript? We can do it with a remoteObject (http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_4.html).
2nd problem: We use the Mate framework (http://mate.asfusion.com) and make use of the RemoteObjectInvoker. The is no such thing as a NativeObjectInvoker. Anyone have an idea how to provide the ability to conditionally use Flerry in Air vs our remoteObject in the Web app?
Marc
11 Aug 11 at 2:37 pm
Piotr, thanks for this code… very power full.. but.. i need one help… how i get this exception?
java.lang.reflect.InvocationTargetException
if use the database class connection, got this erro…
U now?
Thanks..
Rodrigo Valentim
22 Aug 11 at 10:18 pm
A follow up to Rob McKeown 2 Mar 10 at 5:44 pm regarding the “Error #2006: The supplied index is out of bounds.”.
This error showed even when all log statements were at ‘debug’ level and logging was set to ‘info’.
I was able to log to file without error. I had to comment out all console references in log4j.properties. Removing ‘console’ from ‘log4j.rootCategory’ was not enough.
Ray
Ray Bon
23 Sep 11 at 1:39 am
hi Piotr, thanks for your great work!
i have downloaded the flerry-demo project,but when i import it into flash builder4 as a project,there are some errors.
1.Project ‘flerry-demo’ is missing required Java project:’flerry’
2.The project cannot be built until build path errors are resolved
3.Cannot open “\flerry\bin-as3\flerry.swc”
I don’t konw how to solve them.
can you tell me how to run the flerry-demo?
thank u!
yaoconghai
1 Dec 11 at 5:33 pm