Search code examples
javagwtgrailsgrails-plugin

ClassNotFoundException in Grails gwt module


I have recently tried to start using Grails and now I want to integrate my gwt client part into grails project. I am using the Grails GWT Plugin and have eventually fixed all the compiler errors, except this one:

Compiling module com.CalendarMVP
|    Resolving com.client.mvp.AppPlaceHistoryMapper
|       Found type 'com.client.mvp.AppPlaceHistoryMapper'
|          [ERROR] Annotation error: cannot resolve com.client.place.HelloPlace$Tokenizer
| java.lang.ClassNotFoundException: com.client.place.HelloPlace$Tokenizer

And the same repeats for GreetingsPlace$Tokenizer and UserPlace$Tokenizer, except that I also receive:

 [ERROR] Annotation error: expected class java.lang.Class, got null

This classes are the part of my MVP pattern realization using built-in ActivitiesAndPlaces framework.The code for AppPlaceHistoryMapper is such:

package com.client.mvp;

import com.google.gwt.place.shared.PlaceHistoryMapper;
import com.google.gwt.place.shared.WithTokenizers;

import com.client.place.GoodbyePlace;
import com.client.place.GreetingsPlace;
import com.client.place.HelloPlace;
import com.client.place.ManagerCalendarPlace;
import com.client.place.ManagerPlace;
import com.client.place.UserPlace;

@WithTokenizers( { HelloPlace.Tokenizer.class, GoodbyePlace.Tokenizer.class,
GreetingsPlace.Tokenizer.class, ManagerPlace.Tokenizer.class,
UserPlace.Tokenizer.class, ManagerCalendarPlace.Tokenizer.class
})
public interface AppPlaceHistoryMapper extends PlaceHistoryMapper {
}

And for HelloPlace:

 package com.client.place;

 import com.google.gwt.place.shared.Place;

 import com.google.gwt.place.shared.PlaceTokenizer;


 public class HelloPlace extends Place {
 private String helloName;

public HelloPlace(String token)
{
    this.helloName = token;
}

public String getHelloName()
{
    return helloName;
}

public static class Tokenizer implements PlaceTokenizer<HelloPlace>
{

    @Override
    public String getToken(HelloPlace place)
    {
        return place.getHelloName();
    }

    @Override
    public HelloPlace getPlace(String token)
    {
        return new HelloPlace(token);
    }

}

}

In the end of error list I also have:

 Computing all possible rebind results for 'com.client.mvp.AppPlaceHistoryMapper'
 |          Rebinding com.client.mvp.AppPlaceHistoryMapper
 |             Invoking generator com.google.gwt.place.rebind.PlaceHistoryMapperGenerator
 |                [ERROR] Generator 'com.google.gwt.place.rebind.PlaceHistoryMapperGenerator' threw an exception while rebinding 'com.client.mvp.AppPlaceHistoryMapper'
 | java.lang.NullPointerException

and:

 [WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
 |          [WARN] com.client.mvp.AppPlaceHistoryMapperImpl
 |    [ERROR] Errors in 'file:/D:/Naukma/Programing/JavaEE/STSworkspace/SocSystemGrails/src/gwt/com/client/CalendarMVP.java'
 |       [ERROR] Line 47:  Failed to resolve 'com.client.mvp.AppPlaceHistoryMapper' via deferred binding

In onModuleLoad() I create AppPlaceHistoryMapper in such a way:

 public void onModuleLoad()
{

    ClientFactory clientFactory = GWT.create(ClientFactoryImpl.class);
    EventBus eventBus = clientFactory.getEventBus();
    PlaceController placeController = clientFactory.getPlaceController();

    ActivityMapper activityMapper = new AppActivityMapper(clientFactory);
    ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
    activityManager.setDisplay(appWidget);

    AppPlaceHistoryMapper historyMapper= GWT.create(AppPlaceHistoryMapper.class);
    PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
    historyHandler.register(placeController, eventBus, defaultPlace);

    RootPanel.get().add(appWidget);
    // Goes to place represented on URL or default place
    historyHandler.handleCurrentHistory();
}

I have just started working with Grails and maybe I am mising something. Could anyone help me ?


Solution

  • I think this link (google groups) may help.

    Basically you have to compile the classes created using annotations (those with Tokenizers, referenced on the PlaceHistoryMapper). Once you compile that classes you add them to the classpath for the GWTCompiler.

    Hope it helps