gpt4 book ai didi

java - Grails gwt 模块中的 ClassNotFoundException

转载 作者:行者123 更新时间:2023-11-29 06:02:29 24 4
gpt4 key购买 nike

我最近尝试开始使用 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,也许我漏掉了什么。谁能帮帮我?

最佳答案

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

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

希望对你有帮助

关于java - Grails gwt 模块中的 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9612717/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com