NutzCN Logo
问答 module extends CommModule 注入公共url 启动报错
发布于 2841天前 作者 xupengfei08 2584 次浏览 复制 上一个帖子 下一个帖子
标签:

想将一些通用的controller写到一个公用的CommModule里面,然后所有module extends CommModule ,但是启动报错:

public class BaseModule {

    /**
     * 获取当前HttpServletRequest信息
     *
     * @return
     * @throws CommonException
     */
    protected HttpServletRequest getRequest() throws CommonException {
        return Mvcs.getReq();
    }

    /**
     * 获取dao
     *
     * @return
     * @throws CommonException
     */
    protected NutDao getDao() throws CommonException {
        NutDao nutDao = (NutDao) Mvcs.getIoc().get(Dao.class);
        return nutDao;
    }

}

CommModule

public class CommModule<T> extends BaseModule {

    protected Service<T> service;

    public CommModule(Service service) {
        this.service = service;
    }

    @POST
    @At
    public T add(@Param("..") T bean) {
        bean = service.insert(bean);
        return bean;
    }

    @PUT
    @At
    public T update(@Param("..") T bean) {
        service.updateIgnoreNull(bean);
        return bean;
    }

    @DELETE
    @At
    public void delete(@Param("id") String id) {
        service.vDelete(id);
    }

}

CompanyModule (举例业务module)

/**
 * 公司信息
 */
@IocBean(args = {"refer:crmCompanyService"})
@At("/company")
public class CompanyModule extends CommModule<Company> {

    public CompanyModule(CompanyService service) {
        super(service);
    }

    @POST
    @At
    public void hello(){

    }
}

报错信息:

[org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:98) 2017-02-11 01:09:48][INFO ]:NutIoc init begin ...
[org.nutz.ioc.impl.NutIoc.<init>(NutIoc.java:115) 2017-02-11 01:09:48][INFO ]:... NutIoc init complete
[org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:159) 2017-02-11 01:09:48][INFO ]:Build URL mapping by org.nutz.mvc.impl.UrlMappingImpl ...
[org.nutz.mvc.impl.NutLoading.createViewMakers(NutLoading.java:369) 2017-02-11 01:09:48][DEBUG]:@Views(ResultViewMaker.class,DefaultViewMaker.class)
[org.nutz.mvc.impl.NutLoading.createChainMaker(NutLoading.java:266) 2017-02-11 01:09:48][DEBUG]:@ChainBy(org.nutz.mvc.impl.NutActionChainMaker)
[org.nutz.mvc.impl.Loadings.scanModules(Loadings.java:154) 2017-02-11 01:09:48][DEBUG]:module class location 'file:/E:/download/local_projects/all_server/coagent/target/coagent/WEB-INF/classes/com/sharefree/module/MainModule.class'
[org.nutz.mvc.impl.Loadings.scanModuleInPackage(Loadings.java:184) 2017-02-11 01:09:48][DEBUG]: > scan 'com.sharefree.module'
[org.nutz.resource.Scans.scan(Scans.java:274) 2017-02-11 01:09:48][DEBUG]:Found 7 resource by src( com/sharefree/module/ ) , regex( ^.+[.]class$ )
[org.nutz.mvc.impl.Loadings.checkModule(Loadings.java:198) 2017-02-11 01:09:48][DEBUG]:   >> add 'com.sharefree.module.CommModule'
[org.nutz.mvc.impl.Loadings.checkModule(Loadings.java:198) 2017-02-11 01:09:48][DEBUG]:   >> add 'com.sharefree.module.crm.CompanyModule'
[org.nutz.mvc.impl.Loadings.checkModule(Loadings.java:198) 2017-02-11 01:09:48][DEBUG]:   >> add 'com.sharefree.module.system.LoginModule'
[org.nutz.mvc.impl.Loadings.checkModule(Loadings.java:198) 2017-02-11 01:09:48][DEBUG]:   >> add 'com.sharefree.module.system.MenuModule'
[org.nutz.mvc.impl.Loadings.checkModule(Loadings.java:198) 2017-02-11 01:09:48][DEBUG]:   >> add 'com.sharefree.module.system.RoleModule'
[org.nutz.mvc.impl.processor.ModuleProcessor.init(ModuleProcessor.java:61) 2017-02-11 01:09:48][INFO ]:Create Module obj without Ioc --> class com.sharefree.module.CommModule
[org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:51) 2017-02-11 01:09:48][DEBUG]:Eval FAIL!! : public java.lang.Object com.sharefree.module.CommModule.add(java.lang.Object)
org.nutz.lang.born.BorningException: Fail to born 'com.sharefree.module.CommModule'
 by args: [] because: No suitable Constructor or Factory Method!!
	at org.nutz.lang.Mirror.born(Mirror.java:988)
	at org.nutz.mvc.impl.processor.ModuleProcessor.init(ModuleProcessor.java:63)
	at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
	at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
	at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:204)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1558)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:620)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:567)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
