JBoss Developer: Message List - Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Most recent forum messageshttps://developer.jboss.org/community/errai?view=discussionsJive Engage2012-05-01T21:23:53Z2012-05-01T21:23:53ZenRe: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-05-01T21:23:53Z2012-05-01T21:23:53Z<!-- [DocumentBodyStart:b5f8aa8a-710a-4849-9242-931b42ded901] --><div class="jive-rendered-content"><p>Good to know.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>Thanks for all your help! </p></div><!-- [DocumentBodyEnd:b5f8aa8a-710a-4849-9242-931b42ded901] --><img src='/beacon?t=1481332318131' />2012-05-01T21:23:53Z4 years 7 months ago0Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Christian Sadilek/people/csado-not-reply@jboss.com2012-05-01T21:22:32Z2012-05-01T21:22:32Z<!-- [DocumentBodyStart:b0e01e23-f954-4afb-a1e4-c4cf4f6295e0] --><div class="jive-rendered-content"><p>No, the latter is currently not possible.</p></div><!-- [DocumentBodyEnd:b0e01e23-f954-4afb-a1e4-c4cf4f6295e0] -->2012-05-01T21:22:32Z4 years 7 months ago10Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-05-01T21:11:44Z2012-05-01T21:11:44Z<!-- [DocumentBodyStart:d2a62d87-0a0f-4083-87d6-165da282ad98] --><div class="jive-rendered-content"><p>So the ErraiServlet creates the MessageBus (during its init) and I'd access it after initializing the servlet. That should work. I'll have to restructure our code so that we startup the ErraiServlet first and then the rest of the code that initializes the Spring container.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>But do you know if there's a way for me to inject a MessageBus that I create, into the ErraiServlet so that it uses that bus instead of creating a new one? If I could do that, I might not have to restructure my code.</p></div><!-- [DocumentBodyEnd:d2a62d87-0a0f-4083-87d6-165da282ad98] -->2012-05-01T21:11:44Z4 years 7 months ago20Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Christian Sadilek/people/csado-not-reply@jboss.com2012-05-01T20:28:12Z2012-05-01T20:28:12Z<!-- [DocumentBodyStart:d134223e-2b0a-49f8-957a-55200284f715] --><div class="jive-rendered-content"><p>Yes, that's the problem then. You could override your ErraiServlet's init method. After calling super.init, the ErraiServiceSingleton should be initialized.</p></div><!-- [DocumentBodyEnd:d134223e-2b0a-49f8-957a-55200284f715] -->2012-05-01T20:28:12Z4 years 7 months ago30Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-05-01T20:14:47Z2012-05-01T20:14:47Z<!-- [DocumentBodyStart:071907f7-ccea-40a3-bda6-c7336e525466] --><div class="jive-rendered-content"><p>The instance of ServerMessageBus reported by ErraiService via ErraiServiceSingleton is indeed different from the instance that I'm creating and inializing with the RPC endpoints. </p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>I guess I have to figure out how I can either inject the MessageBus I'm creating into Errai.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>Either that or I need to delay the initializing of the RPC endpoints until such time that ErraiServiceSingleton has been created (and initialized) and then get a reference to the ServerMessageBus. At this point I could initialize the RPC endpoints with the message bus.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>Can you recommend an insertion point in the startup of the Errai servlet where I can do this? i.e. get a reference to the ServerMessageBus to do the RPC endpoints and to provide it to our Spring container?</p></div><!-- [DocumentBodyEnd:071907f7-ccea-40a3-bda6-c7336e525466] -->2012-05-01T20:14:47Z4 years 7 months ago40Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Christian Sadilek/people/csado-not-reply@jboss.com2012-04-30T22:02:47Z2012-04-30T22:00:56Z<!-- [DocumentBodyStart:dd2e3805-d946-4191-9259-c98cc6f5959d] --><div class="jive-rendered-content"><p>&lt;<span style="color: #555555; font-family: 'Lucida Sans', 'Lucida Sans Unicode', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #eef4f9;">When I turn off auto-discovery and subscribe the services myself, the call from the client never gets to the server. Instead, the client reports a NoSubscribersToDeliver exception.</span>&gt;</p><p>Yes, that's because the server bus communicates the subscriptions to the client on startup, which is why I think the bus instance you subscribe to is not the one used by Errai. The client does then not even bother sending the messages because there are no subscribers.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>&lt;<span style="color: #555555; font-family: 'Lucida Sans', 'Lucida Sans Unicode', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #eef4f9;">And when I turn on auto-discovery (even if I subscribe the services programmatically), it looks like there are two instances of the service object (Errai and Spring).</span>&gt;</p><p>Yes, you will end up with two instances of your Service, the one that you created plus the one created by Errai.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>So, you need to make sure you only have one Service instance and bus instance in your app. Take a look at ErraiServiceSingleton: It will provide you with an ErraiService instance that in turn provides access to the bus instance.</p></div><!-- [DocumentBodyEnd:dd2e3805-d946-4191-9259-c98cc6f5959d] -->2012-04-30T22:00:56Z4 years 7 months ago50Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-04-30T21:49:27Z2012-04-30T21:49:27Z<!-- [DocumentBodyStart:599a1450-3d6e-40cb-9208-09fc25c47450] --><div class="jive-rendered-content"><p>When I turn off auto-discovery and subscribe the services myself, the call from the client never gets to the server. Instead, the client reports a NoSubscribersToDeliver exception. </p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>And when I turn on auto-discovery (even if I subscribe the services programmatically), it looks like there are two instances of the service object (Errai and Spring). I'll try to get the message bus instance from the server object when its methos gets invoked - is that what you're asking for? I assume there's an API for me to get to the message bus object from within the server method?</p></div><!-- [DocumentBodyEnd:599a1450-3d6e-40cb-9208-09fc25c47450] -->2012-04-30T21:49:27Z4 years 7 months ago60Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Christian Sadilek/people/csado-not-reply@jboss.com2012-04-30T21:36:36Z2012-04-30T21:36:36Z<!-- [DocumentBodyStart:52acb5d8-b6fe-4e6e-aad6-e98d754af224] --><div class="jive-rendered-content"><p>Yeah I understand. So, when you turn off auto-discovery and subscribe to the service yourself, can you verify the bus instance you subscribed on is the same as the one which received the in-coming message? In our service processor we use the bus instance provided by the BootstrapContext.</p></div><!-- [DocumentBodyEnd:52acb5d8-b6fe-4e6e-aad6-e98d754af224] -->2012-04-30T21:36:36Z4 years 7 months ago70Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-04-30T20:46:31Z2012-04-30T20:46:31Z<!-- [DocumentBodyStart:ca3fe2aa-759b-4449-ac15-17ae21d97acd] --><div class="jive-rendered-content"><p>I think what's happening is that with both @Service annotations, both Spring and Errai are instantiating objects of the same type. But the auto-wiring that we depend on in the implementation of the methods, is done in the Spring instantiated object, not the Errrai instantiated object. But since the RPC call gets invoked on the Errai instantiated object, the call fails since none of the members of the object have been wired.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>When we used the 1.3.2Final library, we didn't used auto-discovery in Errai and instead made Spring and Errai work together (as I described in my first post). In short what we did was:</p><p>- instantiate Spring context</p><p>- instantiate Guice and Errai </p><p>- for all our services that were instantiated by Spring, interate through their interface and subscribe them as endpoints with Errai so that Errai thinks these are RPC service endpoints.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>It looks like that method doesn't work with the 2.0CR1 library - specifically that last part of subscribing endpoints with Errai programmatically.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>What we want to do is have Spring manage the objects (i.e. instantiate them, auto-wire them, etc) but have Errai use those objects when servicing a RPC call. Is there a different process you know of that we should be following?</p></div><!-- [DocumentBodyEnd:ca3fe2aa-759b-4449-ac15-17ae21d97acd] -->2012-04-30T20:46:31Z4 years 7 months ago80Re: Errai RPC problems when upgrading from 1.3.2Final to 2.09CR1Ajit Nair/people/ajitnairdo-not-reply@jboss.com2012-04-30T19:54:38Z2012-04-30T19:54:38Z<!-- [DocumentBodyStart:12786e3f-c6cd-48b0-b78f-12b7cafb3e9e] --><div class="jive-rendered-content"><p>Yes I am compiling with the 2.0 libraries. I followed the instruction set in the document for upgrading from 1.x to 2.0. </p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>The RPC calls from the client were not reaching the server. Other messages (such as createMessage() and createConversation()) seem to be working fine. It's just the RPC calls - createCall(). I verified that the names being registered are the same as well. </p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>I've made some progress from my last email. I found a problem in our code. Since we're using the Spring framework, our server side classes were annotated with the Spring @Service annotation, not the Errai @Service. This had been working with the Errai 1.3.2Final libraries, but maybe the 2.0 libraries perform stricter validation? Anyway, I went ahead and added the Errai annotation and now I see that the call from the client is making it to the server, which is good, but Spring seems to be confused and is not auto-wiring the components of those objects. So I'm now getting NullPointerExceptions when the server method gets executed.</p><p style="min-height: 8pt; padding: 0px;">&#160;</p><p>It's possible that I need to order the invocation of Spring and Errai differently. I'm looking into that right now. But if you have any ideas, that would be appreciated.</p></div><!-- [DocumentBodyEnd:12786e3f-c6cd-48b0-b78f-12b7cafb3e9e] -->2012-04-30T19:54:38Z4 years 7 months ago90