NutzCN Logo
问答 MainLauncher cannot be cast to IndexModule
发布于 2550天前 作者 qq_85df1dfe 1770 次浏览 复制 上一个帖子 下一个帖子
标签:

使用nutz-boot,module访问不了,不知道是什么原因

17 回复

nutz的异常我觉得还是可以再完善一下

[WARN ] 16:10:16.327 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/ :
java.lang.ClassCastException: site.qiuyuan.MainLauncher cannot be cast to site.qiuyuan.module.IndexModule
at site.qiuyuan.module.IndexModule$FM$index$af964ff8bf0f4344be6f5869bfe3c669.invoke(IndexModule.java)
at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:159)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:561)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
at java.lang.Thread.run(Thread.java:748)

public class IndexModule {

@At("/")
@Ok("->:/index.html")
public String index(){
    return "t";
}

}

用 "插入代码" 按钮重新贴一次

[WARN ] 16:10:16.327 org.nutz.mvc.impl.processor.FailProcessor.process(FailProcessor.java:28) - Error@/ :
java.lang.ClassCastException: site.qiuyuan.MainLauncher cannot be cast to site.qiuyuan.module.IndexModule
 at site.qiuyuan.module.IndexModule$FM$index$af964ff8bf0f4344be6f5869bfe3c669.invoke(IndexModule.java)
 at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:31)
 at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
 at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
 at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
 at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
 at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
 at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
 at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
 at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
 at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
 at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
 at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
 at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
 at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
 at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
 at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
 at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:159)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637)
 at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
 at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
 at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
 at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
 at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
 at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
 at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
 at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
 at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
 at org.eclipse.jetty.server.Server.handle(Server.java:561)
 at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:334)
 at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
 at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
 at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:104)
 at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:679)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:597)
 at java.lang.Thread.run(Thread.java:748)
public class IndexModule {

@At("/")
@Ok("->:/index.html")
public String index(){
    return "t";
}
}
@IocBean(create = "init")
public class MainLauncher {

    @Inject
    private Dao dao;

    public void init() {
       // System.out.println(dao);
       // Daos.createTablesInPackage(dao,"site.qiuyuan.bean",true);
    }


    public static void main(String[] args) throws Exception {
        new NbApp(MainLauncher.class).run();
    }

}

我试了一下, 如果IndexModule没加@IocBean的话会报这个错误

module不是会扫描的吗

@At跟@IocBean是两个独立的东西,感觉是nutz库的bug,待我查查

我试了一下,如果在类上加上@At 就好了 建议修复一下

我错了,加了at只是不报错了,映射好像还没加上

加上@IocBean能好,我找到原因了. 你要报issue不? https://github.com/nutzam/nutz/issues

不报了吧,这个问题挺复杂,我描述不好。
怎么总感觉有一种缓存的存在,我改成这样

    @At("/index")
    @Ok("jsp:/in.jsp")
    public String index(int page,int size,ViewModel viewModel){

        return "t";
    }

还是可以进去index.jsp 项目也重启了几次了

idea的debug也没进去

知道了,原来是因为我刚才类上加的at没去掉,去掉后就行了

添加回复
请先登陆
回到顶部