[org.nutz.mvc.impl.NutLoading.load(NutLoading.java:125) 2017-02-11 01:09:48][ERROR]:Error happend during start serivce!
org.nutz.lang.born.BorningException: Fail to born 'com.sharefree.module.CommModule'
 by args: [] because: No suitable Constructor or Factory Method!!
	at org.nutz.lang.Mirror.born(Mirror.java:988)
	at org.nutz.mvc.impl.processor.ModuleProcessor.init(ModuleProcessor.java:63)
	at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
	at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
	at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:204)
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19)
	at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
	at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1558)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:620)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:567)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
[org.nutz.mvc.impl.NutLoading.load(NutLoading.java:127) 2017-02-11 01:09:48][ERROR]:try to depose ioc
[org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:255) 2017-02-11 01:09:48][INFO ]:org.nutz.ioc.impl.NutIoc@893572605 is closing. startup date [17-02-11 01:09:48.303]
[org.nutz.ioc.impl.NutIoc.depose(NutIoc.java:262) 2017-02-11 01:09:48][INFO ]:org.nutz.ioc.impl.NutIoc@893572605 is deposed. startup date [17-02-11 01:09:48.303]
Feb 11, 2017 1:09:48 AM org.apache.catalina.core.StandardContext startInternal
严重: Error filterStart
Feb 11, 2017 1:09:48 AM org.apache.catalina.core.StandardContext startInternal
严重: Context [] startup failed due to previous errors
[2017-02-11 01:09:48,387] Artifact coagent:war exploded: Error during artifact deployment. See server log for details.
Feb 11, 2017 1:09:54 AM org.apache.catalina.startup.HostConfig deployDirectory
信息: Deploying web application directory D:\Program Files\Java\apache-tomcat-7.0.47\webapps\manager
7 回复

CommModule改成抽象类

@wendal 现在可以正常启动了
但是好像没有加载CommModule里面的@At方法

[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]:   '/company/hello'            >> (CompanyModule.java:27).hello         : void       | @Ok(success) @Fail(exception) | by 1 Filters | (I:UTF-8/O:UTF-8)
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]:   '/menu/tree'                >> (MenuModule.java:27).getMenuTree      : JsonResult | @Ok(success) @Fail(exception) | by 1 Filters | (I:UTF-8/O:UTF-8)
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]:   '/login/check'              >> (LoginModule.java:88).check           : JsonResult | @Ok(success) @Fail(exception) | by 1 Filters | (I:UTF-8/O:UTF-8)
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]:   '/login'                    >> (LoginModule.java:47).byUserNo        : JsonResult | @Ok(success) @Fail(exception) | by 1 Filters | (I:UTF-8/O:UTF-8)
[org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:220) 2017-02-11 10:51:06][INFO ]:Found 4 module methods

@xupengfei08 是bug,建议换上nutz 1.r.61快照版

@wendal 按道理应该还有
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]: '/company/add' ...
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]: '/company/update' ...
[org.nutz.mvc.impl.UrlMappingImpl.print(UrlMappingImpl.java:146) 2017-02-11 10:51:06][DEBUG]: '/company/delete' ...

@wendal 快照版是什么版本?开发版本?

@wendal 大神,nutz 1.r.61快照版在哪里啊,maven引入失败 (lll¬ω¬)

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