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

[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 :
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:

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

Cool, but not yet...

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

Then ... mvn install

Yahoooo !

[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.


javajoshw said...

I have been trying to follow your advice but I can't get it to work yet. I am using the current nightly build CI-283. I get the following error after I change the pom to point to 1.0.0.RELEASE.

[INFO] ------------------------------------------------------------------------
[INFO] Compilation failure

C:\Downloads\App Server\SpringSource\SBI\spring-flex-1.0.1.CI-283-with-dependenc
java:[6,40] cannot find symbol
symbol : class AuthenticationResultUtils
location: package org.springframework.flex.security

C:\Downloads\App Server\SpringSource\SBI\spring-flex-1.0.1.CI-283-with-dependenc
java:[14,15] cannot find symbol
symbol : variable AuthenticationResultUtils
location: class org.springframework.flex.samples.secured.SecurityHelper

Stas Ostapenko said...

Hi javajoshw, thanks for comment !

Aha, I see, they made some changes in testdive regarding security stuff. Well, here is the way to make thins work... We really need to change version of spring-flex dependency. Since there is no Maven 2 repo for Spring BlazeDS integration nightly builds we need to install it manually. Follow the instructions provided here. It works ! :)