Monday, January 14, 2013

Invient Charts, Problem with TimeZone - always in UTC

The Problem


It seemed that all my InvientChart 0.8.6 charts in Vaadin were two hours behind where they should have been. And because I live in GMT + 2 it seemed like a timezone issue.

The solution


Before adding your chart to the UI add this component


            try {
                CustomLayout cl = new CustomLayout(new ByteArrayInputStream("
".getBytes())); addComponent(cl); } catch (IOException ex) { //should never happen log.warn("Should never happen",ex); }

Tuesday, January 8, 2013

Manage my time more effectively - Email and chats are the devil

Being used to being unfocused

I am lucky enough to work in a private office where I can closed the door and not be disturbed. But work email, Google chats and private Google mail really becomes a distraction. 
To make it worse, when I am not being distracted by mail and chat I check to see if I have new mail or chats periodically.
This really disrupts my train of thought.

The desired end result

While developing software focus is key!
No disruptions during pomodoros!

What I am going to do
Close my work email and gmail during 25 min pomodoros

Monday, January 7, 2013

2013 New Years Resolutions as a Java developer

I am going to focus on the following this year and blog about it.

Test driven development for everything I do

 

Doing things in a panic and rush comes back and bites.
Completely offline and modular test are a must.

Deploy one application to the Android Market

 

Deploy one application to the IOS Market

 

Become a GWT master

GWT is really one of the best frameworks I have seen in a long time. I've been dabbling for a long time, but I really want to be a master. That includes MVP 

Never lie on my timesheets

At one of the Java User groups at a new venue, one of my friends joked. "Look at that guy coming, you can see he is a Java developer, his eyes are red."
Long hours and stress is part of being a Java developer and I log 8 hours on my timesheet per day even though I spend much more.
People need to see how long I work.

Manage my time more effectively

Refine how I work. The Pomodoro Technique is a great starting point to working smart and working towards a end goal. But there needs to be more.

Do my Oracle Certified Java 8 Programmer course

Java 8 should be released close to the end of the year. If this is so, I would like to do a beta of the exam. If this is possible in South Africa.

Get involved a little with Java EE 7

 

Adopt a JSR

http://java.net/projects/adoptajsr/pages/Home

Monday, November 26, 2012

PhoneGAP without Javascript! My demo of GWT 2.5 at the JoziJUG


Live code demos are scary

I did a live code demo to a bunch of Java geeks at the JoziJUG event

1) The showcase application I demoed on a iPad3, Android 2.1 phone, Android 3 tab, Android 4 phone, Windows 2008 tab last night is downloadable from PhoneGap Build. 
https://build.phonegap.com/apps/249950/share
The plain ugly Hello World HTML version is also downloadable :https://build.phonegap.com/apps/249918/share
2) You can also give GWT 2.5 a spin , even if it's in Eclipse (Marius and Myron ) ;-) 
http://mojo.codehaus.org/gwt-maven-plugin/user-guide/archetype.html
3) You can also check out the fancy demo I hacked together using m-gwt and gwt-phonegap 
https://github.com/rjdkolb/jozijug_phonegapdemo
You will need to read Google's MVP to understand the concepts :https://developers.google.com/web-toolkit/doc/latest/DevGuideMvpActivitiesAndPlaces

To the real person who made this possible in GWT :
Daniel Kurka thank you!

To Google, GWT is evolving so nicely :)
Here is Google's closure-compiler that is now built into GWT 2.5
Java is so cool! 
Richard.

Below is me pretending to know something about Java :)


Wednesday, October 31, 2012

Java Community Process EC Elections 2012

The election results are out!


Here is how the Jozi JUG voted :



Most notably on the open seat side, here are the people who got elected.

London Java Community 164 votes (33%)

CloudBees 101 votes (20%)


Thanks to everyone who made the effort to vote.


More info here.

Thursday, October 11, 2012

Help Getting a GWT error : com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.

GWT can be painful sometimes

I was getting the following error while using GWT 2.4.0, GWT 2.5.0 and 2.5.1


[gwt:compile]
auto discovered modules [za.co.enerweb.ies.iesmobile]
Compiling module za.co.enerweb.ies.iesmobile
   Validating units:
      Ignored 1 unit with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
   [ERROR] An internal compiler exception occurred
