GXT 3 XTemplate: Custom Formatter – ClassNotFoundException Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of GXT 3 XTemplate: Custom Formatter – ClassNotFoundException without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am trying to use a custom formatter to turn a boolean into “Yes” or “No” and have run into a roadblock.

My IDE (Eclipse) does not indicate any errors but when I try to compile I receive

[ERROR] Annotation error: cannot resolve foobar.client.formatter.YesNoFormatter – exception: ClassNotFoundException

followed by a few other exceptions that appear to stem from this exception. I understand what a ClassNotFoundException indicates however I cannot figure out why I would be getting it since, as my code shows, the YesNoFormatter class is located in foobar.client.formatter and I can access it through

GWT.log("True: " + YesNoFactory.getFormat().format(Boolean.TRUE);

I am using GXT 3.1.0 and GWT 2.6.1.

Could anybody have an idea of why I am getting this exception? The example given at http://docs.sencha.com/gxt-guides/3/utility/xtemplates/XTemplates.html doesn’t mention anything (as far as I can see) about these classes needing to be in specific locations so I am at a loss.


package foobar.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.sencha.gxt.core.client.XTemplates.FormatterFactories;
import com.sencha.gxt.core.client.XTemplates.FormatterFactory;

public class TestClass implements EntryPoint {

    @FormatterFactories(@FormatterFactory(factory=YesNoFactory.class, name="yesNo"))
    public interface Renderer extends XTemplates {
       SafeHtml render(Boolean b);

    public void onModuledLoad() {
      GWT.log("True: " + YesNoFactory.getFormat().format(Boolean.TRUE);
      Renderer r = GWT.create(Renderer.class);



package foobar.client.formatter;

import com.sencha.gxt.core.client.XTemplates.Formatter;

public class YesNo implements Formatter<Boolean> {
   public String format(Boolean data) {
      if (data == null) {
         return null;
      return (data) ? "Yes" : "No";


package foobar.client.formatter;

public class YesNoFactory {
   public static YesNo getFormat() {
      return new YesNo();

in foobar

<?xml version="1.0 encoding="UTF-8"?>
   <inherits name='com.google.gwt.user.User'/>
   <inherits name='com.sencha.gxt.GXT'/>

   <entry-point class='foobar.client.TestClass'/>

   <source path='client'/>




My formatter classes (YesNo and YesNoFactory) apparently have to be in a location that gets compiled prior to compiling the client-side code. After I moved these classes to my ‘shared’ package – the package that houses code used by the client and server – everything worked.

This was not obvious in the XTemplates portion of the guide at http://docs.sencha.com/gxt-guides/3/utility/xtemplates/XTemplates.html which does not seem to specify where the files used for custom formatters need to be located. Maybe that should have been obvious but not to me.

We are here to answer your question about GXT 3 XTemplate: Custom Formatter – ClassNotFoundException - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji