My Errai 2.4.4 to 3.0.1 upgrade experience
markonamac Aug 4, 2014 3:30 PMFirst of all... greeting Errai team and Errai fans. I'm a huge fan too. I'm a bit new to posting so please forgive me if I don't get it right. I've been working with Errai, on and off, since I first discovered it back in 2011. My investiment in it is now substancial. Although I must admit that I don't know it as well as I would like to. I wish I had the time to dig deep, understand it thoroughly, and contribute back to the project. I hope, one day, to get there.
My current GWT project is using Errai 2.4.4. The other big tool in the toolbox is SmartGWT. I don't use development mode. I make a change, compile a WAR (with Maven), and deploy it to an off-node Tomcat (7.0.35). 90% of what I use Errai for is client side. It is the most superb tool for decoupling screen widgets, dialog boxes, and other client side objects. The remote bus is not used. In fact, "erraiBusRemoteCommunicationEnabled" is set to false. All communication to the server happens through Errai JAX-RS. I make heavy use of the client side (sync) bean manager and CDI, and finally, Errai Navigation. The app.gwt.xml contains this:
[code]
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
<inherits name="com.smartclient.theme.blackops.BlackOps"/>
<inherits name="org.jboss.errai.bus.ErraiBus"/>
<inherits name="org.jboss.errai.ioc.Container"/>
<inherits name="org.jboss.errai.enterprise.Jaxrs"/>
<inherits name="org.jboss.errai.ui.nav.Navigation"/>
[/code]
Which brings me to the reason for this post. It was a problem with Errai Navigation where, on page load, it would only show me the top 100 pixels of the "default" page. The code in PostConstruct of the EntryPoint class had worked... just over a year ago when I first tried Errai Navigation...
[code]
VLayout page = new VLayout(); // A SmartGWT vertical layout construct
page.setWidth100();
VxBanner banner = instanceBanner.get();
page.addMember(banner);
page.addMember(navigation.getContentPanel().asWidget());
VxFooter footer = instanceFooter.get();
page.addMember(footer);
RootPanel.get().add(page);
[/code]
Between the banner DIV and my actual "default" page DIV, there were three more DIVs, each a parent of the default page DIV. One, I assume belonged to the VLayout. The other two, I assume were coming from Errai Navigation. One of those was set to a fixed height of 100px, with overflow: hidden. Hence, my problem. If only the overflow had been set to visible!
To help me identify where this DIV is coming from... and possibly fix it as well... I decided to use the technique described in the Errai reference called "11.2.6. Overriding the default Nagivating Panel type". I found this in the 2.4.4 reference... as well as the 2.4.3 and 2.4.2 references. Unfortunately, the actual interface "NavigatingContainer" is not in the 2.4.4 JAR my Maven had fetched.
Digging a little, I discovered it IS in the 3.0.1 JAR. So... ok.... lets upgrade.
I edited my Maven POM, changing the Errai version from "2.4.4" to "3.0.1". mvn clean. mvn package.
Errors. Well... not unexpected. The same error over and over:
[CODE]
[INFO] generating ioc bootstrapping code...
[ERROR] java.util.concurrent.ExecutionException: org.jboss.errai.ioc.rebind.ioc.exception.UnsatisfiedDependenciesException: @> com.vmedex.uiapp.client.local.banner.VxBanner
[ERROR] - field org.jboss.errai.codegen.meta.MetaField:com.vmedex.uiapp.client.local.banner.VxBanner.dispatcher could not be satisfied for type: org.jboss.errai.bus.client.api.messaging.RequestDispatcher
[ERROR] Message: can't resolve bean: org.jboss.errai.bus.client.api.messaging.RequestDispatcher ( @Default )
[ERROR]
[ERROR] at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
[ERROR] at java.util.concurrent.FutureTask.get(FutureTask.java:111)
[ERROR] at org.jboss.errai.config.rebind.AsyncGenerators$FutureWrapper.get(AsyncGenerators.java:112)
[/CODE]
Every instance of:
[CODE]
@Inject
private RequestDispatcher dispatcher;
[/CODE]
in my app, was causing this. I'm hoping you can help me understand why. I checked the JAR... its there!
So I went a'Googling for a 3.0.1 example app... which I found at GitHub. In it, MessageBuilder...callNowWith was passing "bus" instead of "dispatcher". So, I removed every instance of the @Inject... dispatcher from my app, and sure enough, successful build of the WAR.
Not so bad. Thought I was done, but... no. I deployed the WAR and opened the app... and none of my bus subscription callbacks were firing. yuk. Referring back to the example from GitHub, I could only find one other difference... Instead of the:
[CODE]
@Inject
private MessageBus bus;
[/CODE]
I was using throughout in 2.4.4, the example used:
[CODE]
private ClientMessageBus bus = (ClientMessageBus) ErraiBus.get();
[/CODE]
I tested using ErraiBus.get() instead of the @Inject on a couple of classes, and sure enough! The publish/subscribe (bus) between those classes started working again.
Any insight you can offer about why I encountered these two particular issues after upgrading to 3.0.1 would be greatly appreciated. I still haven't tackled the original issue with Navigation yet... but I'm more concerned now with having to make such sweeping changes to the code base to get things working. I'm sure I've just done something wrong. I am happy to provide any other details you need.
My profound thanks for such a great GWT enhancement. Errai rocks!
Mark