Tuesday, August 25, 2009

Spring BlazeDS integration - playing with testdrive

svn checkout https://src.springframework.org/svn/spring-flex/trunk/spring-flex-samples/

cd spring-flex-samples\spring-flex-testdrive,

mvn install

[ERROR] FATAL ERROR
[INFO] -------------------------------------
[INFO] Java heap space
[INFO] -------------------------------------
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space

Oops... Okay... lets say "set MAVEN_OPTS=-Xmx1024m" - should be enough.

mvn clean install


Not all is clear here, still :
Missing:
----------
1) org.springframework.flex:spring-flex:jar:1.0.1.BUILD-SNAPSHOT

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=org.springframework.flex -DartifactId=spring-flex -Dversion=1.0.1.BUILD-SNAPSHOT -Dpack
aging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.springframework.flex -DartifactId=spring-flex -Dversion=1.0.1.BUILD-SNAPSHOT -Dpackag
ing=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.springframework.flex.samples:testdrive:war:1.0.1.BUILD-SNAPSHOT
2) org.springframework.flex:spring-flex:jar:1.0.1.BUILD-SNAPSHOT


cd testdrive, edit pom.xml, change version of spring-flex jar:
<dependency>  
<groupid>org.springframework.flex</groupid>
<artifactid>org.springframework.flex</artifactid>
<version>1.0.0.RELEASE</version>
</dependency>

mvn install
....
[INFO] BUILD SUCCESSFUL
[INFO] --------------------------------
[INFO] Total time: 4 minutes 50 seconds

Cool, but not yet...
Deploying...

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBrokerDefaultHandlerMapping': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '_messageBroker': Invocation of init method failed; nest ed exception is java.lang.NoClassDefFoundError: org/apache/xpath/CachedXPathAPI


Well, ok, org.apache.xpath.CachedXPathAPI - it's xalan
<dependency>                       
<groupid>xalan</groupid>
<artifactid>xalan</artifactid>
<version>2.7.1</version>
</dependency>

Then ... mvn install

Yahoooo !

[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------
[INFO] Total time: 7 minutes 30 seconds
[INFO] Finished at: Tue Aug 25 11:10:46 EEST 2009
[INFO] Final Memory: 32M/106M

Deploying.. looks nice...
FF -> http://localhost:8080/testdrive/insync01/insync01.html

Ooops... Flash-plugin stacktrace :

[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 404: url: 'http://localhost:8080/messagebroker/amf'"]
at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
at mx.rpc::Responder/fault()
at mx.rpc::AsyncRequest/fault()
at mx.messaging::ChannelSet/faultPendingSends()
at mx.messaging::ChannelSet/channelFaultHandler()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::Channel/connectFailed()
at mx.messaging.channels::PollingChannel/connectFailed()
at mx.messaging.channels::AMFChannel/statusHandler()

Maybe wrong context root ? Where ? To keep things as simple as possible I'm renaming testdrive.war to ROOT.war. And yes ! It works. I've added maven jetty plugin to be able to run web application directly from command line, I just love it. BTW, here is the svn diff file (patch) which you can apply as described here and don't do manual editing. It's simple, but maybe could be useful for someone.

Now I'm going to test all this stuff to see how can I benefit from using integration.

Friday, August 21, 2009

Java Champion Yakov Fain started podcast

Here is a few words about Yakov (from book "Rich Internet Applications with Adobe Flex & Java")

Yakov Fain is a Managing Principal of Farata Systems. He’s responsible for the enterprise architecture and emerging technologies. Yakov has authored several Java books, dozens of technical articles, and his blog is hugely popular. Sun Microsystems has awarded Yakov with the title Java Champion. He leads the Princeton Java Users Group. Yakov holds a BS and an MS in Applied Math and is an Adobe Certified Flex Instructor.
Link : http://nobsit.podbean.com/

Wednesday, August 19, 2009

Adobe Flex , BlazeDS and Spring data push RIA app

I'm playing with Adobe Flex 3 and BlazeDS last time. It's pretty fun! Imagine some kind of application where we need to process and visualize data which we fetching from some service at regular basis, for example every second. Maybe not so regular, maybe 10 seconds or something else. So, it's better to notify client that we have a new data and send it to client for processing. Data push - is when server pushing data to client, every time new data become available.

My example of such kind of application is RIA app for JVM free memory monitoring. It's probably useless, but approach is right, I suppose :) I have Adobe Flex 3 on client and Spring 2 + BlazeDS+Quartz on backend. I don't want to dive into technical details here(not now, sorry, maybe latter), just code and video of working application. Source is here (FlexMemoryMonitoring) and here is the video :


Update.
You can see fresh version of this application online.