org.granite.tide.TideServiceInvoker error

109 views
Skip to first unread message

Cindy Marin

unread,
Sep 30, 2013, 10:08:00 PM9/30/13
to gran...@googlegroups.com

I've been trying to migrate from a project with spring mvc, hibernate, blazeds to graniteds.

I have everything setup with the default configuration according with this granite tutorials.

But now I need to use the Tide api , which is the one that is gonna allow my app to manage the lazy loading of detached objects in my flex client.

but i'm having this error =(:

destination: spring
- method: getApplicationSettings
- exception: java.lang.NoSuchMethodException: org.granite.tide.TideServiceInvoker.getApplicationSettings()


here the service-config.xml

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

<!-- ********************** services ********************** -->

<services>

   
<service  id="granite-service"
             
class="flex.messaging.services.RemotingService"
             
messageTypes="flex.messaging.messages.RemotingMessage" >

       
<destination id="spring">

           
<channels>
               
<channel ref="my-amf"/>
           
</channels>

           
<properties>
               
<factory>tideSpringFactory</factory>


           
</properties>

       
</destination>

   
</service>

</services>


<!-- ********************** factories ********************** -->

<!--

! Declare tideSpringFactory service factory.

!-->


<factories>

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

</factories>


<!-- ********************** channels ********************** -->

<channels>

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

       
<endpoint uri="http://{server.name}:{server.port}/{context.root}/graniteamf/amf" class="flex.messaging.endpoints.AMFEndpoint" /> <!---->

   
</channel-definition>

</channels>

the granite.config.xml

<granite-config scan="true">

     <tide-components>

        <tide-component annotated-with="org.granite.messaging.service.annotations.RemoteDestination"/>

    </tide-components>


</granite-config>


from the error what I understand is that the remoteobject cannot match the getApplicationSettings method in my service layer, but i can't understand where is the link between the destination in my service-config and the class that acts like service , which is the one with the method list in the error.


-----------------

ok, I think that what i need to do is to annotate the class that acts like the service layer with : @RemoteDestination, so according to this tutorial, the properties of this annotation are

The annotation supports the following attributes:

id is mandatory and is the destination name
source is mandatory and should be the name of the Spring component
service is optional if there is only one service for RemotingMessage defined in services-config.xml. Otherwise this should be the name of the service.
channel is optional if there is only one channel defined in services-config.xml. Otherwise this should be the id of the target channel.
channels may be used instead of channel to define a failover channel.
factory is optional if there is only one factory in services-config.xml. Otherwise this should be the factory id.
securityRoles is an array of role names for securing the destination.

But even doing this i'm having the same error. I need some help here, the documentation is confuse.

Kris Hofmans

unread,
Oct 1, 2013, 4:15:33 AM10/1/13
to gran...@googlegroups.com
Hi,

We're missing two small piece of code that could clarify things.

How does the code on the client (as3) look that you are using to perform the call?

And what's the declaration of your springbean (incl annotations).

Kris


--
 
---
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Granite Data Services Forum.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse graniteds+...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .

Cindy Marin

unread,
Oct 1, 2013, 7:55:18 PM10/1/13
to gran...@googlegroups.com
So, After follow some suggestions made by Kris, we did the following changes in the client side.
 
