Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to handle custom Java exception in Flex app
    primarykey
    data
    text
    <p>we are using BlazeDS as a proxy between Flex and Java. The approach is the same as in (<a href="http://www.flexpasta.com/index.php/2008/05/16/exception-handling-with-blazeds-and-flex/" rel="nofollow noreferrer">http://www.flexpasta.com/index.php/2008/05/16/exception-handling-with-blazeds-and-flex/</a>) </p> <p>Java exception declaration:</p> <pre><code>public class FlexException extends RuntimeException { private String name = 'John'; public FlexException(String message) { super(message); } public String getName() { return name; } } </code></pre> <p>Then, we are throwing it:</p> <pre><code>public void testMethod(String str) throws Exception { throw new FlexException("Custom exception"); } </code></pre> <p>Flex part:</p> <pre><code>private function faultHandler(event:FaultEvent):void { var errorMessage:ErrorMessage = event.message as ErrorMessage; trace("error++"); } </code></pre> <p>and remote object is instantiated here:</p> <pre><code>&lt;mx:RemoteObject id="mySample" destination="mySample" channelSet="{cs1}" fault="faultHandler(event)" /&gt; </code></pre> <p>But in <code>event.fault</code> I get "Server.Processing" and <code>event.faultString</code> equals "There was an unhandled failure on the server. Custom exception" How can I receive the data is specified in exception props ?</p> <p>UPDATE: Configuration files: messaging-config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p></p> <pre><code>&lt;adapters&gt; &lt;adapter-definition id="actionscript" class="flex.messaging.services.messaging.adapters.ActionScriptAdapter" default="true" /&gt; &lt;!-- &lt;adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter"/&gt; --&gt; &lt;/adapters&gt; &lt;default-channels&gt; &lt;channel ref="my-polling-amf"/&gt; &lt;/default-channels&gt; </code></pre> <p></p> <p>proxy-config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;service id="proxy-service" class="flex.messaging.services.HTTPProxyService"&gt; &lt;properties&gt; &lt;connection-manager&gt; &lt;max-total-connections&gt;100&lt;/max-total-connections&gt; &lt;default-max-connections-per-host&gt;2&lt;/default-max-connections-per-host&gt; &lt;/connection-manager&gt; &lt;allow-lax-ssl&gt;true&lt;/allow-lax-ssl&gt; &lt;/properties&gt; &lt;adapters&gt; &lt;adapter-definition id="http-proxy" class="flex.messaging.services.http.HTTPProxyAdapter" default="true"/&gt; &lt;adapter-definition id="soap-proxy" class="flex.messaging.services.http.SOAPProxyAdapter"/&gt; &lt;/adapters&gt; &lt;default-channels&gt; &lt;channel ref="my-amf"/&gt; &lt;/default-channels&gt; &lt;destination id="DefaultHTTP"&gt; &lt;/destination&gt; &lt;/service&gt; </code></pre> <p>remoting-config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p></p> <pre><code>&lt;adapters&gt; &lt;adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/&gt; &lt;/adapters&gt; &lt;default-channels&gt; &lt;channel ref="my-amf"/&gt; &lt;/default-channels&gt; </code></pre> <p></p> <p>services-config.xml</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; </code></pre> <p></p> <pre><code>&lt;services&gt; &lt;service-include file-path="remoting-config.xml" /&gt; &lt;service-include file-path="proxy-config.xml" /&gt; &lt;service-include file-path="messaging-config.xml" /&gt; &lt;/services&gt; &lt;security&gt; &lt;login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/&gt; &lt;!-- Uncomment the correct app server &lt;login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss"&gt; &lt;login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/&gt; &lt;login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/&gt; &lt;login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/&gt; --&gt; &lt;!-- &lt;security-constraint id="basic-read-access"&gt; &lt;auth-method&gt;Basic&lt;/auth-method&gt; &lt;roles&gt; &lt;role&gt;guests&lt;/role&gt; &lt;role&gt;accountants&lt;/role&gt; &lt;role&gt;employees&lt;/role&gt; &lt;role&gt;managers&lt;/role&gt; &lt;/roles&gt; &lt;/security-constraint&gt; --&gt; &lt;/security&gt; &lt;channels&gt; &lt;channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"&gt; &lt;endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/&gt; &lt;/channel-definition&gt; &lt;channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel"&gt; &lt;endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/&gt; &lt;properties&gt; &lt;add-no-cache-headers&gt;false&lt;/add-no-cache-headers&gt; &lt;/properties&gt; &lt;/channel-definition&gt; &lt;channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel"&gt; &lt;endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/&gt; &lt;properties&gt; &lt;polling-enabled&gt;true&lt;/polling-enabled&gt; &lt;polling-interval-seconds&gt;4&lt;/polling-interval-seconds&gt; &lt;/properties&gt; &lt;/channel-definition&gt; &lt;!-- &lt;channel-definition id="my-http" class="mx.messaging.channels.HTTPChannel"&gt; &lt;endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/&gt; &lt;/channel-definition&gt; &lt;channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel"&gt; &lt;endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/&gt; &lt;properties&gt; &lt;add-no-cache-headers&gt;false&lt;/add-no-cache-headers&gt; &lt;/properties&gt; &lt;/channel-definition&gt; --&gt; &lt;/channels&gt; &lt;logging&gt; &lt;target class="flex.messaging.log.ConsoleTarget" level="Debug"&gt; &lt;properties&gt; &lt;prefix&gt;[BlazeDS] &lt;/prefix&gt; &lt;includeDate&gt;true&lt;/includeDate&gt; &lt;includeTime&gt;true&lt;/includeTime&gt; &lt;includeLevel&gt;true&lt;/includeLevel&gt; &lt;includeCategory&gt;true&lt;/includeCategory&gt; &lt;/properties&gt; &lt;filters&gt; &lt;pattern&gt;Endpoint.*&lt;/pattern&gt; &lt;pattern&gt;Service.*&lt;/pattern&gt; &lt;pattern&gt;Configuration&lt;/pattern&gt; &lt;/filters&gt; &lt;/target&gt; &lt;/logging&gt; &lt;system&gt; &lt;redeploy&gt; &lt;enabled&gt;false&lt;/enabled&gt; &lt;!-- &lt;watch-interval&gt;20&lt;/watch-interval&gt; &lt;watch-file&gt;{context.root}/WEB-INF/flex/services-config.xml&lt;/watch-file&gt; &lt;watch-file&gt;{context.root}/WEB-INF/flex/proxy-config.xml&lt;/watch-file&gt; &lt;watch-file&gt;{context.root}/WEB-INF/flex/remoting-config.xml&lt;/watch-file&gt; &lt;watch-file&gt;{context.root}/WEB-INF/flex/messaging-config.xml&lt;/watch-file&gt; &lt;watch-file&gt;{context.root}/WEB-INF/flex/data-management-config.xml&lt;/watch-file&gt; &lt;touch-file&gt;{context.root}/WEB-INF/web.xml&lt;/touch-file&gt; --&gt; &lt;/redeploy&gt; &lt;/system&gt; </code></pre> <p></p> <p>Spring config:</p> <pre><code>&lt;bean id="mySample" class="ru.crystals.pos.testFlexConnection.Test"&gt; &lt;constructor-arg ref="defaultMessageTemplate" /&gt; &lt;flex:remoting-destination /&gt; &lt;/bean&gt; </code></pre> <p>This is a log from Tomcat</p> <pre><code> [BlazeDS]03/23/2010 14:46:51.870 [DEBUG] [Endpoint.AMF] Serializing AMF/HTTP res ponse Version: 3 (Message #0 targetURI=/1/onStatus, responseUR|-) (Typed Object #0 'flex.messaging.messages.ErrorMessage') headers = (Object #1) rootCause = null body = null correlationId = "2EB1C972-B32B-03BA-825C-8AD8B9DFCEF8" faultDetail = null faultString = "There was an unhandled failure on the server. Custom except ion" clientId = "89FB2149-6E0F-4FB6-4D5E-EC838139EE90" timeToLive = 0.0 destination = "mySample" timestamp = 1.269344811854E12 extendedData = null faultCode = "Server.Processing" messageId = "89FB2149-6E1A-4453-6E45-55A93BBA50AF" </code></pre> <p>Here is what I get in Flex when setting a breakpoint in the onFaultHandler: <a href="http://my.picresize.com/vault/RS9I8P87PH.jpg" rel="nofollow noreferrer">alt text http://my.picresize.com/vault/RS9I8P87PH.jpg</a> So the quesion is why rootClause is null? Where is my FlexException with name = 'John'.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload