Grails gwt模块中的ClassNotFoundException

时间:2012-03-08 04:03:05

标签: java gwt grails grails-plugin

我最近尝试开始使用Grails,现在我想将我的gwt客户端部分集成到grails项目中。我正在使用Grails GWT插件并最终修复了所有编译器错误,除了这一个:

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

和GreetingsPlace $ Tokenizer和UserPlace $ Tokenizer一样重复,除了我还收到:

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

这个类是我使用内置的ActivitiesAndPlaces框架实现MVP模式的一部分.AppPlaceHistoryMapper的代码是这样的:

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 {
}

对于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);
    }

}

}

在错误列表的最后,我还有:

 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

 [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

在onModuleLoad()中,我以这种方式创建AppPlaceHistoryMapper:

 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();
}

我刚刚开始使用Grails,也许我正在做些什么。有谁可以帮助我?

2 个答案:

答案 0 :(得分:2)

我认为这个link(谷歌群组)可能会有所帮助。

基本上你必须编译使用注释创建的类(具有Tokenizers的类,在PlaceHistoryMapper上引用)。 编译完这些类后,将它们添加到GWTCompiler的类路径中。

希望有所帮助

答案 1 :(得分:1)

  

如果错误SDM编译:查找入口点类         [错误]无法找到类型'com.company.project.client.YourGWTApp'            [错误]提示:检查类型名称'com.ajna4taiga.recycling.client.RecyclingEntryPoint'真的是什么   你的意思是            [错误]提示:检查您的类路径是否包含所有必需的源根[错误]编译器返回false

为SDM添加classpath运行配置 用户条目 进度(按钮) 高级文件夹(添加YourGWTApp项目的src目录) Applay保存运行配置

  

if bellow error编译模块com.company.project.YourGWTApp
  解决com.ajna4taiga.recycling.client.AppPlaceHistoryMapper         找到类型'com.company.project.client.AppPlaceHistoryMapper'            [错误]注释错误:无法解析com.company.project.client.places.HomePlace $ HomePlaceTokenizer

您应该为SDM添加运行配置 在classpath中添加您的GWT项目 用户条目 按钮添加项目 pa检查YourGWTApp项目