we are using Cairgorn 2, =(. 
so we add in the constructor delegate the method that retrieves the spring context (Spring.getInstance().getSpringContext();), and the call of the method that is required trough the tideContext  :

 public class ContainerDelegate{

               private var _tideContext:Context;

               public function ContainerDelegate( responder:IResponder){
                     this._responder = responder;
                     this._tideContext = Spring.getInstance().getSpringContext();
               }
               public function getApplication(url:String):void
              {
                      var call:Object =this._tideContext.spring.getApplicationSettings(url);
                      call
.addResponder(_responder);
               }


in the backend , we have a god class that implements multiple interfaces, annotated like:
one interface:
@RemoteDestination(id = "spring", source = "appListFacade", service = "granite-service",channel = "my-amf")
public interface AppListFacade {

    public Applications getApplicationSettings(String url) throws ServiceException;
}


and the implementation:
@Service(value = "appListFacade")
public class CatalogFacadeImpl implements   CategoryFacade,ContainerFacade,ProductFacade,ProductOptionFacade,ProductValueFacade,ProductStatusFacade,AttributeToValuesFacade,UserFacade,EmailFacade,FileFacade,PaypalTransactionFacade,OrderFacade,AppListFacade,DiscountsFacade{
...}

but now the error is:

operation=invokeComponent
source=null
mx.messaging.messages.RemotingMessage (@1de441f1)


any ideas?

wdrai

unread,
Oct 10, 2013, 10:35:30 AM10/10/13
to gran...@googlegroups.com
1. You have mixed some Tide and non-Tide configurations

2. When using Tide, you don't have to specify anything on the @RemoteDestination, Tide will use the Spring bean name or class

@RemoteDestination
public interface AppListFacade {

    public Applications getApplicationSettings(String url) throws ServiceException;
}

3. On the client, tideContext.spring does not correspond to anything, you should use this:


public class ContainerDelegate{

               private var _tideContext:Context;

               public function ContainerDelegate( responder:IResponder){
                     this._responder = responder;
                     this._tideContext = Spring.getInstance().getSpringContext();
               }
               public function getApplication(url:String):void
              {

                      var call:Object =this._tideContext.appListFacade.getApplicationSettings(url);
                      call
.addResponder(_responder);
               }

4. Even if you are using Cairngorm which works fine with default Flex Responders, it would be better to use 'native' Tide responders:

public class ContainerDelegate{

                private var _tideContext:Context = Spring.getInstance().getSpringContext();              
                private var _responder:ITideResponder;

               public function ContainerDelegate( responder:ITideResponder){
                     this._responder = responder;


               }
               public function getApplication(url:String):void
              {

                     _tideContext.appListFacade.getApplicationSettings(url, _responder);
               }

Cindy Marin

unread,
Oct 10, 2013, 5:44:53 PM10/10/13
to gran...@googlegroups.com
Hi William!!
Thanks for your help!

I did the changes that you said but it seems that it couldn't find the destination.
I understood that the _tideContext.spring was the link with it, because that I used it like this.


the error is still the same:

Couldn't establish a connection to 'server'
[MessagingError message='Destination 'server' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']

and it couldn't find the source?

operation=invokeComponent
source=null
mx.messaging.messages.RemotingMessage (@1de441f1)

I really appreciate your help, I've been working almost two weeks trying to connect this proyect with granite, we thought it could help us with the lazy problems in our flex client. 
do you have any other suggestions? if so, please let me know.

Cindy Marin

unread,
Oct 10, 2013, 5:45:27 PM10/10/13
to gran...@googlegroups.com
Hi!!

I just realize that the person before me was using a customized class as a factory in the service-config.xml, this class implements another class call FlexFactory.



here the code:


in the service-config.xml

 <factories>
        <factory id="spring" class="com.bamboo.common.factory.SpringFactory"/>
    </factories>

and the class SpringFactory, I think that this is the problem, i'm trying to understand why this person did this, so maybe I can understand why the configuration with tide doesn't work:

public class SpringFactory implements FlexFactory {


    private static final String SOURCE = "source";

    public SpringFactory()
    {
    }

    public void initialize(String s, ConfigMap configmap)
    {
    }

    public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
    {
        SpringFactoryInstance instance = new SpringFactoryInstance(this,id, properties);

        instance.setSource(properties.getPropertyAsString("source", instance.getId()));

        return instance;
    }

    public Object lookup(FactoryInstance inst)
    {
        SpringFactoryInstance factoryInstance = (SpringFactoryInstance)inst;

        return factoryInstance.lookup();
    }

    static class SpringFactoryInstance extends FactoryInstance
    {

        public String toString()
        {
            return (new ToStringBuilder("SpringFactory instance for id=")).append(getId()).append(" source=").append(getSource()).append(" scope=").append(getScope()).toString();
        }

        public Object lookup()
        {
            return BeanFactory.getBean(getSource());
        }

        SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties)
        {
            super(factory, id, properties);
        }
    }
}


but now , with tide we are using the tideSpringFactory

William Draï

unread,
Oct 10, 2013, 6:21:23 PM10/10/13
to gran...@googlegroups.com
Try with in your services-config.xml :

<factories>

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

</factories>

Or even better, destroy your services-config.xml and use the spring mvc configuration. http://www.graniteds.org/public/docs/3.0.0/docs/reference/flex/en-US/html/graniteds.spring.html#spring.tidemvcconfig

Basically, you just need to configure the Spring MVC dispatcher servlet in web.xml, create a (mostly) empty dispatcher-servlet.xml file and configure the server-filter in the spring application context.




2013/10/10 Cindy Marin <lasl...@gmail.com>

Cindy Marin

unread,
Oct 10, 2013, 8:07:08 PM10/10/13
to gran...@googlegroups.com
we are already using :
<factories>

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

</factories>


I mentioned that we were implementing the FlexFactory  before, because I thought it could be connected with the problem.

and about the MVC configuration I tried as well, but it didn't work at first hand, I could try again anyways. let you know.

thanks!

Cindy Marin

unread,
Oct 11, 2013, 10:28:09 AM10/11/13
to gran...@googlegroups.com
another hint!

when i start up the server, and access to this url http://localhost:8080/graniteamf/amf

I got this error:

09:57:24,051 ERROR AMFMessageFilter:160 - AMF message error
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:323)
at org.granite.messaging.amf.io.AMF0Deserializer.readHeaders(AMF0Deserializer.java:94)
at org.granite.messaging.amf.io.AMF0Deserializer.<init>(AMF0Deserializer.java:76)
at org.granite.messaging.webapp.AMFMessageFilter.doAMFFilter(AMFMessageFilter.java:128)
at org.granite.messaging.webapp.AMFMessageFilter.doFilter(AMFMessageFilter.java:102)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
--


Cindy Marin
Mobil +58 (0) 424 218 2556

William Draï

unread,
Oct 11, 2013, 10:38:24 AM10/11/13
to gran...@googlegroups.com
This is a good sign, the graniteds servlet is responding so it's correctly configured...
It responds only to POST requests so you can't directly test it from a browser.



2013/10/11 Cindy Marin <lasl...@gmail.com>

Cindy Marin

unread,
Oct 11, 2013, 11:51:58 AM10/11/13
to gran...@googlegroups.com
same error with the MVC setup.
Couldn't establish a connection to 'server'
[MessagingError message='Destination 'server' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']

is 'server' the destination? if so, it should be 'spring' 


--
 
---
Vous recevez ce message car vous êtes abonné à un sujet dans le groupe Google Groupes "Granite Data Services Forum".
Pour vous désabonner de ce sujet, visitez le site https://groups.google.com/d/topic/graniteds/Vr0DyhhYWDo/unsubscribe.
Pour vous désabonner de ce groupe et de tous ses sujets, envoyez un e-mail à l'adresse graniteds+...@googlegroups.com.

Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .

William Draï

unread,
Oct 11, 2013, 11:59:49 AM10/11/13
to gran...@googlegroups.com
Well can you post your full config ?
web.xml, services-config.xml, application-context.xml


2013/10/11 Cindy Marin <lasl...@gmail.com>
Reply all
Reply to author
Forward
0 new messages