com.google.gwt.dev.jjs.InternalCompilerException: Unexpected error during visit.
 at com.google.gwt.dev.jjs.ast.JVisitor.translateException(JVisitor.java:109)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:276)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
 at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
 at com.google.gwt.dev.jjs.ast.JCastOperation.traverse(JCastOperation.java:65)
 at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
 at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:116)
 at com.google.gwt.dev.jjs.ast.JDeclarationStatement.traverse(JDeclarationStatement.java:48)
 at com.google.gwt.dev.jjs.ast.JModVisitor$ListContextImmutable.traverse(JModVisitor.java:170)
 at com.google.gwt.dev.jjs.ast.JModVisitor.acceptWithInsertRemoveImmutable(JModVisitor.java:336)
 at com.google.gwt.dev.jjs.ast.JBlock.traverse(JBlock.java:83)
 at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
 at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:137)
 at com.google.gwt.dev.jjs.ast.JVisitor.accept(JVisitor.java:133)
 at com.google.gwt.dev.jjs.ast.JMethodBody.traverse(JMethodBody.java:82)
 at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
 at com.google.gwt.dev.jjs.ast.JMethod.visitChildren(JMethod.java:426)
 at com.google.gwt.dev.jjs.ast.JMethod.traverse(JMethod.java:395)
 at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:265)
 at com.google.gwt.dev.jjs.impl.UnifyAst.mainLoop(UnifyAst.java:902)
 at com.google.gwt.dev.jjs.impl.UnifyAst.exec(UnifyAst.java:627)
 at com.google.gwt.dev.jjs.JavaToJavaScriptCompiler.precompile(JavaToJavaScriptCompiler.java:604)
 at com.google.gwt.dev.jjs.JavaScriptCompiler.precompile(JavaScriptCompiler.java:33)
 at com.google.gwt.dev.Precompile.precompile(Precompile.java:278)
 at com.google.gwt.dev.Precompile.precompile(Precompile.java:229)
 at com.google.gwt.dev.Precompile.precompile(Precompile.java:141)
 at com.google.gwt.dev.Compiler.run(Compiler.java:232)
 at com.google.gwt.dev.Compiler.run(Compiler.java:198)
 at com.google.gwt.dev.Compiler$1.run(Compiler.java:170)
 at com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:88)
 at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger(CompileTaskRunner.java:82)
 at com.google.gwt.dev.Compiler.main(Compiler.java:177)
Caused by: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;
 at com.google.gwt.uibinder.rebind.W3cDocumentBuilder.startElement(W3cDocumentBuilder.java:127)
 at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
 at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
 at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
 at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
 at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
 at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
 at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
 at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)
 at com.google.gwt.uibinder.rebind.W3cDomHelper.documentFor(W3cDomHelper.java:74)
 at com.google.gwt.uibinder.rebind.UiBinderGenerator.getW3cDoc(UiBinderGenerator.java:204)
 at com.google.gwt.uibinder.rebind.UiBinderGenerator.generateOnce(UiBinderGenerator.java:174)
 at com.google.gwt.uibinder.rebind.UiBinderGenerator.generate(UiBinderGenerator.java:129)
 at com.google.gwt.core.ext.IncrementalGenerator.generateNonIncrementally(IncrementalGenerator.java:40)
 at com.google.gwt.dev.javac.StandardGeneratorContext.runGeneratorIncrementally(StandardGeneratorContext.java:657)
 at com.google.gwt.dev.cfg.RuleGenerateWith.realize(RuleGenerateWith.java:41)
 at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind(StandardRebindOracle.java:79)
 at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:276)
 at com.google.gwt.dev.shell.StandardRebindOracle.rebind(StandardRebindOracle.java:265)
 at com.google.gwt.dev.DistillerRebindPermutationOracle.getAllPossibleRebindAnswers(DistillerRebindPermutationOracle.java:91)
 at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleGwtCreate(UnifyAst.java:355)
 at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.handleMagicMethodCall(UnifyAst.java:433)
 at com.google.gwt.dev.jjs.impl.UnifyAst$UnifyVisitor.endVisit(UnifyAst.java:237)
 at com.google.gwt.dev.jjs.ast.JMethodCall.traverse(JMethodCall.java:243)
 at com.google.gwt.dev.jjs.ast.JModVisitor.traverse(JModVisitor.java:361)
 at com.google.gwt.dev.jjs.ast.JModVisitor.accept(JModVisitor.java:273)
 ... 37 more
      [ERROR] at MainPage.java(27): GWT.create(MainPage$MainPageUiBinder.class)
         com.google.gwt.dev.jjs.ast.JMethodCall
      [ERROR] at MainPage.java(27): (MainPage$MainPageUiBinder) GWT.create(MainPage$MainPageUiBinder.class)
         com.google.gwt.dev.jjs.ast.JCastOperation
      [ERROR] at MainPage.java(27): static MainPage$MainPageUiBinder uiBinder = (MainPage$MainPageUiBinder) GWT.create(MainPage$MainPageUiBinder.class)
         com.google.gwt.dev.jjs.ast.JDeclarationStatement
      [ERROR] at MainPage.java(23): {
  Page.$clinit();
  static MainPage$MainPageUiBinder uiBinder = (MainPage$MainPageUiBinder) GWT.create(MainPage$MainPageUiBinder.class);
}
         com.google.gwt.dev.jjs.ast.JBlock
      [ERROR] at MainPage.java(23): {
  Page.$clinit();
  static MainPage$MainPageUiBinder uiBinder = (MainPage$MainPageUiBinder) GWT.create(MainPage$MainPageUiBinder.class);
}
         com.google.gwt.dev.jjs.ast.JMethodBody
      [ERROR] at MainPage.java(23): private static final void $clinit();

         com.google.gwt.dev.jjs.ast.JMethod 
 
The UI Binder Java code
public class MainPage extends Page {

    @UiField
    ListPanel list;
    private static MainPageUiBinder uiBinder = GWT.create(MainPageUiBinder.class);

    interface MainPageUiBinder extends UiBinder {
    }

    public MainPage() {
        initWidget(uiBinder.createAndBindUi(this));

 
 

The solution

 There was a very old version old version of xercesImpl 2.6.2 included by Jersey
       
        
            com.sun.jersey.contribs
            jersey-atom-abdera
            1.8
        

So find it and banish it to the place it came from and don't forget to clean package
 
          
            com.sun.jersey.contribs
            jersey-atom-abdera
            1.8
          
            
              xercesImpl
              xerces
            
          
        
       
 
 
 

Friday, August 31, 2012

Et tu, Richard. I stabbed myself in the back with Vaadin and Lombok

The problem I struggled with for days... 

Take a simple Vaadin tab sheet.
Add a sheet , remove a sheet etc. Nothing hard at all right ?

I was getting the below error when the screen was repainted.
 
SEVERE: Terminal error:
java.lang.NullPointerException
 at com.vaadin.ui.TabSheet.paintContent(TabSheet.java:390)
 at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
 at com.vaadin.ui.AbstractSplitPanel.paintContent(AbstractSplitPanel.java:235)
 at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
 at com.vaadin.ui.AbstractOrderedLayout.paintContent(AbstractOrderedLayout.java:187)
 at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
 at com.vaadin.ui.Panel.paintContent(Panel.java:269)
 at com.vaadin.ui.Window.paintContent(Window.java:641)
 at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:781)
 at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.writeUidlResponce(AbstractCommunicationManager.java:1046)
 at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:927)
 at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:794)
 at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
 at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
 at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:169)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:168)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
 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:405)
 at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
 at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
 at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
 at java.lang.Thread.run(Thread.java:722)


There seems to be a Vaadin ticket for this : http://dev.vaadin.com/ticket/4179  

The culprit

My favorite java Add On : Lombok
Actually I can't blame Lombok or Vaadin, this is my misuse of Lombok inside Vaadin

I decorated my component with @Data
That means the equals and hashCode were generated by all the fields in the class.

com.vaadin.ui.TabSheet.java contains an internal representation of the tabs in a HashMap tabs.

If the hashmap can not find your component because the equals has changed. you will get what I did.


            Tab tab = tabs.get(component);//will return null

            target.startTag("tab");
            if (!tab.isEnabled() && tab.isVisible()) {