AMF message error java.io.EOFException implementing graniteDS

1.3k views Asked by At

Hopefully someone can help me with this.

I'm working on a project with Spring MVC + Hibernate + Tomcat 7 in the backend and blazeDS + Cairngorm in the frontend, and we need to migrate from blazeDS to graniteDS but I have a :Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 500 when trying to connect with the backend, and in the tomcat console:

ERROR AMFMessageFilter:160 - AMF message error java.io.EOFException at java.io.DataInputStream.readUnsignedShort

I don't understand what i'm missing here , I've been looking on the internet and the most representative resources i found were this ones: http://www.graniteds.org/public/docs/3.0.0/docs/reference/flex/en-US/html/index.html, http://narup.blogspot.com/2008/08/getting-started-project-graniteds-with.html

thanks in advance!

here my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee       

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
 version="2.4">

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
<listener-class>com.bamboo.common.factory.Log4JContextListener</listener-class>
</listener>

<!-- Spring listener -->
<listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-

class>
</listener>


<!-- read services-config.xml file at web application startup   -->
<listener>

<listener-class>org.granite.config.GraniteConfigListener</listener-class>

</listener>

<!-- Spring listener for web-scopes (request, session)  -->
<listener>
<listener-class>
    org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>


<!-- handle AMF requests ([de]serialization)  -->
<filter>

<filter-name>AMFMessageFilter</filter-name>

<filter-class>org.granite.messaging.webapp.AMFMessageFilter</filter-class>

</filter>

<filter-mapping>

<filter-name>AMFMessageFilter</filter-name>

<url-pattern>/graniteamf/*</url-pattern>

</filter-mapping>

<servlet>

<servlet-name>dispatcher</servlet-name>
<servlet-class>
    org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>


<!-- handle AMF requests (execution)  -->
<servlet>

<servlet-name>AMFMessageServlet</servlet-name>

<servlet-class>org.granite.messaging.webapp.AMFMessageServlet</servlet-class>

<load-on-startup>1</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>AMFMessageServlet</servlet-name>

<url-pattern>/graniteamf/*</url-pattern>

</servlet-mapping>

</web-app>

and the services-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<services-config>

<services>
<service-include file-path="remoting-config.xml" />
</services>

<factories>

<factory id="springFactory" class="org.granite.spring.SpringServiceFactory" />

</factories>
<channels>

<channel-definition  id="my-amf" class="mx.messaging.channels.AMFChannel" >

    <endpoint url="http://{server.name}:{server.port}/{context.root}/graniteamf/amf"  

class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
</services-config>

the remote-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<service  id="remoting-service" 
class="flex.messaging.services.RemotingService"  

messageTypes="flex.messaging.messages.RemotingMessage" >

<destination id="remoteObject-destination">      
    <channels>
        <channel ref="my-amf"/>
    </channels>
    <properties>
        <factory>springFactory</factory>
        <source>catalogFacade</source>
        <scope>application</scope>        
    </properties>
</destination>

</service>
1

There are 1 answers

1
zenbeni On BEST ANSWER

It seems you have a deserialization problem. The stack says that it is trying to read an unsigned short from your AMF and it can't as the stream has no more bytes to read. (basically trying to read more data from AMF than it contains) Your java classes and your AS3 classes are not synchronised. Did you modify your java classes and forgot to regenerate your AS3 files with the granite plugin (or maven plugin)? Adding a field on the java side without regenerating could be the reason.

Granite serialization system is based on IExternalizable on AS3 side: it is explicit (a huge difference with BlazeDS which can adapt data at runtime and can convert type fields for instance at runtime).

Check your generation of AS3 files and eventually the granite server configuration.